-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
build_runner: add option to clear console when watching #24122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -484,6 +487,10 @@ pub fn main() !void { | |||
var debounce_timeout: Watch.Timeout = .none; | |||
while (true) switch (try w.wait(gpa, debounce_timeout)) { | |||
.timeout => { | |||
if (watch_clear) { | |||
try std.io.getStdOut().writeAll("\x1B[2J\x1B[H"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, "\x1B[2J\x1B[H"
should be moved into std.io.tty
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that std.Progress
already has code like this so that could be refactored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked at std.io.tty
and it seems to handle only colors not the entire suite of ANSI escape codes. std.Progress
on the other hand uses some ANSI codes but it's not the main use of the API and I would rather not import from it.
To me it feels like std.io.tty
should hold the ANSI escapes for the screen clearing as well. Does this mean that NO_COLOR
/--color off
should also disable screen clearing? My assumption is that the main reason you would disable colors is to get rid of the ANSI escapes from the output. Maybe someone from the core team can shed some light.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that
NO_COLOR
/--color off
should also disable screen clearing?
https://no-color.org seems to me to strongly indicate that it's about a preference of colored vs non-colored output, not terminal sequences in general. So I would say no.
clearing is pretty aggressive, have you considered simply adding a newline instead? |
FWIW, I absolutely want the "clear" option, and have done for a while. With the reference trace and command also in the output, just blank lines don't separate things enough. I would really like my Ideally we could replace just the previous |
I agree with @mlugg on this one. I usually just want to expend as little as possible of my attention trying to locate the error in the log and just go back to fixing the code. I was wondering if it would be better to also allow people to specify their own separator either as a flag or as an option in |
Big thanks to @romeobalta for picking this up!
Why not both? We could have:
IMO, |
I'm going to step in and say there must be no additional option. Instead, the defaults must be better. Newline should be be added unconditionally. I propose that, when combined with |
I would be okay with clearing being a part of |
Just wanna tune in and say i'm happy to see it's already being worked on! It bugs me a lot when working on my OS to find out which of the 80some compile errors are part of the "current problem set", so having an auto-clear would be awesome. my preference is |
I'm not against having something like this as an option, but I don't personally consider it sufficient. I want to be able to run |
I think this is a pretty strong argument. I can't actually think of any software that has ever cleared my terminal scrollback without my very explicit consent. It would be unfortunate if |
Yeah I think it's okay to have the clear option, I just think the big delimiter is a good default as it's easy enough to see the latest output (especially compared to status quo), it keeps scrollback, and it works the same on all terminals. |
As described in #23472.
Running
zig build
with-fincremental
and--watch
it's a bit hard to identify what's the up-to-date error state.This PR allows you to opt-in having the screen cleared on debounce timeout.