| ... | ... | @@ -361,7 +361,30 @@ const tree_line = "\x1B\x28\x30\x78\x1B\x28\x42 "; // │ |
| 361 | 361 | const tree_langle = "\x1B\x28\x30\x6d\x71\x1B\x28\x42 "; // └─ |
| 362 | 362 | |
| 363 | 363 | fn clearTerminal() void { |
| 364 | | write(clear); |
| 364 | var i: usize = 0; |
| 365 | const buf = global_progress.draw_buffer; |
| 366 | |
| 367 | buf[i..][0..start_sync.len].* = start_sync.*; |
| 368 | i += start_sync.len; |
| 369 | |
| 370 | const prev_nl_n = global_progress.newline_count; |
| 371 | if (prev_nl_n > 0) { |
| 372 | global_progress.newline_count = 0; |
| 373 | buf[i] = '\r'; |
| 374 | i += 1; |
| 375 | for (0..prev_nl_n) |_| { |
| 376 | buf[i..][0..up_one_line.len].* = up_one_line.*; |
| 377 | i += up_one_line.len; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | buf[i..][0..clear.len].* = clear.*; |
| 382 | i += clear.len; |
| 383 | |
| 384 | buf[i..][0..finish_sync.len].* = finish_sync.*; |
| 385 | i += finish_sync.len; |
| 386 | |
| 387 | write(buf[0..i]); |
| 365 | 388 | } |
| 366 | 389 | |
| 367 | 390 | const Children = struct { |
| ... | ... | @@ -428,8 +451,8 @@ fn computeRedraw() []u8 { |
| 428 | 451 | const children_node = &children[@intFromEnum(parent_index)]; |
| 429 | 452 | if (children_node.child.unwrap()) |existing_child_index| { |
| 430 | 453 | const existing_child = &children[@intFromEnum(existing_child_index)]; |
| 431 | | existing_child.sibling = child_index.toOptional(); |
| 432 | 454 | children[@intFromEnum(child_index)].sibling = existing_child.sibling; |
| 455 | existing_child.sibling = child_index.toOptional(); |
| 433 | 456 | } else { |
| 434 | 457 | children_node.child = child_index.toOptional(); |
| 435 | 458 | } |
| ... | ... | @@ -445,7 +468,7 @@ fn computeRedraw() []u8 { |
| 445 | 468 | i += start_sync.len; |
| 446 | 469 | |
| 447 | 470 | const prev_nl_n = global_progress.newline_count; |
| 448 | | if (global_progress.newline_count > 0) { |
| 471 | if (prev_nl_n > 0) { |
| 449 | 472 | global_progress.newline_count = 0; |
| 450 | 473 | buf[i] = '\r'; |
| 451 | 474 | i += 1; |
| ... | ... | @@ -539,11 +562,8 @@ fn computeNode( |
| 539 | 562 | i = computeNode(buf, i, serialized_node_storage, serialized_node_parents, children, child); |
| 540 | 563 | } |
| 541 | 564 | |
| 542 | | { |
| 543 | | var opt_sibling = children[@intFromEnum(node_index)].sibling; |
| 544 | | while (opt_sibling.unwrap()) |sibling| { |
| 545 | | i = computeNode(buf, i, serialized_node_storage, serialized_node_parents, children, sibling); |
| 546 | | } |
| 565 | if (children[@intFromEnum(node_index)].sibling.unwrap()) |sibling| { |
| 566 | i = computeNode(buf, i, serialized_node_storage, serialized_node_parents, children, sibling); |
| 547 | 567 | } |
| 548 | 568 | |
| 549 | 569 | return i; |