29 */ |
29 */ |
30 |
30 |
31 #include <string.h> |
31 #include <string.h> |
32 #include "interface.h" |
32 #include "interface.h" |
33 |
33 |
|
34 enum { PAGE_SIZE = 10 }; |
|
35 |
34 static String g_input; |
36 static String g_input; |
35 static int g_cursor = 0; |
37 static int g_cursor = 0; |
36 static int g_pan = 0; |
38 static int g_pan = 0; |
37 static bool g_needRefresh = false; |
39 static bool g_needRefresh = false; |
38 static bool g_needStatusBarRender = false; |
40 static bool g_needStatusBarRender = false; |
66 // |
68 // |
67 static FUNCTION |
69 static FUNCTION |
68 interface_render_log_area() -> void |
70 interface_render_log_area() -> void |
69 { |
71 { |
70 int height = LINES - 3; |
72 int height = LINES - 3; |
71 int start = max (0, g_output.size() - height - 1); |
73 |
|
74 // ensure we're within bounds |
|
75 if (g_outputScroll + height >= g_output.size()) |
|
76 g_outputScroll = g_output.size() - height - 1; |
|
77 else if (g_outputScroll < 0) |
|
78 g_outputScroll = 0; |
|
79 |
|
80 int start = max (0, g_output.size() - height - 1 - g_outputScroll); |
72 int end = min (g_output.size(), start + height); |
81 int end = min (g_output.size(), start + height); |
73 int y = 1; |
82 int y = 1; |
74 assert (end - start <= height); |
83 assert (end - start <= height); |
75 |
84 |
76 for (int i = start; i < end; ++i) |
85 for (int i = start; i < end; ++i) |
250 { |
260 { |
251 g_input.remove_at (g_cursor); |
261 g_input.remove_at (g_cursor); |
252 g_needInputRender = true; |
262 g_needInputRender = true; |
253 } |
263 } |
254 break; |
264 break; |
|
265 |
|
266 case KEY_PPAGE: |
|
267 g_outputScroll += PAGE_SIZE; |
|
268 interface_render_log_area(); |
|
269 g_needRefresh = true; |
|
270 break; |
|
271 |
|
272 case KEY_NPAGE: |
|
273 g_outputScroll -= PAGE_SIZE; |
|
274 interface_render_log_area(); |
|
275 g_needRefresh = true; |
|
276 break; |
255 } |
277 } |
256 |
278 |
257 if (g_needStatusBarRender) interface_render_statusbar(); |
279 if (g_needStatusBarRender) interface_render_statusbar(); |
258 if (g_needInputRender) interface_render_input(); |
280 if (g_needInputRender) interface_render_input(); |
259 |
281 |