Sun, 14 Dec 2014 18:15:28 +0200
- added backlog scrolling
sources/interface.cpp | file | annotate | diff | comparison | revisions |
--- a/sources/interface.cpp Sun Dec 14 17:53:24 2014 +0200 +++ b/sources/interface.cpp Sun Dec 14 18:15:28 2014 +0200 @@ -31,6 +31,8 @@ #include <string.h> #include "interface.h" +enum { PAGE_SIZE = 10 }; + static String g_input; static int g_cursor = 0; static int g_pan = 0; @@ -68,7 +70,14 @@ interface_render_log_area() -> void { int height = LINES - 3; - int start = max (0, g_output.size() - height - 1); + + // ensure we're within bounds + if (g_outputScroll + height >= g_output.size()) + g_outputScroll = g_output.size() - height - 1; + else if (g_outputScroll < 0) + g_outputScroll = 0; + + int start = max (0, g_output.size() - height - 1 - g_outputScroll); int end = min (g_output.size(), start + height); int y = 1; assert (end - start <= height); @@ -183,6 +192,7 @@ interface_render_full(); refresh(); g_needRefresh = false; + print ("Interface initialized.\n"); } // ------------------------------------------------------------------------------------------------- @@ -252,6 +262,18 @@ g_needInputRender = true; } break; + + case KEY_PPAGE: + g_outputScroll += PAGE_SIZE; + interface_render_log_area(); + g_needRefresh = true; + break; + + case KEY_NPAGE: + g_outputScroll -= PAGE_SIZE; + interface_render_log_area(); + g_needRefresh = true; + break; } if (g_needStatusBarRender) interface_render_statusbar();