mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 15:43:06 +00:00
* prep: output_buffer -> output_buffer_slice * fix: truncate lines accurately Currently, the code assumes a terminal width of 100. If we look at what's printed for the last test: ``` Test [1/1] test "basic functionality"... [101/100] this is a really long name designed to activate the truncation code. let's fi... ``` No, it does not really work because the relevant part here is `"[101/100] this is a really long name designed to activate the truncation code. let's fi... "`, which is 90 characters, but we expect 100 because that's the width that is assumed. The reason is that it also measures **unprintable characters** (escape sequences) at least non-Windows systems. With this commit the output is now: ``` Test [1/1] test "basic functionality"... [101/100] this is a really long name designed to activate the truncation code. let's find out if... ``` Of which `"[101/100] this is a really long name designed to activate the truncation code. let's find out if... "` is the actual output of *our* `std.Progress` (remember that `zig test` has an `std.Progress` and our test itself does). The length of that string is 100. Now the length is consistent with Windows where we don't use escape sequences. This issue was only present on non-Windows systems. * feat: decide optimal maximum width This is done by 1. getting the current terminal width and 2. subtracting that by the current cursor column. This accounts for previous output from someone else. * test: add more tests They make it easier to see how the progress line is printed in different cases. * style: fix typo and improve docs It also expands an acronym used as a variable name. It confused me. * cleanup: import std.time * test: add test * fix: limit termios usage to Linux only for now * fix: missing cast on Windows * test: try to debug failure * fix: fix off-by-one and disable tests * docs: make comment clearer * fix: more durability * fix(getTerminalWidth): change order