aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Progress.zig
AgeCommit message (Collapse)Author
2022-05-26std.Progress.log: adjust APIAndrew Kelley
Now it will fall back to std.debug.print if there is no tty.
2022-05-13std.Progress: activate() calls maybeRefresh()Andrew Kelley
This makes the progress bar display the ongoing operation in the case that the API user calls activate().
2022-02-14std.Progress: fix suffix printingerikarvstedt
Previously, `suffix` was copied to `output_buffer` at position `max_end`, thereby writing into reserved space after `max_end`. This only worked because `suffix` was not larger than `bytes_needed_for_esc_codes_at_end` (otherwise there'd be a potential buffer overrun) and no escape codes at end are actually written. Since 2d5b2bf1c986d037ef965bf8c9b4d8dfd5967478, escape codes are no longer written to the end of the buffer. They are now written exclusively to the front of the buffer. This allows removing `bytes_needed_for_esc_codes_at_end` and simplifying the suffix printing logic. This also fixes the bug that the ellipse suffix was not printed in Windows terminals because `end.* > max_end` was never true.
2022-02-13Fixed progress indicator for `zig test` (#10859)Sebsatian Keller
Previously the progress displayed the first item as [0/x]. This was misleading when x is the number of items. The first item should be displayed as [1/x]
2022-02-08std.Progress: make the API infallibleAndrew Kelley
by handling `error.TimerUnsupported`. In this case, only explicit calls to refresh() will cause the progress line to be printed.
2021-12-06Fix test label off-by-one error (#10277).Jeremy Fillingim
The console test# label [test#/#tests] was being generated inside refreshWithHeldLock (in lib/std/Progress.zig), using the number of completed items. This was being incremented by 1 when displayed, which is not required.
2021-11-09std.Thread.Mutex: change API to lock() and unlock()Andrew Kelley
This is a breaking change. Before, usage looked like this: ```zig const held = mutex.acquire(); defer held.release(); ``` Now it looks like this: ```zig mutex.lock(); defer mutex.unlock(); ``` The `Held` type was an idea to make mutexes slightly safer by making it more difficult to forget to release an aquired lock. However, this ultimately caused more problems than it solved, when any data structures needed to store a held mutex. Simplify everything by reducing the API down to the primitives: lock() and unlock(). Closes #8051 Closes #8246 Closes #10105
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-07-20std.Progress: revert to the older strategyAndrew Kelley
This reverts the most recent big changes to `std.Progress` changing the strategy for printing. Before the changes, it would leave the cursor after the progress line, having better behavior when a stray print happened, and supporting sub-process progress without any coordination. After the changes, the cursor was left at the beginning of the line, making any prints print garbage and often interfering with stack traces or other debug information. This commit reverts to before the changes. Revert "std: Use more common escape sequences in Progress" This reverts commit 8ebb18d9da0bfbe6a974636fd36e3391d1de253b. Revert "Handle some weird edge cases of Win32 API" This reverts commit b0724a350f07c5e2e8fab572951ffaaa92860b2c. Revert "Fix many thinkos" This reverts commit b5a50a26ebac6a08dacf79f5d1db9bdd94ba33a5. Revert "Fix Progress printing on Windows systems" This reverts commit 3010bfb08af0b47d801d492e4f2e21a988e8399a. Revert "std: Better handling of line-wrapping in Progress" This reverts commit 4fc2e92876d8aafd087a5f0bdb6ea7a54f195704.
2021-06-21fix code broken from previous commitJacob G-W
2021-06-18Fix crash when compiling with cygwin/msys on windowsMatt Chudleigh
2021-06-09std.Progress: use `*W` functions on windowsviri
Closes #534. See: https://source.winehq.org/git/wine.git/blob/refs/heads/stable:/dlls/kernelbase/console.c#l520
2021-03-12std: Use more common escape sequences in ProgressLemonBoy
This should fix the badly-rendered progress message when run in Terminal.app.
2021-03-12Handle some weird edge cases of Win32 APILemonBoy
Sometimes the viewport srWindow may report an invalid rectangle where the top row is below the bottom one.
2021-03-12Fix many thinkosLemonBoy
Somehow I forgot to save after copy-pasting some code and changing it.
2021-03-12Fix Progress printing on Windows systemsLemonBoy
The cursor must be restored after the line is printed, not before. Take into account the visible viewport to correctly compute the terminal size.
2021-03-07std: Better handling of line-wrapping in ProgressLemonBoy
In order to update the printed progress string the code tried to move the cursor N cells to the left, where N is the number of written bytes, and then clear the remaining part of the line. This strategy has two main issues: - Is only valid if the number of characters is equal to the number of written bytes, - Is only valid if the line doesn't get too long. The second point is the main motivation for this change, when the line becomes too long the terminal wraps it to a new physical line. This means that moving the cursor to the left won't be enough anymore as once the left border is reached it cannot move anymore. The wrapped line is still stored by the terminal as a single line, despite now taking more than a single one when displayed. If you try to resize the terminal you'll notice how the contents are reflowed and are essentially illegible. Querying the cursor position on non-Windows systems (plot twist, Microsoft suggests using VT escape sequences on newer systems) is extremely cumbersome so let's do something different. Before printing anything let's save the cursor position and clear the screen below the cursor, this way we ensure there's absolutely no trace of stale data on screen, and after the message is printed we simply restore it.
2021-02-21std.Progress: improve support for "dumb" terminalsjacob gw
2021-01-24std.Progress: call refreshWithHeldLock as appropriateAndrew Kelley
2021-01-24fix windows bug in Progress.zigTimon Kruiper
This bug caused the compiler to deadlock when multiple c objects were build in parallel. Thanks @kprotty for finding this bug!
2021-01-14organize std lib concurrency primitives and add RwLockAndrew Kelley
* move concurrency primitives that always operate on kernel threads to the std.Thread namespace * remove std.SpinLock. Nobody should use this in a non-freestanding environment; the other primitives are always preferable. In freestanding, it will be necessary to put custom spin logic in there, so there are no use cases for a std lib version. * move some std lib files to the top level fields convention * add std.Thread.spinLoopHint * add std.Thread.Condition * add std.Thread.Semaphore * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux * add std.Thread.RwLock Implementations provided by @kprotty
2021-01-07Reduce use of deprecated IO typesJay Petacat
Related: #4917
2020-12-31Year++Frank Denis
2020-12-23std.Progress: work around time going backwardsAndrew Kelley
2020-12-20std.Progress: fix atomic ordering semanticsAndrew Kelley
thx king protty
2020-12-20std.Progress: make the API thread-safeAndrew Kelley
We generally get away with atomic primitives, however a lock is required around the refresh function since it traverses the Node graph, and we need to be sure no references to Nodes remain after end() is called.
2020-12-20ThreadPool: delete dead codeAndrew Kelley
If this errdefer did get run it would constitute a race condition. So I deleted the dead code for clarity.