Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kloenk
Copy link
Member

@Kloenk Kloenk commented Aug 31, 2020

#3666 rebased onto master

CC: @edolstra @petabyteboy

@edolstra
Copy link
Member

This should probably be a different --log-format type (e.g. fullscreen or something). That way users can still use the single-line progress bar.

BTW what happens if there are more activities than the height of the terminal?

@Kloenk
Copy link
Member Author

Kloenk commented Aug 31, 2020

This should probably be a different --log-format type (e.g. fullscreen or something). That way users can still use the single-line progress bar.

Thas is currently addressed with the experimental feature progress-bar.

BTW what happens if there are more activities than the height of the terminal?

Good Question

@Kloenk
Copy link
Member Author

Kloenk commented Aug 31, 2020

This should probably be a different --log-format type (e.g. fullscreen or something). That way users can still use the single-line progress bar.

If we make the option log-format should this be an option for nix.conf?

@Kloenk
Copy link
Member Author

Kloenk commented Aug 31, 2020

@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

@edolstra
Copy link
Member

@Kloenk There is a PR for that: #3961

@Kloenk
Copy link
Member Author

Kloenk commented Aug 31, 2020

@Kloenk There is a PR for that: #3961

Ok, then I will wait for that, as it's makes it easier

Copy link
Member

@aszlig aszlig left a 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.

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
system("cls");
#else
writeToStderr("\r\033[K\r");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
writeToStderr("\r\033[K\r");
writeToStderr("\r\033[K");

Comment on lines 391 to 392
for (auto i = 1; i < state.lastLines; i++)
writeToStderr("\033[1A\r\033[K\r");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):

Suggested change
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:

decstbm

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.

Copy link
Member Author

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


#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
system("cls");
#else
Copy link
Member

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.


void draw(State & state)
{
if (settings.isExperimentalFeatureEnabled("progress-bar")) {
Copy link
Member

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?

Copy link
Member Author

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

@bqv
Copy link
Contributor

bqv commented Dec 22, 2020

c.f. #4296

@nixos-discourse
Copy link

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>
@Kloenk
Copy link
Member Author

Kloenk commented Apr 9, 2021

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.

@stale
Copy link

stale bot commented Oct 11, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Oct 11, 2021
@fricklerhandwerk fricklerhandwerk added the UX The way in which users interact with Nix. Higher level than UI. label Sep 9, 2022
@stale stale bot removed the stale label Sep 9, 2022
@Ericson2314
Copy link
Member

The original was closed in lieu of #4296, which was never finished. Not sure what to do about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants