Sun, 14 Dec 2014 20:20:43 +0200
- now in color! (titlebar at least anyway)
sources/interface.cpp | file | annotate | diff | comparison | revisions | |
sources/interface.h | file | annotate | diff | comparison | revisions |
--- a/sources/interface.cpp Sun Dec 14 19:51:23 2014 +0200 +++ b/sources/interface.cpp Sun Dec 14 20:20:43 2014 +0200 @@ -49,6 +49,40 @@ // ------------------------------------------------------------------------------------------------- // static FUNCTION +interface_color_pair (Color fg, Color bg) -> int +{ + return COLOR_PAIR ((int (fg) * NUM_COLORS) + int (bg)); +} + +// ------------------------------------------------------------------------------------------------- +// +FUNCTION +Interface::initialize() -> void +{ + ::initscr(); + ::start_color(); + ::raw(); + ::keypad (stdscr, true); + ::noecho(); + ::refresh(); + ::timeout (0); + + for (int i = 0; i < NUM_COLORS; ++i) + for (int j = 0; j < NUM_COLORS; ++j) + { + init_pair ((i * NUM_COLORS + j), + (i == DEFAULT) ? -1 : i, + (j == DEFAULT) ? -1 : j); + } + + render_full(); + refresh(); + g_needRefresh = false; + print ("Interface initialized.\n"); +} +// ------------------------------------------------------------------------------------------------- +// +static FUNCTION interface_sessions_width() -> int { return COLS / 3; @@ -57,13 +91,29 @@ // ------------------------------------------------------------------------------------------------- // static FUNCTION +interface_clear_titlebar() -> void +{ + int pair = interface_color_pair (WHITE, BLUE); + attron (pair); + mvhline (0, 0, ' ', COLS); + attroff (pair); +} + +// ------------------------------------------------------------------------------------------------- +// +static FUNCTION interface_render_titlebar() -> void { String versionText = format (APPNAME " %1 (%2)", full_version_string(), changeset_date_string()); if (versionText.length() <= COLS) + { + int pair = interface_color_pair (WHITE, BLUE); + attron (pair); mvprintw (0, (COLS - versionText.length()) / 2, "%s", versionText.chars()); + attroff (pair); + } } // ------------------------------------------------------------------------------------------------- @@ -162,9 +212,10 @@ // ------------------------------------------------------------------------------------------------- // -static FUNCTION -interface_render_full() -> void +FUNCTION +Interface::render_full() -> void { + interface_clear_titlebar(); interface_render_titlebar(); interface_render_output(); interface_render_statusbar(); @@ -187,24 +238,6 @@ // ------------------------------------------------------------------------------------------------- // FUNCTION -Interface::initialize() -> void -{ - ::initscr(); - ::start_color(); - ::raw(); - ::keypad (stdscr, true); - ::noecho(); - ::refresh(); - ::timeout (0); - interface_render_full(); - refresh(); - g_needRefresh = false; - print ("Interface initialized.\n"); -} - -// ------------------------------------------------------------------------------------------------- -// -FUNCTION Interface::handle_input() -> void { int ch = ::getch();