2015-11-29 20:42:04 +00:00
|
|
|
//: A debugging helper that lets you zoom in/out on a trace.
|
2017-03-09 19:35:16 +00:00
|
|
|
//: Warning: this tool has zero automated tests.
|
2017-03-06 07:24:19 +00:00
|
|
|
//:
|
|
|
|
//: To try it out, first create an example trace:
|
|
|
|
//: mu --trace nqueens.mu
|
|
|
|
//: Then to browse the trace, which was stored in a file called 'last_run':
|
|
|
|
//: mu browse-trace last_run
|
|
|
|
//:
|
|
|
|
//: You should now find yourself in a UI showing a subsequence of lines from
|
|
|
|
//: the trace, each line starting with a numeric depth, and ending with a
|
|
|
|
//: parenthetical count of trace lines hidden after it with greater depths.
|
|
|
|
//:
|
|
|
|
//: For example, this line:
|
|
|
|
//: 2 app: line1 (30)
|
|
|
|
//: indicates that it was logged with depth 2, and that 30 following lines
|
|
|
|
//: have been hidden at a depth greater than 2.
|
|
|
|
//:
|
|
|
|
//: As an experiment, hidden counts of 1000 or more are in red to highlight
|
|
|
|
//: where you might be particularly interested in expanding.
|
|
|
|
//:
|
|
|
|
//: The UI provides the following hotkeys:
|
|
|
|
//:
|
2017-03-06 17:06:58 +00:00
|
|
|
//: `q` or `ctrl-c`: Quit.
|
2017-03-06 07:24:19 +00:00
|
|
|
//:
|
2017-03-06 17:06:58 +00:00
|
|
|
//: `Enter`: 'Zoom into' this line. Expand some or all of the hidden lines
|
2017-03-06 07:24:19 +00:00
|
|
|
//: at the next higher level, updating parenthetical counts of hidden lines.
|
|
|
|
//:
|
2017-03-06 17:06:58 +00:00
|
|
|
//: `Backspace`: 'Zoom out' on a line after zooming in, collapsing expanded
|
2017-03-06 07:24:19 +00:00
|
|
|
//: lines below by some series of <Enter> commands.
|
|
|
|
//:
|
2017-03-09 05:19:11 +00:00
|
|
|
//: `j` or `down-arrow`: Move/scroll cursor down one line.
|
|
|
|
//: `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.
|
2017-03-09 07:16:48 +00:00
|
|
|
//: `h` or `left-arrow`: Scroll cursor left one character.
|
|
|
|
//: `l` or `right-arrow`: Scroll cursor right one character.
|
2017-03-09 06:51:39 +00:00
|
|
|
//: `H`: Scroll cursor left one screen-width.
|
|
|
|
//: `L`: Scroll cursor right one screen-width.
|
2017-03-06 07:24:19 +00:00
|
|
|
//:
|
2017-03-06 17:06:58 +00:00
|
|
|
//: `g` or `home`: Move cursor to start of trace.
|
|
|
|
//: `G` or `end`: Move cursor to end of trace.
|
2017-03-06 07:24:19 +00:00
|
|
|
//:
|
2017-03-09 05:48:04 +00:00
|
|
|
//: `t`: Move cursor to top line on screen.
|
|
|
|
//: `c`: Move cursor to center line on screen.
|
|
|
|
//: `b`: Move cursor to bottom line on screen.
|
2017-03-09 06:14:05 +00:00
|
|
|
//: `T`: Scroll line at cursor to top of screen.
|
2015-11-29 20:42:04 +00:00
|
|
|
|
2015-05-23 00:11:03 +00:00
|
|
|
:(before "End Primitive Recipe Declarations")
|
|
|
|
_BROWSE_TRACE,
|
|
|
|
:(before "End Primitive Recipe Numbers")
|
2015-11-06 19:06:58 +00:00
|
|
|
put(Recipe_ordinal, "$browse-trace", _BROWSE_TRACE);
|
2015-10-02 00:30:14 +00:00
|
|
|
:(before "End Primitive Recipe Checks")
|
|
|
|
case _BROWSE_TRACE: {
|
|
|
|
break;
|
|
|
|
}
|
2015-05-23 00:11:03 +00:00
|
|
|
:(before "End Primitive Recipe Implementations")
|
|
|
|
case _BROWSE_TRACE: {
|
|
|
|
start_trace_browser();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:42:04 +00:00
|
|
|
//: browse a trace loaded from a file
|
|
|
|
:(after "Commandline Parsing")
|
|
|
|
if (argc == 3 && is_equal(argv[1], "browse-trace")) {
|
|
|
|
load_trace(argv[2]);
|
|
|
|
start_trace_browser();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-23 00:11:03 +00:00
|
|
|
:(before "End Globals")
|
2016-03-14 03:26:47 +00:00
|
|
|
set<int> Visible;
|
|
|
|
int Top_of_screen = 0;
|
2017-03-09 06:51:39 +00:00
|
|
|
int Left_of_screen = 0;
|
2016-03-14 03:26:47 +00:00
|
|
|
int Last_printed_row = 0;
|
|
|
|
map<int, int> Trace_index; // screen row -> trace index
|
2015-05-23 00:11:03 +00:00
|
|
|
|
|
|
|
:(code)
|
|
|
|
void start_trace_browser() {
|
|
|
|
if (!Trace_stream) return;
|
2015-12-08 08:51:06 +00:00
|
|
|
cerr << "computing min depth to display\n";
|
2016-03-14 03:26:47 +00:00
|
|
|
int min_depth = 9999;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (int i = 0; i < SIZE(Trace_stream->past_lines); ++i) {
|
2015-05-23 01:00:10 +00:00
|
|
|
trace_line& curr_line = Trace_stream->past_lines.at(i);
|
|
|
|
if (curr_line.depth < min_depth) min_depth = curr_line.depth;
|
|
|
|
}
|
2015-12-08 08:51:06 +00:00
|
|
|
cerr << "min depth is " << min_depth << '\n';
|
2015-05-23 01:00:10 +00:00
|
|
|
cerr << "computing lines to display\n";
|
2017-03-09 18:10:19 +00:00
|
|
|
for (int i = 0; i < SIZE(Trace_stream->past_lines); ++i) {
|
2015-05-23 03:17:07 +00:00
|
|
|
if (Trace_stream->past_lines.at(i).depth == min_depth)
|
2015-05-23 01:00:10 +00:00
|
|
|
Visible.insert(i);
|
|
|
|
}
|
2015-05-23 00:11:03 +00:00
|
|
|
tb_init();
|
|
|
|
Display_row = Display_column = 0;
|
2015-05-23 01:25:27 +00:00
|
|
|
Top_of_screen = 0;
|
|
|
|
refresh_screen_rows();
|
2015-05-23 00:11:03 +00:00
|
|
|
while (true) {
|
|
|
|
render();
|
2017-03-09 19:35:16 +00:00
|
|
|
int key = read_key();
|
2017-03-06 17:06:58 +00:00
|
|
|
if (key == 'q' || key == 'Q' || key == TB_KEY_CTRL_C) break;
|
2015-06-08 06:20:04 +00:00
|
|
|
if (key == 'j' || key == TB_KEY_ARROW_DOWN) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// move cursor one line down
|
2015-05-23 01:09:34 +00:00
|
|
|
if (Display_row < Last_printed_row) ++Display_row;
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'k' || key == TB_KEY_ARROW_UP) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// move cursor one line up
|
2015-05-23 01:09:34 +00:00
|
|
|
if (Display_row > 0) --Display_row;
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 't') {
|
2015-05-23 06:45:43 +00:00
|
|
|
// move cursor to top of screen
|
2015-05-23 02:30:26 +00:00
|
|
|
Display_row = 0;
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'c') {
|
2015-05-23 06:45:43 +00:00
|
|
|
// move cursor to center of screen
|
2015-05-23 02:30:26 +00:00
|
|
|
Display_row = tb_height()/2;
|
2017-03-09 18:01:22 +00:00
|
|
|
while (!contains_key(Trace_index, Display_row))
|
|
|
|
--Display_row;
|
2015-05-23 02:30:26 +00:00
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'b') {
|
2015-05-23 06:45:43 +00:00
|
|
|
// move cursor to bottom of screen
|
2015-05-23 02:30:26 +00:00
|
|
|
Display_row = tb_height()-1;
|
2017-03-09 18:01:22 +00:00
|
|
|
while (!contains_key(Trace_index, Display_row))
|
|
|
|
--Display_row;
|
2015-05-23 02:30:26 +00:00
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'T') {
|
|
|
|
// scroll line at cursor to top of screen
|
2017-03-09 06:14:05 +00:00
|
|
|
Top_of_screen = get(Trace_index, Display_row);
|
|
|
|
Display_row = 0;
|
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'h' || key == TB_KEY_ARROW_LEFT) {
|
2017-03-09 19:38:15 +00:00
|
|
|
// pan screen one character left
|
|
|
|
if (Left_of_screen > 0) --Left_of_screen;
|
2017-03-09 07:16:48 +00:00
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'l' || key == TB_KEY_ARROW_RIGHT) {
|
2017-03-09 19:38:15 +00:00
|
|
|
// pan screen one character right
|
2017-03-09 07:16:48 +00:00
|
|
|
++Left_of_screen;
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'H') {
|
2017-03-09 07:35:56 +00:00
|
|
|
// pan screen one screen-width left
|
2017-03-09 06:51:39 +00:00
|
|
|
Left_of_screen -= (tb_width() - 5);
|
|
|
|
if (Left_of_screen < 0) Left_of_screen = 0;
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'L') {
|
2017-03-09 07:35:56 +00:00
|
|
|
// pan screen one screen-width right
|
2017-03-09 06:51:39 +00:00
|
|
|
Left_of_screen += (tb_width() - 5);
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'J' || key == TB_KEY_PGDN || key == TB_KEY_CTRL_F) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// page-down
|
2015-05-23 02:30:26 +00:00
|
|
|
if (Trace_index.find(tb_height()-1) != Trace_index.end()) {
|
2016-02-21 05:58:48 +00:00
|
|
|
Top_of_screen = get(Trace_index, tb_height()-1) + 1;
|
2015-05-23 02:30:26 +00:00
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'K' || key == TB_KEY_PGUP || key == TB_KEY_CTRL_B) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// page-up is more convoluted
|
2017-03-09 18:10:19 +00:00
|
|
|
for (int screen_row = tb_height(); screen_row > 0 && Top_of_screen > 0; --screen_row) {
|
2015-05-23 02:30:26 +00:00
|
|
|
--Top_of_screen;
|
|
|
|
if (Top_of_screen <= 0) break;
|
2015-11-06 21:22:16 +00:00
|
|
|
while (Top_of_screen > 0 && !contains_key(Visible, Top_of_screen))
|
2015-05-23 02:30:26 +00:00
|
|
|
--Top_of_screen;
|
|
|
|
}
|
2015-12-15 17:38:56 +00:00
|
|
|
if (Top_of_screen >= 0)
|
2015-05-23 02:30:26 +00:00
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'g' || key == TB_KEY_HOME) {
|
2017-03-06 17:06:58 +00:00
|
|
|
Top_of_screen = 0;
|
|
|
|
Last_printed_row = 0;
|
|
|
|
Display_row = 0;
|
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == 'G' || key == TB_KEY_END) {
|
2015-05-29 01:11:28 +00:00
|
|
|
// go to bottom of screen; largely like page-up, interestingly
|
|
|
|
Top_of_screen = SIZE(Trace_stream->past_lines)-1;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (int screen_row = tb_height(); screen_row > 0 && Top_of_screen > 0; --screen_row) {
|
2015-05-29 01:11:28 +00:00
|
|
|
--Top_of_screen;
|
|
|
|
if (Top_of_screen <= 0) break;
|
2015-11-06 21:22:16 +00:00
|
|
|
while (Top_of_screen > 0 && !contains_key(Visible, Top_of_screen))
|
2015-05-29 01:11:28 +00:00
|
|
|
--Top_of_screen;
|
|
|
|
}
|
|
|
|
refresh_screen_rows();
|
|
|
|
// move cursor to bottom
|
|
|
|
Display_row = Last_printed_row;
|
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == TB_KEY_CARRIAGE_RETURN) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// expand lines under current by one level
|
2015-11-06 21:22:16 +00:00
|
|
|
assert(contains_key(Trace_index, Display_row));
|
2016-03-14 03:26:47 +00:00
|
|
|
int start_index = get(Trace_index, Display_row);
|
|
|
|
int index = 0;
|
2015-05-23 03:17:07 +00:00
|
|
|
// simultaneously compute end_index and min_depth
|
|
|
|
int min_depth = 9999;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (index = start_index+1; index < SIZE(Trace_stream->past_lines); ++index) {
|
2015-11-06 21:22:16 +00:00
|
|
|
if (contains_key(Visible, index)) break;
|
2015-05-23 03:17:07 +00:00
|
|
|
trace_line& curr_line = Trace_stream->past_lines.at(index);
|
|
|
|
assert(curr_line.depth > Trace_stream->past_lines.at(start_index).depth);
|
|
|
|
if (curr_line.depth < min_depth) min_depth = curr_line.depth;
|
|
|
|
}
|
2016-03-14 03:26:47 +00:00
|
|
|
int end_index = index;
|
2015-05-23 03:17:07 +00:00
|
|
|
// mark as visible all intervening indices at min_depth
|
2017-03-09 18:10:19 +00:00
|
|
|
for (index = start_index; index < end_index; ++index) {
|
2015-05-23 03:17:07 +00:00
|
|
|
trace_line& curr_line = Trace_stream->past_lines.at(index);
|
|
|
|
if (curr_line.depth == min_depth) {
|
|
|
|
Visible.insert(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2017-03-09 17:57:53 +00:00
|
|
|
else if (key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2) {
|
2015-05-23 06:45:43 +00:00
|
|
|
// collapse all lines under current
|
2015-11-06 21:22:16 +00:00
|
|
|
assert(contains_key(Trace_index, Display_row));
|
2016-03-14 03:26:47 +00:00
|
|
|
int start_index = get(Trace_index, Display_row);
|
|
|
|
int index = 0;
|
2015-05-23 06:42:31 +00:00
|
|
|
// end_index is the next line at a depth same as or lower than start_index
|
|
|
|
int initial_depth = Trace_stream->past_lines.at(start_index).depth;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (index = start_index+1; index < SIZE(Trace_stream->past_lines); ++index) {
|
2015-11-06 21:22:16 +00:00
|
|
|
if (!contains_key(Visible, index)) continue;
|
2015-05-23 06:29:44 +00:00
|
|
|
trace_line& curr_line = Trace_stream->past_lines.at(index);
|
2015-05-23 06:42:31 +00:00
|
|
|
if (curr_line.depth <= initial_depth) break;
|
2015-05-23 06:29:44 +00:00
|
|
|
}
|
2016-03-14 03:26:47 +00:00
|
|
|
int end_index = index;
|
2015-05-23 06:29:44 +00:00
|
|
|
// mark as visible all intervening indices at min_depth
|
2017-03-09 18:10:19 +00:00
|
|
|
for (index = start_index+1; index < end_index; ++index) {
|
2015-05-23 06:42:31 +00:00
|
|
|
Visible.erase(index);
|
2015-05-23 06:29:44 +00:00
|
|
|
}
|
|
|
|
refresh_screen_rows();
|
|
|
|
}
|
2015-05-23 00:11:03 +00:00
|
|
|
}
|
|
|
|
tb_shutdown();
|
|
|
|
}
|
|
|
|
|
2015-05-23 01:25:27 +00:00
|
|
|
// update Trace_indices for each screen_row on the basis of Top_of_screen and Visible
|
|
|
|
void refresh_screen_rows() {
|
2016-03-14 03:26:47 +00:00
|
|
|
int screen_row = 0, index = 0;
|
2015-05-23 01:25:27 +00:00
|
|
|
Trace_index.clear();
|
2017-03-09 18:10:19 +00:00
|
|
|
for (screen_row = 0, index = Top_of_screen; screen_row < tb_height() && index < SIZE(Trace_stream->past_lines); ++screen_row, ++index) {
|
2015-05-23 00:11:03 +00:00
|
|
|
// skip lines without depth for now
|
2015-11-06 21:22:16 +00:00
|
|
|
while (!contains_key(Visible, index)) {
|
2015-05-23 00:11:03 +00:00
|
|
|
++index;
|
|
|
|
if (index >= SIZE(Trace_stream->past_lines)) goto done;
|
|
|
|
}
|
|
|
|
assert(index < SIZE(Trace_stream->past_lines));
|
2016-02-21 05:58:48 +00:00
|
|
|
put(Trace_index, screen_row, index);
|
2015-05-23 01:25:27 +00:00
|
|
|
}
|
|
|
|
done:;
|
|
|
|
}
|
|
|
|
|
|
|
|
void render() {
|
2016-03-14 03:26:47 +00:00
|
|
|
int screen_row = 0;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (screen_row = 0; screen_row < tb_height(); ++screen_row) {
|
2015-11-06 21:22:16 +00:00
|
|
|
if (!contains_key(Trace_index, screen_row)) break;
|
2016-02-21 05:58:48 +00:00
|
|
|
trace_line& curr_line = Trace_stream->past_lines.at(get(Trace_index, screen_row));
|
2015-05-23 00:11:03 +00:00
|
|
|
ostringstream out;
|
|
|
|
out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents;
|
2015-07-10 19:58:17 +00:00
|
|
|
if (screen_row < tb_height()-1) {
|
2016-03-14 03:26:47 +00:00
|
|
|
int delta = lines_hidden(screen_row);
|
2015-07-10 19:58:17 +00:00
|
|
|
// home-brew escape sequence for red
|
2016-11-22 19:39:05 +00:00
|
|
|
if (delta > 999) out << static_cast<char>(1);
|
2015-12-08 07:22:56 +00:00
|
|
|
out << " (" << delta << ")";
|
2016-11-22 19:39:05 +00:00
|
|
|
if (delta > 999) out << static_cast<char>(2);
|
2015-07-10 19:58:17 +00:00
|
|
|
}
|
2017-03-06 17:40:43 +00:00
|
|
|
render_line(screen_row, out.str(), screen_row == Display_row);
|
2015-05-23 00:11:03 +00:00
|
|
|
}
|
|
|
|
// clear rest of screen
|
2015-05-23 01:09:34 +00:00
|
|
|
Last_printed_row = screen_row-1;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (; screen_row < tb_height(); ++screen_row) {
|
2017-03-06 17:40:43 +00:00
|
|
|
render_line(screen_row, "~", /*highlight?*/false);
|
2015-05-23 00:11:03 +00:00
|
|
|
}
|
|
|
|
// move cursor back to display row at the end
|
|
|
|
tb_set_cursor(0, Display_row);
|
|
|
|
tb_present();
|
|
|
|
}
|
|
|
|
|
2016-03-14 03:26:47 +00:00
|
|
|
int lines_hidden(int screen_row) {
|
2015-11-06 21:22:16 +00:00
|
|
|
assert(contains_key(Trace_index, screen_row));
|
|
|
|
if (!contains_key(Trace_index, screen_row+1))
|
2016-02-21 05:58:48 +00:00
|
|
|
return SIZE(Trace_stream->past_lines) - get(Trace_index, screen_row);
|
2015-07-10 19:58:17 +00:00
|
|
|
else
|
2016-02-21 05:58:48 +00:00
|
|
|
return get(Trace_index, screen_row+1) - get(Trace_index, screen_row);
|
2015-07-10 19:58:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-06 17:40:43 +00:00
|
|
|
void render_line(int screen_row, const string& s, bool highlight) {
|
2016-03-14 03:26:47 +00:00
|
|
|
int col = 0;
|
2015-07-10 19:58:17 +00:00
|
|
|
int color = TB_WHITE;
|
2017-03-09 18:10:19 +00:00
|
|
|
for (col = 0; col < tb_width() && col+Left_of_screen < SIZE(s); ++col) {
|
2017-03-09 06:51:39 +00:00
|
|
|
char c = s.at(col+Left_of_screen); // todo: unicode
|
2015-05-23 00:11:03 +00:00
|
|
|
if (c == '\n') c = ';'; // replace newlines with semi-colons
|
2015-07-10 19:58:17 +00:00
|
|
|
// escapes. hack: can't start a line with them.
|
2017-03-09 18:10:19 +00:00
|
|
|
if (c == '\1') { color = /*red*/1; c = ' '; }
|
|
|
|
if (c == '\2') { color = TB_WHITE; c = ' '; }
|
2017-03-06 17:40:43 +00:00
|
|
|
tb_change_cell(col, screen_row, c, color, highlight ? /*subtle grey*/240 : TB_BLACK);
|
2015-05-23 00:11:03 +00:00
|
|
|
}
|
2017-03-09 18:10:19 +00:00
|
|
|
for (; col < tb_width(); ++col)
|
2017-03-06 17:40:43 +00:00
|
|
|
tb_change_cell(col, screen_row, ' ', TB_WHITE, highlight ? /*subtle grey*/240 : TB_BLACK);
|
2015-05-23 00:11:03 +00:00
|
|
|
}
|
2015-11-29 20:42:04 +00:00
|
|
|
|
|
|
|
void load_trace(const char* filename) {
|
|
|
|
ifstream tin(filename);
|
|
|
|
if (!tin) {
|
|
|
|
cerr << "no such file: " << filename << '\n';
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
Trace_stream = new trace_stream;
|
|
|
|
while (has_data(tin)) {
|
2015-12-08 08:51:06 +00:00
|
|
|
tin >> std::noskipws;
|
|
|
|
skip_whitespace_but_not_newline(tin);
|
|
|
|
if (!isdigit(tin.peek())) {
|
|
|
|
string dummy;
|
|
|
|
getline(tin, dummy);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
tin >> std::skipws;
|
2015-11-29 20:42:04 +00:00
|
|
|
int depth;
|
|
|
|
tin >> depth;
|
|
|
|
string label;
|
|
|
|
tin >> label;
|
|
|
|
if (*--label.end() == ':') label.erase(--label.end());
|
|
|
|
string line;
|
|
|
|
getline(tin, line);
|
|
|
|
Trace_stream->past_lines.push_back(trace_line(depth, label, line));
|
|
|
|
}
|
2015-12-08 08:51:06 +00:00
|
|
|
cerr << "lines read: " << Trace_stream->past_lines.size() << '\n';
|
2015-11-29 20:42:04 +00:00
|
|
|
}
|
2017-03-09 19:35:16 +00:00
|
|
|
|
|
|
|
int read_key() {
|
|
|
|
tb_event event;
|
|
|
|
do {
|
|
|
|
tb_poll_event(&event);
|
|
|
|
} while (event.type != TB_EVENT_KEY);
|
|
|
|
return event.key ? event.key : event.ch;
|
|
|
|
}
|