From 8c40f046b938f9b8123d385eb38b36ee38630a6a Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 15 Dec 2008 20:57:30 +0100 Subject: [PATCH] render state line on stdscr instead of header window --- src/ncmpcpp.cpp | 2 +- src/status_checker.cpp | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index cecb2cce..b0b910ee 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -311,7 +311,7 @@ int main(int argc, char *argv[]) if (Config.header_visibility) { - wHeader = new Window(0, 0, COLS, 2, "", Config.header_color, brNone); + wHeader = new Window(0, 0, COLS, 1, "", Config.header_color, brNone); wHeader->Display(); } diff --git a/src/status_checker.cpp b/src/status_checker.cpp index f77850b3..16158184 100644 --- a/src/status_checker.cpp +++ b/src/status_checker.cpp @@ -432,26 +432,27 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) if (mpd_db_updating) switch_state += mpd_db_updating; - wHeader->Bold(1); - wHeader->SetColor(Config.state_line_color); - mvwhline(wHeader->Raw(), 1, 0, 0, wHeader->GetWidth()); + // this is done by raw ncurses because creating another + // window only for handling this is quite silly + attrset(A_BOLD|COLOR_PAIR(Config.state_line_color)); + mvhline(1, 0, 0, COLS); if (!switch_state.empty()) { - wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-3, 1, 0, "["); - wHeader->SetColor(Config.state_flags_color); - wHeader->WriteXY(wHeader->GetWidth()-switch_state.length()-2, 1, 0, "%s", switch_state.c_str()); - wHeader->SetColor(Config.state_line_color); - wHeader->WriteXY(wHeader->GetWidth()-2, 1, 0, "]"); + + mvprintw(1, COLS-switch_state.length()-3, "["); + attron(COLOR_PAIR(Config.state_flags_color)); + mvprintw(1, COLS-switch_state.length()-2, "%s", switch_state.c_str()); + attron(COLOR_PAIR(Config.state_line_color)); + mvprintw(1, COLS-2, "]"); } - wHeader->SetColor(Config.header_color); - wHeader->Bold(0); + attroff(A_BOLD|COLOR_PAIR(Config.state_line_color)); + refresh(); header_update_status = 0; } if ((changed.Volume) && Config.header_visibility) { - int vol = Mpd->GetVolume(); volume_state = " Volume: "; - volume_state += IntoStr(vol); + volume_state += IntoStr(Mpd->GetVolume()); volume_state += "%"; wHeader->SetColor(Config.volume_color); wHeader->WriteXY(wHeader->GetWidth()-volume_state.length(), 0, 1, "%s", volume_state.c_str());