about summary refs log tree commit diff stats
path: root/100trace_browser.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-03-08 22:51:39 -0800
committerKartik K. Agaram <vc@akkartik.com>2017-03-08 22:59:40 -0800
commitab53600bd7a4a57a5765c1b3dfafe85b1c042acf (patch)
tree6f1f37537ce756ba732d11d1f4c00acc09c56912 /100trace_browser.cc
parentb0ef6d58e25e11145c165d59dcd3c79246b34931 (diff)
downloadmu-ab53600bd7a4a57a5765c1b3dfafe85b1c042acf.tar.gz
3768 - trace browser: scrolling horizontally
Diffstat (limited to '100trace_browser.cc')
-rw-r--r--100trace_browser.cc14
1 files changed, 12 insertions, 2 deletions
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<int> Visible;
 int Top_of_screen = 0;
+int Left_of_screen = 0;
 int Last_printed_row = 0;
 map<int, int> 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 = ' '; }