# HG changeset patch # User Teemu Piippo # Date 1418581243 -7200 # Node ID 5f8cdc8febbbb37670953a0b7d53e0e1a715e0ce # Parent 2046a1651c0bca742d34e1656a5672e5f5a57a9d - now in color! (titlebar at least anyway) diff -r 2046a1651c0b -r 5f8cdc8febbb sources/interface.cpp --- 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(); diff -r 2046a1651c0b -r 5f8cdc8febbb sources/interface.h --- a/sources/interface.h Sun Dec 14 19:51:23 2014 +0200 +++ b/sources/interface.h Sun Dec 14 20:20:43 2014 +0200 @@ -36,4 +36,5 @@ FUNCTION initialize() -> void; FUNCTION handle_input() -> void; FUNCTION render() -> void; + FUNCTION render_full() -> void; };