# HG changeset patch # User Teemu Piippo # Date 1418573728 -7200 # Node ID 33bac54867bfc5e11b71da91ae56e14d956860d4 # Parent 33da84af4bbaad477eeeaffa0958c52b4ce6b8b1 - added backlog scrolling diff -r 33da84af4bba -r 33bac54867bf sources/interface.cpp --- 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 #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();