| ... | @@ -60,7 +60,7 @@ pub const Options = struct { | ... | @@ -60,7 +60,7 @@ pub const Options = struct { |
| 60 | /// Must be at least 200 bytes. | 60 | /// Must be at least 200 bytes. |
| 61 | draw_buffer: []u8, | 61 | draw_buffer: []u8, |
| 62 | /// How many nanoseconds between writing updates to the terminal. | 62 | /// How many nanoseconds between writing updates to the terminal. |
| 63 | refresh_rate_ns: u64 = 50 * std.time.ns_per_ms, | 63 | refresh_rate_ns: u64 = 60 * std.time.ns_per_ms, |
| 64 | /// How many nanoseconds to keep the output hidden | 64 | /// How many nanoseconds to keep the output hidden |
| 65 | initial_delay_ns: u64 = 500 * std.time.ns_per_ms, | 65 | initial_delay_ns: u64 = 500 * std.time.ns_per_ms, |
| 66 | /// If provided, causes the progress item to have a denominator. | 66 | /// If provided, causes the progress item to have a denominator. |
| ... | @@ -435,8 +435,8 @@ fn computeRedraw() []u8 { | ... | @@ -435,8 +435,8 @@ fn computeRedraw() []u8 { |
| 435 | } | 435 | } |
| 436 | } | 436 | } |
| 437 | | 437 | |
| 438 | // The strategy is: keep the cursor at the beginning, and then with every redraw: | 438 | // The strategy is: keep the cursor at the end, and then with every redraw: |
| 439 | // erase to end of screen, write, move cursor to beginning of line, move cursor up N lines | 439 | // move cursor to beginning of line, move cursor up N lines, erase to end of screen, write |
| 440 | | 440 | |
| 441 | var i: usize = 0; | 441 | var i: usize = 0; |
| 442 | const buf = global_progress.draw_buffer; | 442 | const buf = global_progress.draw_buffer; |
| ... | @@ -444,22 +444,26 @@ fn computeRedraw() []u8 { | ... | @@ -444,22 +444,26 @@ fn computeRedraw() []u8 { |
| 444 | buf[i..][0..start_sync.len].* = start_sync.*; | 444 | buf[i..][0..start_sync.len].* = start_sync.*; |
| 445 | i += start_sync.len; | 445 | i += start_sync.len; |
| 446 | | 446 | |
| 447 | buf[0..clear.len].* = clear.*; | 447 | const prev_nl_n = global_progress.newline_count; |
| 448 | i = clear.len; | 448 | if (global_progress.newline_count > 0) { |
| 449 | | | |
| 450 | const root_node_index: Node.Index = @enumFromInt(0); | | |
| 451 | i = computeNode(buf, i, serialized_node_storage, serialized_node_parents, children, root_node_index); | | |
| 452 | | | |
| 453 | if (buf[i - 1] == '\n') { | | |
| 454 | buf[i - 1] = '\r'; | | |
| 455 | const prev_nl_n = global_progress.newline_count - 1; | | |
| 456 | global_progress.newline_count = 0; | 449 | global_progress.newline_count = 0; |
| | 450 | buf[i] = '\r'; |
| | 451 | i += 1; |
| 457 | for (0..prev_nl_n) |_| { | 452 | for (0..prev_nl_n) |_| { |
| 458 | buf[i..][0..up_one_line.len].* = up_one_line.*; | 453 | buf[i..][0..up_one_line.len].* = up_one_line.*; |
| 459 | i += up_one_line.len; | 454 | i += up_one_line.len; |
| 460 | } | 455 | } |
| 461 | } | 456 | } |
| 462 | | 457 | |
| | 458 | buf[i..][0..clear.len].* = clear.*; |
| | 459 | i += clear.len; |
| | 460 | |
| | 461 | const root_node_index: Node.Index = @enumFromInt(0); |
| | 462 | i = computeNode(buf, i, serialized_node_storage, serialized_node_parents, children, root_node_index); |
| | 463 | |
| | 464 | // Truncate trailing newline. |
| | 465 | //if (buf[i - 1] == '\n') i -= 1; |
| | 466 | |
| 463 | buf[i..][0..finish_sync.len].* = finish_sync.*; | 467 | buf[i..][0..finish_sync.len].* = finish_sync.*; |
| 464 | i += finish_sync.len; | 468 | i += finish_sync.len; |
| 465 | | 469 | |