Skip to content

Commit

Permalink
BasicMarquee: change separator to std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 1, 2024
1 parent 017bc06 commit 466f9d0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/BasicMarquee.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ using std::string_view_literals::operator""sv;
std::string_view
BasicMarquee::ScrollString() const noexcept
{
assert(separator != nullptr);

const char *p = AtCharMB(buffer.data(), buffer.length(), offset);
const char *end = AtWidthMB(p, strlen(p), width);
return {p, end};
Expand All @@ -24,7 +22,6 @@ BasicMarquee::ScrollString() const noexcept
bool
BasicMarquee::Set(unsigned _width, const char *_text) noexcept
{
assert(separator != nullptr);
assert(_text != nullptr);

if (_width == width && text == _text)
Expand Down
5 changes: 3 additions & 2 deletions src/BasicMarquee.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#pragma once

#include <string>
#include <string_view>
#include <utility>

/**
* This class is used to auto-scroll text which does not fit on the
* screen. Call Set() to begin scrolling.
*/
class BasicMarquee {
const char *const separator;
const std::string_view separator;

/**
* The scrolled text, in the current locale.
Expand Down Expand Up @@ -40,7 +41,7 @@ class BasicMarquee {
unsigned offset;

public:
BasicMarquee(const char *_separator) noexcept
explicit BasicMarquee(std::string_view _separator) noexcept
:separator(_separator) {}

bool IsDefined() const noexcept {
Expand Down
2 changes: 1 addition & 1 deletion src/QueuePage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class QueuePage final : public ListPage, ListRenderer, ListText {
screen(_screen),
#ifndef NCMPC_MINI
hscroll(screen.GetEventLoop(),
_window, options.scroll_sep.c_str()),
_window, options.scroll_sep),
table_layout(song_table_structure),
#endif
hide_cursor_timer(screen.GetEventLoop(),
Expand Down
2 changes: 1 addition & 1 deletion src/StatusBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ StatusBar::StatusBar(EventLoop &event_loop,
:window(p, {width, 1u}),
message_timer(event_loop, BIND_THIS_METHOD(OnMessageTimer))
#ifndef NCMPC_MINI
, hscroll(event_loop, window, options.scroll_sep.c_str())
, hscroll(event_loop, window, options.scroll_sep)
#endif
{
leaveok(window.w, false);
Expand Down
2 changes: 1 addition & 1 deletion src/hscroll.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class hscroll {

public:
hscroll(EventLoop &event_loop,
const Window _window, const char *_separator) noexcept
const Window _window, std::string_view _separator) noexcept
:window(_window), basic(_separator),
timer(event_loop, BIND_THIS_METHOD(OnTimer))
{
Expand Down

0 comments on commit 466f9d0

Please sign in to comment.