| 47 static int g_outputScroll = 0; |
47 static int g_outputScroll = 0; |
| 48 |
48 |
| 49 // ------------------------------------------------------------------------------------------------- |
49 // ------------------------------------------------------------------------------------------------- |
| 50 // |
50 // |
| 51 static FUNCTION |
51 static FUNCTION |
| |
52 interface_color_pair (Color fg, Color bg) -> int |
| |
53 { |
| |
54 return COLOR_PAIR ((int (fg) * NUM_COLORS) + int (bg)); |
| |
55 } |
| |
56 |
| |
57 // ------------------------------------------------------------------------------------------------- |
| |
58 // |
| |
59 FUNCTION |
| |
60 Interface::initialize() -> void |
| |
61 { |
| |
62 ::initscr(); |
| |
63 ::start_color(); |
| |
64 ::raw(); |
| |
65 ::keypad (stdscr, true); |
| |
66 ::noecho(); |
| |
67 ::refresh(); |
| |
68 ::timeout (0); |
| |
69 |
| |
70 for (int i = 0; i < NUM_COLORS; ++i) |
| |
71 for (int j = 0; j < NUM_COLORS; ++j) |
| |
72 { |
| |
73 init_pair ((i * NUM_COLORS + j), |
| |
74 (i == DEFAULT) ? -1 : i, |
| |
75 (j == DEFAULT) ? -1 : j); |
| |
76 } |
| |
77 |
| |
78 render_full(); |
| |
79 refresh(); |
| |
80 g_needRefresh = false; |
| |
81 print ("Interface initialized.\n"); |
| |
82 } |
| |
83 // ------------------------------------------------------------------------------------------------- |
| |
84 // |
| |
85 static FUNCTION |
| 52 interface_sessions_width() -> int |
86 interface_sessions_width() -> int |
| 53 { |
87 { |
| 54 return COLS / 3; |
88 return COLS / 3; |
| |
89 } |
| |
90 |
| |
91 // ------------------------------------------------------------------------------------------------- |
| |
92 // |
| |
93 static FUNCTION |
| |
94 interface_clear_titlebar() -> void |
| |
95 { |
| |
96 int pair = interface_color_pair (WHITE, BLUE); |
| |
97 attron (pair); |
| |
98 mvhline (0, 0, ' ', COLS); |
| |
99 attroff (pair); |
| 55 } |
100 } |
| 56 |
101 |
| 57 // ------------------------------------------------------------------------------------------------- |
102 // ------------------------------------------------------------------------------------------------- |
| 58 // |
103 // |
| 59 static FUNCTION |
104 static FUNCTION |
| 61 { |
106 { |
| 62 String versionText = format (APPNAME " %1 (%2)", |
107 String versionText = format (APPNAME " %1 (%2)", |
| 63 full_version_string(), changeset_date_string()); |
108 full_version_string(), changeset_date_string()); |
| 64 |
109 |
| 65 if (versionText.length() <= COLS) |
110 if (versionText.length() <= COLS) |
| |
111 { |
| |
112 int pair = interface_color_pair (WHITE, BLUE); |
| |
113 attron (pair); |
| 66 mvprintw (0, (COLS - versionText.length()) / 2, "%s", versionText.chars()); |
114 mvprintw (0, (COLS - versionText.length()) / 2, "%s", versionText.chars()); |
| |
115 attroff (pair); |
| |
116 } |
| 67 } |
117 } |
| 68 |
118 |
| 69 // ------------------------------------------------------------------------------------------------- |
119 // ------------------------------------------------------------------------------------------------- |
| 70 // |
120 // |
| 71 static FUNCTION |
121 static FUNCTION |
| 160 g_needStatusBarRender = true; |
210 g_needStatusBarRender = true; |
| 161 } |
211 } |
| 162 |
212 |
| 163 // ------------------------------------------------------------------------------------------------- |
213 // ------------------------------------------------------------------------------------------------- |
| 164 // |
214 // |
| 165 static FUNCTION |
215 FUNCTION |
| 166 interface_render_full() -> void |
216 Interface::render_full() -> void |
| 167 { |
217 { |
| |
218 interface_clear_titlebar(); |
| 168 interface_render_titlebar(); |
219 interface_render_titlebar(); |
| 169 interface_render_output(); |
220 interface_render_output(); |
| 170 interface_render_statusbar(); |
221 interface_render_statusbar(); |
| 171 interface_render_input(); |
222 interface_render_input(); |
| 172 } |
223 } |
| 185 } |
236 } |
| 186 |
237 |
| 187 // ------------------------------------------------------------------------------------------------- |
238 // ------------------------------------------------------------------------------------------------- |
| 188 // |
239 // |
| 189 FUNCTION |
240 FUNCTION |
| 190 Interface::initialize() -> void |
|
| 191 { |
|
| 192 ::initscr(); |
|
| 193 ::start_color(); |
|
| 194 ::raw(); |
|
| 195 ::keypad (stdscr, true); |
|
| 196 ::noecho(); |
|
| 197 ::refresh(); |
|
| 198 ::timeout (0); |
|
| 199 interface_render_full(); |
|
| 200 refresh(); |
|
| 201 g_needRefresh = false; |
|
| 202 print ("Interface initialized.\n"); |
|
| 203 } |
|
| 204 |
|
| 205 // ------------------------------------------------------------------------------------------------- |
|
| 206 // |
|
| 207 FUNCTION |
|
| 208 Interface::handle_input() -> void |
241 Interface::handle_input() -> void |
| 209 { |
242 { |
| 210 int ch = ::getch(); |
243 int ch = ::getch(); |
| 211 set_statusbar_text (String::from_number (ch)); |
244 set_statusbar_text (String::from_number (ch)); |
| 212 |
245 |