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
progress-bar: multiple output lines #3972
base: master
Are you sure you want to change the base?
Conversation
This should probably be a different BTW what happens if there are more activities than the height of the terminal? |
Thas is currently addressed with the experimental feature
Good Question |
If we make the option |
@edolstra oh we already have log format. Didn't see that. The problem I have with that, It doesn't seems like I can set it via nix.conf. so I cannot default onto it in my own config |
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.
LGTM :-) See the comments for my pesky nitpicks. Especially the DECSTBM/DECSLRM part is something that certainly could be done later and I might even give it a try to revamp the TUI in general for the NixCon Hackday if you want to join.
src/libmain/progress-bar.cc
Outdated
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) | ||
system("cls"); | ||
#else | ||
writeToStderr("\r\033[K\r"); |
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.
writeToStderr("\r\033[K\r"); | |
writeToStderr("\r\033[K"); |
src/libmain/progress-bar.cc
Outdated
for (auto i = 1; i < state.lastLines; i++) | ||
writeToStderr("\033[1A\r\033[K\r"); |
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.
for (auto i = 1; i < state.lastLines; i++) | |
writeToStderr("\033[1A\r\033[K\r"); | |
writeToStderr(fmt("\033[%dA\r\033[K", state.lastLines - 1)); |
What about using DECSTBM instead? This would also get rid of line tracking since all you need to do is set the scrolling region and push new lines.
For example like this (given that lineStart
and lineEnd
point to the absolute top and bottom margins):
for (auto i = 1; i < state.lastLines; i++) | |
writeToStderr("\033[1A\r\033[K\r"); | |
writeToStderr(fmt("\033[s\033[%d;%dr\033[u", lineStart, lineEnd)); |
The \e[s
and \e[u
CSI are to save and restore cursor positions.
Here is a small demo on how this could be even improved further, which also uses DECSLRM if the terminal supports it (currently it's just checks if TERM
starts with xterm
) to set left margins. The latter could also be useful for constraining build outputs (eg. in conjunction with DECOM) to the output of prefixed status like building somedrv: some build output
and should make a lot of the CSI handling in ProgressBar obsolete.
Running this looks something like this. Note that I deliberately filled the terminal with stuff, so that behaviour is clear when we're reaching the bottom row of the terminal:
The demo currently doesn't handle SIGWINCH
and apart for the mentioned XTerm check it doesn't query terminal features. This is btw. something which I think we should probably do in Nix in general, since for example right now we just assume that SGR is always working on all terminals.
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.
@aszlig I don't know enough about that to implement it, so feel free to take this pr over. I also would be available on https://jitsi.nixcon.net/progress-bar at the moment
src/libmain/progress-bar.cc
Outdated
|
||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) | ||
system("cls"); | ||
#else |
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.
Since Nix uses spaces for indentation, please use spaces (instead of tabs) here as well to stay consistent.
src/libmain/progress-bar.cc
Outdated
|
||
void draw(State & state) | ||
{ | ||
if (settings.isExperimentalFeatureEnabled("progress-bar")) { |
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.
What's the reason to hide this behind such a feature flag?
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.
This should be changed once #3961 lands
c.f. #4296 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/announcing-the-nix-output-monitor/11672/11 |
Co-authored-by: Milan Pässler <milan@petabyte.dev>
I updated it to a more generic version. @edolstra do you mind merging this, until your new log format is ready? I know some guys would like to use it. |
I marked this as stale due to inactivity. → More info |
The original was closed in lieu of #4296, which was never finished. Not sure what to do about this. |
#3666 rebased onto master
CC: @edolstra @petabyteboy