diff options
Diffstat (limited to 'html/080trace_browser.cc.html')
-rw-r--r-- | html/080trace_browser.cc.html | 171 |
1 files changed, 85 insertions, 86 deletions
diff --git a/html/080trace_browser.cc.html b/html/080trace_browser.cc.html index 07635388..f2139f3f 100644 --- a/html/080trace_browser.cc.html +++ b/html/080trace_browser.cc.html @@ -15,11 +15,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } .cSpecial { color: #008000; } .Constant { color: #00a0a0; } -.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } -.CommentedCode { color: #6c6c6c; } .Identifier { color: #804000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -36,31 +35,31 @@ _BROWSE_TRACE<span class="Delimiter">,</span> <span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> Recipe_ordinal[<span class="Constant">"$browse-trace"</span>] = _BROWSE_TRACE<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> -<span class="Normal">case</span> _BROWSE_TRACE: <span class="Delimiter">{</span> +case _BROWSE_TRACE: <span class="Delimiter">{</span> start_trace_browser<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Globals")</span> -set<<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Visible<span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> Last_printed_row = <span class="Constant">0</span><span class="Delimiter">;</span> -map<<span class="Normal">int</span><span class="Delimiter">,</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>> Trace_index<span class="Delimiter">;</span> <span class="Comment">// screen row -> trace index</span> +set<long long int> Visible<span class="Delimiter">;</span> +long long int Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> +long long int Last_printed_row = <span class="Constant">0</span><span class="Delimiter">;</span> +map<int<span class="Delimiter">,</span> long long int> Trace_index<span class="Delimiter">;</span> <span class="Comment">// screen row -> trace index</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> +void start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> cerr << <span class="Constant">"computing depth to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> <span class="Delimiter">}</span> cerr << <span class="Constant">"depth is "</span> << min_depth << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> cerr << <span class="Constant">"computing lines to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>depth == min_depth<span class="Delimiter">)</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>depth == min_depth<span class="Delimiter">)</span> Visible<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Delimiter">}</span> tb_init<span class="Delimiter">();</span> @@ -68,62 +67,62 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla tb_event event<span class="Delimiter">;</span> Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> refresh_screen_rows<span class="Delimiter">();</span> - <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + while <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> render<span class="Delimiter">();</span> - <span class="Normal">do</span> <span class="Delimiter">{</span> + do <span class="Delimiter">{</span> tb_poll_event<span class="Delimiter">(</span>&event<span class="Delimiter">);</span> - <span class="Delimiter">}</span> <span class="Normal">while</span> <span class="Delimiter">(</span>event<span class="Delimiter">.</span>type != TB_EVENT_KEY<span class="Delimiter">);</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'q'</span> || key == <span class="Constant">'Q'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'j'</span> || key == TB_KEY_ARROW_DOWN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Delimiter">}</span> while <span class="Delimiter">(</span>event<span class="Delimiter">.</span>type != TB_EVENT_KEY<span class="Delimiter">);</span> + long long int key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'q'</span> || key == <span class="Constant">'Q'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'j'</span> || key == TB_KEY_ARROW_DOWN<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor one line down</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row < Last_printed_row<span class="Delimiter">)</span> ++Display_row<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>Display_row < Last_printed_row<span class="Delimiter">)</span> ++Display_row<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'k'</span> || key == TB_KEY_ARROW_UP<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'k'</span> || key == TB_KEY_ARROW_UP<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor one line up</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row > <span class="Constant">0</span><span class="Delimiter">)</span> --Display_row<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>Display_row > <span class="Constant">0</span><span class="Delimiter">)</span> --Display_row<span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'H'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'H'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor to top of screen</span> Display_row = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'M'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'M'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor to center of screen</span> Display_row = tb_height<span class="Delimiter">()</span>/<span class="Constant">2</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'L'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'L'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// move cursor to bottom of screen</span> Display_row = tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'J'</span> || key == TB_KEY_PGDN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'J'</span> || key == TB_KEY_PGDN<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// page-down</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> Top_of_screen = Trace_index[tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span>]+<span class="Constant">1</span><span class="Delimiter">;</span> refresh_screen_rows<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'K'</span> || key == TB_KEY_PGUP<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'K'</span> || key == TB_KEY_PGUP<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// page-up is more convoluted</span> <span class="CommentedCode">//? tb_shutdown(); //? 1</span> <span class="CommentedCode">//? cerr << "page-up: Top_of_screen is currently " << Top_of_screen << '\n'; //? 1</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>int screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> --Top_of_screen<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + if <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + while <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> --Top_of_screen<span class="Delimiter">;</span> <span class="CommentedCode">//? cerr << "now " << Top_of_screen << '\n'; //? 1</span> <span class="Delimiter">}</span> <span class="CommentedCode">//? exit(0); //? 1</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span><span class="Delimiter">)</span> + if <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span><span class="Delimiter">)</span> refresh_screen_rows<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == <span class="Constant">'G'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'G'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// go to bottom of screen; largely like page-up, interestingly</span> Top_of_screen = SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>int screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> --Top_of_screen<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + if <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + while <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> --Top_of_screen<span class="Delimiter">;</span> <span class="Delimiter">}</span> refresh_screen_rows<span class="Delimiter">();</span> @@ -131,29 +130,29 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla Display_row = Last_printed_row<span class="Delimiter">;</span> refresh_screen_rows<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// expand lines under current by one level</span> <span class="CommentedCode">//? tb_shutdown();</span> assert<span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Display_row<span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">());</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> start_index = Trace_index[Display_row]<span class="Delimiter">;</span> + long long int start_index = Trace_index[Display_row]<span class="Delimiter">;</span> <span class="CommentedCode">//? cerr << "start_index is " << start_index << '\n';</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + long long int index = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// simultaneously compute end_index and min_depth</span> - <span class="Normal">int</span> min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> != Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + int min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> != Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth > Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="CommentedCode">//? cerr << "min_depth is " << min_depth << '\n';</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> + long long int end_index = index<span class="Delimiter">;</span> <span class="CommentedCode">//? cerr << "end_index is " << end_index << '\n';</span> <span class="Comment">// mark as visible all intervening indices at min_depth</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index<span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>index = start_index<span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == min_depth<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == min_depth<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << "adding " << index << '\n';</span> Visible<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -161,22 +160,22 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="CommentedCode">//? exit(0);</span> refresh_screen_rows<span class="Delimiter">();</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// collapse all lines under current</span> assert<span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Display_row<span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">());</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> start_index = Trace_index[Display_row]<span class="Delimiter">;</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + long long int start_index = Trace_index[Display_row]<span class="Delimiter">;</span> + long long int index = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">// end_index is the next line at a depth same as or lower than start_index</span> - <span class="Normal">int</span> initial_depth = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + int initial_depth = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth <= initial_depth<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth <= initial_depth<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> end_index = index<span class="Delimiter">;</span> + long long int end_index = index<span class="Delimiter">;</span> <span class="Comment">// mark as visible all intervening indices at min_depth</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> Visible<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>index<span class="Delimiter">);</span> <span class="Delimiter">}</span> refresh_screen_rows<span class="Delimiter">();</span> @@ -186,40 +185,40 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Delimiter">}</span> <span class="Comment">// update Trace_indices for each screen_row on the basis of Top_of_screen and Visible</span> -<span class="Normal">void</span> refresh_screen_rows<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> +void refresh_screen_rows<span class="Delimiter">()</span> <span class="Delimiter">{</span> + long long int screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> Trace_index<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = Top_of_screen<span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">()</span> && index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++screen_row<span class="Delimiter">,</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = Top_of_screen<span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">()</span> && index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++screen_row<span class="Delimiter">,</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// skip lines without depth for now</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + while <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> ++index<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>index >= SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">))</span> <span class="Identifier">goto</span> done<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>index >= SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">))</span> <span class="Identifier">goto</span> done<span class="Delimiter">;</span> <span class="Delimiter">}</span> assert<span class="Delimiter">(</span>index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">));</span> Trace_index[screen_row] = index<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">done</span>:<span class="Delimiter">;</span> +done:<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> render<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row<span class="Delimiter">)</span> == Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> +void render<span class="Delimiter">()</span> <span class="Delimiter">{</span> + long long int screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row<span class="Delimiter">)</span> == Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Trace_index[screen_row]<span class="Delimiter">);</span> ostringstream out<span class="Delimiter">;</span> out << std::setw<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">)</span> << curr_line<span class="Delimiter">.</span>depth << <span class="Constant">' '</span> << curr_line<span class="Delimiter">.</span>label << <span class="Constant">": "</span> << curr_line<span class="Delimiter">.</span>contents<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>screen_row < tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> delta = lines_hidden<span class="Delimiter">(</span>screen_row<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>screen_row < tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int delta = lines_hidden<span class="Delimiter">(</span>screen_row<span class="Delimiter">);</span> <span class="Comment">// home-brew escape sequence for red</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>delta > <span class="Constant">999</span><span class="Delimiter">)</span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>delta > <span class="Constant">999</span><span class="Delimiter">)</span> out << <span class="Constant">"{"</span><span class="Delimiter">;</span> out << <span class="Constant">" ("</span> << lines_hidden<span class="Delimiter">(</span>screen_row<span class="Delimiter">)</span> << <span class="Constant">")"</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>delta > <span class="Constant">999</span><span class="Delimiter">)</span> out << <span class="Constant">"}"</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>delta > <span class="Constant">999</span><span class="Delimiter">)</span> out << <span class="Constant">"}"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> render_line<span class="Delimiter">(</span>screen_row<span class="Delimiter">,</span> out<span class="Delimiter">.</span>str<span class="Delimiter">());</span> <span class="Delimiter">}</span> <span class="Comment">// clear rest of screen</span> Last_printed_row = screen_row-<span class="Constant">1</span><span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> render_line<span class="Delimiter">(</span>screen_row<span class="Delimiter">,</span> <span class="Constant">"~"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// move cursor back to display row at the end</span> @@ -227,26 +226,26 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla tb_present<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> lines_hidden<span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> +long long int lines_hidden<span class="Delimiter">(</span>long long int screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row<span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">());</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row+<span class="Constant">1</span><span class="Delimiter">)</span> == Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + if <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row+<span class="Constant">1</span><span class="Delimiter">)</span> == Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">return</span> SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">)</span>-Trace_index[screen_row]<span class="Delimiter">;</span> - <span class="Normal">else</span> + else <span class="Identifier">return</span> Trace_index[screen_row+<span class="Constant">1</span>] - Trace_index[screen_row]<span class="Delimiter">;</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> render_line<span class="Delimiter">(</span><span class="Normal">int</span> screen_row<span class="Delimiter">,</span> <span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">int</span> color = TB_WHITE<span class="Delimiter">;</span> - <span class="Normal">for</span> <span class="Delimiter">(</span>col = <span class="Constant">0</span><span class="Delimiter">;</span> col < tb_width<span class="Delimiter">()</span> && col < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">char</span> c = s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>col<span class="Delimiter">);</span> <span class="Comment">// todo: unicode</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> c = <span class="Constant">';'</span><span class="Delimiter">;</span> <span class="Comment">// replace newlines with semi-colons</span> +void render_line<span class="Delimiter">(</span>int screen_row<span class="Delimiter">,</span> const string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int col = <span class="Constant">0</span><span class="Delimiter">;</span> + int color = TB_WHITE<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>col = <span class="Constant">0</span><span class="Delimiter">;</span> col < tb_width<span class="Delimiter">()</span> && col < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> + char c = s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>col<span class="Delimiter">);</span> <span class="Comment">// todo: unicode</span> + if <span class="Delimiter">(</span>c == <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> c = <span class="Constant">';'</span><span class="Delimiter">;</span> <span class="Comment">// replace newlines with semi-colons</span> <span class="Comment">// escapes. hack: can't start a line with them.</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'{'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> color = <span class="Comment">/*</span><span class="Comment">red</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> c = <span class="Constant">' '</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="Constant">'}'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> color = TB_WHITE<span class="Delimiter">;</span> c = <span class="Constant">' '</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>c == <span class="Constant">'{'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> color = <span class="Comment">/*</span><span class="Comment">red</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> c = <span class="Constant">' '</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>c == <span class="Constant">'}'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> color = TB_WHITE<span class="Delimiter">;</span> c = <span class="Constant">' '</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> tb_change_cell<span class="Delimiter">(</span>col<span class="Delimiter">,</span> screen_row<span class="Delimiter">,</span> c<span class="Delimiter">,</span> color<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(;</span> col < tb_width<span class="Delimiter">();</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(;</span> col < tb_width<span class="Delimiter">();</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> tb_change_cell<span class="Delimiter">(</span>col<span class="Delimiter">,</span> screen_row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> |