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

Indicator with set_progress does not display properly (cursor issue?) #86

Open
prudhomm opened this issue Feb 8, 2021 · 5 comments
Open

Comments

@prudhomm
Copy link

prudhomm commented Feb 8, 2021

Screenshot 2021-02-08 at 08 46 34

  using namespace indicators;

    // Hide cursor
    show_console_cursor(false);

    ProgressBar bar{
      option::BarWidth{50},
      option::Start{"["},
      option::Fill{"■"},
      option::Lead{"■"},
      option::Remainder{"-"},
      option::End{" ]"},
      option::PostfixText{"Starting simulator"},
      option::ForegroundColor{Color::cyan},
      option::FontStyles{std::vector<FontStyle>{FontStyle::bold}}
    };

here is the code for the first 10%

if ( !VLOG_IS_ON( 1 ) && Environment::isMasterRank() )
    {
        bar.set_option( option::PostfixText{ "Configuring "s}  );
        bar.set_progress( 10 );
    }

the same for the rest

@csparker247
Copy link
Contributor

This is typically caused by the size of the terminal window being smaller than the total width of the bar (including postfix text). If you set bar width smaller and/or make your window larger, it should display correctly when you rerun the program.

@prudhomm
Copy link
Author

I will check thanks
Wouldn't it be possible to get automatically the terminal size and adjust automatically?
Also this is not intuitive because my terminal is quite larger than the indicator part

@p-ranav
Copy link
Owner

p-ranav commented Feb 20, 2021

Wouldn't it be possible to get automatically the terminal size and adjust automatically?

Depends. Calculating the full width of the progress bar = (Prefix text) + (Width of bar) + (Width of time remaining displayed) (Width of postfix text displayed). Some of these are known at compile time and others are calculated as we go (e.g., parameterized postfix text) and one of these displayed elements could bring the total bar width over the available terminal size.

In your case, however, I don't understand why the carriage return is correctly working after the first Configuring. The terminal cursor should shoot back to the first cell in that row in the terminal so that the bar can be printed again.

image

This suggests to me that (if the terminal has enough width), that \r isn't correctly working for some reason.

What terminal are you using?

@prudhomm
Copy link
Author

I use the macosx terminal (Catalina), as well as vscode embedded terminal (vscode on a mac)

@p-ranav
Copy link
Owner

p-ranav commented Mar 13, 2021

@prudhomm can you check if this commit has fixed the problem? 4790bfd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants