about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-12-21 22:25:36 -0800
committerKartik Agaram <vc@akkartik.com>2019-12-21 22:40:24 -0800
commitc9c6ab35a66f791ebdc32ce1b33fda14595befe2 (patch)
treebdc0393bcf40817852cb1807cdc3576d9528e1a6
parente1dd3f95788b573bbb8d846df89c51d9cff27db6 (diff)
downloadmu-c9c6ab35a66f791ebdc32ce1b33fda14595befe2.tar.gz
5812 - debugging an ancient niggle in browse_trace
The problem: when I hit 'G' to go to the bottom of the trace, if the bottom
is visible on screen, the screen scrolls so the bottom of the trace
is the bottom-most line on screen. But the cursor moves to where the trace
used to end rather than the new location of the bottom of the trace (the
bottom of the screen).
-rw-r--r--tools/browse_trace.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/browse_trace.cc b/tools/browse_trace.cc
index b15da9c8..f1d8b5c8 100644
--- a/tools/browse_trace.cc
+++ b/tools/browse_trace.cc
@@ -132,8 +132,7 @@ void load_trace(const char* filename) {
   cerr << "lines read: " << Trace_stream->past_lines.size() << '\n';
 }
 
-// update Trace_indices for each screen_row on the basis of Top_of_screen and Visible
-void refresh_screen_rows() {
+void refresh_screen_rows() {  // Top_of_screen, Visible -> Trace_index
   int screen_row = 0, index = 0;
   Trace_index.clear();
   for (screen_row = 0, index = Top_of_screen;  screen_row < tb_height() && index < SIZE(Trace_stream->past_lines);  ++screen_row, ++index) {
@@ -148,7 +147,7 @@ void refresh_screen_rows() {
 done:;
 }
 
-void clear_line(int screen_row) {
+void clear_line(int screen_row) {  // -> screen
   tb_set_cursor(0, screen_row);
   for (int col = 0;  col < tb_width();  ++col)
     tb_print(' ', TB_WHITE, TB_BLACK);
@@ -193,7 +192,7 @@ vector<pair<size_t, size_t> > find_all_occurrences(const string& s, const string
   return result;
 }
 
-void render_line(int screen_row, const string& s, bool cursor_line) {
+void render_line(int screen_row, const string& s, bool cursor_line) {  // -> screen
   int col = 0;
   int color = TB_WHITE;
   int background_color = cursor_line ? /*subtle grey*/240 : TB_BLACK;
@@ -337,7 +336,7 @@ bool start_search_editor(search_direction dir) {
   }
 }
 
-void render() {
+void render() {  // Trace_index -> Last_printed_row, screen
   int screen_row = 0;
   for (screen_row = 0;  screen_row < tb_height();  ++screen_row) {
     if (!contains_key(Trace_index, screen_row)) break;
@@ -469,7 +468,7 @@ int main(int argc, char* argv[]) {
         refresh_screen_rows();
     }
     else if (key == 'G' || key == TB_KEY_END) {
-      // go to bottom of screen; largely like page-up, interestingly
+      // go to bottom of trace; largely like page-up, interestingly
       Top_of_screen = SIZE(Trace_stream->past_lines)-1;
       for (int screen_row = tb_height();  screen_row > 0 && Top_of_screen > 0;  --screen_row) {
         --Top_of_screen;