mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
std.Progress: avoid scrolling the PS1 off the terminal
This commit is contained in:
parent
52ed54d1e7
commit
11f894702b
1 changed files with 7 additions and 2 deletions
|
|
@ -908,13 +908,13 @@ fn computeNode(
|
||||||
global_progress.newline_count += 1;
|
global_progress.newline_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global_progress.newline_count < global_progress.rows) {
|
if (global_progress.withinRowLimit()) {
|
||||||
if (children[@intFromEnum(node_index)].child.unwrap()) |child| {
|
if (children[@intFromEnum(node_index)].child.unwrap()) |child| {
|
||||||
i = computeNode(buf, i, serialized, children, child);
|
i = computeNode(buf, i, serialized, children, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global_progress.newline_count < global_progress.rows) {
|
if (global_progress.withinRowLimit()) {
|
||||||
if (children[@intFromEnum(node_index)].sibling.unwrap()) |sibling| {
|
if (children[@intFromEnum(node_index)].sibling.unwrap()) |sibling| {
|
||||||
i = computeNode(buf, i, serialized, children, sibling);
|
i = computeNode(buf, i, serialized, children, sibling);
|
||||||
}
|
}
|
||||||
|
|
@ -923,6 +923,11 @@ fn computeNode(
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn withinRowLimit(p: *Progress) bool {
|
||||||
|
// The +1 here is so that the PS1 is not scrolled off the top of the terminal.
|
||||||
|
return p.newline_count + 1 < p.rows;
|
||||||
|
}
|
||||||
|
|
||||||
fn write(buf: []const u8) void {
|
fn write(buf: []const u8) void {
|
||||||
const tty = global_progress.terminal orelse return;
|
const tty = global_progress.terminal orelse return;
|
||||||
tty.writeAll(buf) catch {
|
tty.writeAll(buf) catch {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue