From 8ccf992d317a867f5e477b2dee5db90b2c5ded3a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 6 Mar 2017 09:40:43 -0800 Subject: 3759 - make current line more salient --- html/100trace_browser.cc.html | 73 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'html/100trace_browser.cc.html') diff --git a/html/100trace_browser.cc.html b/html/100trace_browser.cc.html index 0da9a5bd..9d621a9d 100644 --- a/html/100trace_browser.cc.html +++ b/html/100trace_browser.cc.html @@ -115,7 +115,7 @@ if ('onhashchange' in window) { 57 //: browse a trace loaded from a file 58 :(after "Commandline Parsing") 59 if (argc == 3 && is_equal(argv[1], "browse-trace")) { - 60 load_trace(argv[2]); + 60 load_trace(argv[2]); 61 start_trace_browser(); 62 return 0; 63 } @@ -287,12 +287,12 @@ if ('onhashchange' in window) { 229 out << " (" << delta << ")"; 230 if (delta > 999) out << static_cast<char>(2); 231 } -232 render_line(screen_row, out.str()); +232 render_line(screen_row, out.str(), screen_row == Display_row); 233 } 234 // clear rest of screen 235 Last_printed_row = screen_row-1; 236 for (; screen_row < tb_height(); ++screen_row) { -237 render_line(screen_row, "~"); +237 render_line(screen_row, "~", /*highlight?*/false); 238 } 239 // move cursor back to display row at the end 240 tb_set_cursor(0, Display_row); @@ -307,7 +307,7 @@ if ('onhashchange' in window) { 249 return get(Trace_index, screen_row+1) - get(Trace_index, screen_row); 250 } 251 -252 void render_line(int screen_row, const string& s) { +252 void render_line(int screen_row, const string& s, bool highlight) { 253 int col = 0; 254 int color = TB_WHITE; 255 for (col = 0; col < tb_width() && col < SIZE(s); ++col) { @@ -316,40 +316,39 @@ if ('onhashchange' in window) { 258 // escapes. hack: can't start a line with them. 259 if (c == '\1') { color = /*red*/1; c = ' '; } 260 if (c == '\2') { color = TB_WHITE; c = ' '; } -261 tb_change_cell(col, screen_row, c, color, TB_BLACK); +261 tb_change_cell(col, screen_row, c, color, highlight ? /*subtle grey*/240 : TB_BLACK); 262 } -263 for (; col < tb_width(); ++col) { -264 tb_change_cell(col, screen_row, ' ', TB_WHITE, TB_BLACK); -265 } -266 } -267 -268 void load_trace(const char* filename) { -269 ifstream tin(filename); -270 if (!tin) { -271 cerr << "no such file: " << filename << '\n'; -272 exit(1); -273 } -274 Trace_stream = new trace_stream; -275 while (has_data(tin)) { -276 tin >> std::noskipws; -277 skip_whitespace_but_not_newline(tin); -278 if (!isdigit(tin.peek())) { -279 string dummy; -280 getline(tin, dummy); -281 continue; -282 } -283 tin >> std::skipws; -284 int depth; -285 tin >> depth; -286 string label; -287 tin >> label; -288 if (*--label.end() == ':') label.erase(--label.end()); -289 string line; -290 getline(tin, line); -291 Trace_stream->past_lines.push_back(trace_line(depth, label, line)); -292 } -293 cerr << "lines read: " << Trace_stream->past_lines.size() << '\n'; -294 } +263 for (; col < tb_width(); ++col) +264 tb_change_cell(col, screen_row, ' ', TB_WHITE, highlight ? /*subtle grey*/240 : TB_BLACK); +265 } +266 +267 void load_trace(const char* filename) { +268 ifstream tin(filename); +269 if (!tin) { +270 cerr << "no such file: " << filename << '\n'; +271 exit(1); +272 } +273 Trace_stream = new trace_stream; +274 while (has_data(tin)) { +275 tin >> std::noskipws; +276 skip_whitespace_but_not_newline(tin); +277 if (!isdigit(tin.peek())) { +278 string dummy; +279 getline(tin, dummy); +280 continue; +281 } +282 tin >> std::skipws; +283 int depth; +284 tin >> depth; +285 string label; +286 tin >> label; +287 if (*--label.end() == ':') label.erase(--label.end()); +288 string line; +289 getline(tin, line); +290 Trace_stream->past_lines.push_back(trace_line(depth, label, line)); +291 } +292 cerr << "lines read: " << Trace_stream->past_lines.size() << '\n'; +293 } -- cgit 1.4.1-2-gfad0