window: fill background color on clearing to EOL

This commit is contained in:
Andrzej Rybczak
2014-11-11 16:08:48 +01:00
parent 011738f653
commit d26c3c8fc5
5 changed files with 28 additions and 16 deletions

View File

@@ -465,7 +465,8 @@ void Status::Changes::playerState()
myPlaylist->reloadRemaining();
if (Config.design == Design::Alternative)
{
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::XY(0, 1) << wclrtoeol;
*wHeader << NC::XY(0, 0) << NC::TermManip::ClearToEOL;
*wHeader << NC::XY(0, 1) << NC::TermManip::ClearToEOL;
mixer();
flags();
}
@@ -488,7 +489,7 @@ void Status::Changes::playerState()
{
*wFooter << NC::XY(0, 1);
if (state.empty())
*wFooter << wclrtoeol;
*wFooter << NC::TermManip::ClearToEOL;
else
*wFooter << NC::Format::Bold << state << NC::Format::NoBold;
}
@@ -551,7 +552,7 @@ void Status::Changes::elapsedTime(bool update_elapsed)
if (m_player_state == MPD::psStop)
{
if (Statusbar::isUnlocked() && Config.statusbar_visibility)
*wFooter << NC::XY(0, 1) << wclrtoeol;
*wFooter << NC::XY(0, 1) << NC::TermManip::ClearToEOL;
return;
}
@@ -592,7 +593,7 @@ void Status::Changes::elapsedTime(bool update_elapsed)
}
NC::WBuffer np_song;
Format::print(Config.song_status_wformat, np_song, &np);
*wFooter << NC::XY(0, 1) << wclrtoeol << NC::Format::Bold << ps << NC::Format::NoBold;
*wFooter << NC::XY(0, 1) << NC::TermManip::ClearToEOL << NC::Format::Bold << ps << NC::Format::NoBold;
writeCyclicBuffer(np_song, *wFooter, playing_song_scroll_begin, wFooter->getWidth()-ps.length()-tracklength.length(), L" ** ");
*wFooter << NC::Format::Bold << NC::XY(wFooter->getWidth()-tracklength.length(), 1) << tracklength << NC::Format::NoBold;
}
@@ -631,11 +632,11 @@ void Status::Changes::elapsedTime(bool update_elapsed)
size_t second_start = second_len < COLS-second_margin ? (COLS-second_len)/2 : ps.length()+1;
if (!Global::SeekingInProgress)
*wHeader << NC::XY(0, 0) << wclrtoeol << tracklength;
*wHeader << NC::XY(0, 0) << NC::TermManip::ClearToEOL << tracklength;
*wHeader << NC::XY(first_start, 0);
writeCyclicBuffer(first, *wHeader, first_line_scroll_begin, COLS-tracklength.length()-VolumeState.length()-1, L" ** ");
*wHeader << NC::XY(0, 1) << wclrtoeol << NC::Format::Bold << ps << NC::Format::NoBold;
*wHeader << NC::XY(0, 1) << NC::TermManip::ClearToEOL << NC::Format::Bold << ps << NC::Format::NoBold;
*wHeader << NC::XY(second_start, 1);
writeCyclicBuffer(second, *wHeader, second_line_scroll_begin, COLS-ps.length()-8-2, L" ** ");

View File

@@ -112,7 +112,7 @@ Statusbar::ScopedLock::~ScopedLock() noexcept
switch (Config.design)
{
case Design::Classic:
put() << wclrtoeol;
put(); // clear statusbar
break;
case Design::Alternative:
Progressbar::draw(Status::State::elapsedTime(), Status::State::totalTime());
@@ -149,7 +149,7 @@ void Statusbar::tryRedraw()
{
case MPD::psUnknown:
case MPD::psStop:
put() << wclrtoeol;
put(); // clear statusbar
break;
case MPD::psPlay:
case MPD::psPause:
@@ -168,7 +168,7 @@ void Statusbar::tryRedraw()
NC::Window &Statusbar::put()
{
*wFooter << NC::XY(0, Config.statusbar_visibility ? 1 : 0) << wclrtoeol;
*wFooter << NC::XY(0, Config.statusbar_visibility ? 1 : 0) << NC::TermManip::ClearToEOL;
return *wFooter;
}
@@ -183,7 +183,7 @@ void Statusbar::print(int delay, const std::string &message)
else
progressbar_block_update = true;
wFooter->goToXY(0, Config.statusbar_visibility);
*wFooter << message << wclrtoeol;
*wFooter << message << NC::TermManip::ClearToEOL;
wFooter->refresh();
}
}

View File

@@ -47,14 +47,14 @@ void drawHeader()
switch (Config.design)
{
case Design::Classic:
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::Format::Bold << myScreen->title() << NC::Format::NoBold;
*wHeader << NC::XY(0, 0) << NC::TermManip::ClearToEOL << NC::Format::Bold << myScreen->title() << NC::Format::NoBold;
*wHeader << Config.volume_color;
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << VolumeState;
*wHeader << NC::Color::End;
break;
case Design::Alternative:
std::wstring title = myScreen->title();
*wHeader << NC::XY(0, 3) << wclrtoeol;
*wHeader << NC::XY(0, 3) << NC::TermManip::ClearToEOL;
*wHeader << NC::Format::Bold << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS);
mvwhline(wHeader->raw(), 4, 0, 0, COLS);

View File

@@ -1094,9 +1094,18 @@ Window &Window::operator<<(Format format)
return *this;
}
Window &Window::operator<<(int (*f)(WINDOW *))
Window &Window::operator<<(TermManip tm)
{
f(m_window);
switch (tm)
{
case TermManip::ClearToEOL:
{
auto x = getX(), y = getY();
mvwhline(m_window, y, x, ' ', m_width-x);
goToXY(x, y);
}
break;
}
return *this;
}

View File

@@ -187,6 +187,9 @@ private:
std::ostream &operator<<(std::ostream &os, const Color &c);
std::istream &operator>>(std::istream &is, Color &f);
/// Terminal manipulation functions
enum class TermManip { ClearToEOL };
/// Format flags used by NCurses
enum class Format {
None,
@@ -410,8 +413,7 @@ struct Window
/// @param where indicates how many lines it has to scroll
virtual void scroll(Scroll where);
/// Applies function of compatible prototype to internal WINDOW pointer
Window &operator<<(int (*f)(WINDOW *));
Window &operator<<(TermManip tm);
Window &operator<<(const Color &color);
Window &operator<<(Format format);
Window &operator<<(const XY &coords);