From ab53600bd7a4a57a5765c1b3dfafe85b1c042acf Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 8 Mar 2017 22:51:39 -0800 Subject: 3768 - trace browser: scrolling horizontally --- 100trace_browser.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to '100trace_browser.cc') diff --git a/100trace_browser.cc b/100trace_browser.cc index 5464080a..fb3e3df0 100644 --- a/100trace_browser.cc +++ b/100trace_browser.cc @@ -31,6 +31,8 @@ //: `k` or `up-arrow`: Move/scroll cursor up one line. //: `J` or `ctrl-f` or `page-down`: Scroll cursor down one page. //: `K` or `ctrl-b` or `page-up`: Scroll cursor up one page. +//: `H`: Scroll cursor left one screen-width. +//: `L`: Scroll cursor right one screen-width. //: //: `g` or `home`: Move cursor to start of trace. //: `G` or `end`: Move cursor to end of trace. @@ -65,6 +67,7 @@ if (argc == 3 && is_equal(argv[1], "browse-trace")) { :(before "End Globals") set Visible; int Top_of_screen = 0; +int Left_of_screen = 0; int Last_printed_row = 0; map Trace_index; // screen row -> trace index @@ -120,6 +123,13 @@ void start_trace_browser() { Display_row = 0; refresh_screen_rows(); } + if (key == 'H') { + Left_of_screen -= (tb_width() - 5); + if (Left_of_screen < 0) Left_of_screen = 0; + } + if (key == 'L') { + Left_of_screen += (tb_width() - 5); + } if (key == 'J' || key == TB_KEY_PGDN || key == TB_KEY_CTRL_F) { // page-down if (Trace_index.find(tb_height()-1) != Trace_index.end()) { @@ -257,8 +267,8 @@ int lines_hidden(int screen_row) { void render_line(int screen_row, const string& s, bool highlight) { int col = 0; int color = TB_WHITE; - for (col = 0; col < tb_width() && col < SIZE(s); ++col) { - char c = s.at(col); // todo: unicode + for (col = 0; col < tb_width() && col+Left_of_screen < SIZE(s); ++col) { + char c = s.at(col+Left_of_screen); // todo: unicode if (c == '\n') c = ';'; // replace newlines with semi-colons // escapes. hack: can't start a line with them. if (c == '\1') { color = /*red*/1; c = ' '; } -- cgit 1.4.1-2-gfad0