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

Carriage return does not work #90

Open
tgalaj opened this issue Mar 11, 2021 · 4 comments
Open

Carriage return does not work #90

tgalaj opened this issue Mar 11, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@tgalaj
Copy link

tgalaj commented Mar 11, 2021

Hi,

Recently I was using the indicators library to print some progress bars inside my pet projects. Everything was working fine until I replaced the machines. On the new machine progress bars are not printed correctly:

bad

Progress bar is configured in the code as follows:

	indicators::show_console_cursor(false);
	indicators::ProgressBar bar
	{
		indicators::option::BarWidth{30},
		indicators::option::Start{"["},
		indicators::option::Fill{"="},
		indicators::option::Lead{">"},
		indicators::option::Remainder{" "},
		indicators::option::End{"]"},
		indicators::option::PostfixText{"Rendering..."},
		indicators::option::ForegroundColor{indicators::Color::green},
		indicators::option::ShowElapsedTime{true},
		indicators::option::ShowPercentage{true},
		indicators::option::FontStyles{std::vector<indicators::FontStyle>{indicators::FontStyle::bold}},
		indicators::option::MaxProgress{max_pixels}
	};

        (...)
        bar.set_progress(count);
        (...)
	indicators::show_console_cursor(true);

I thought that it has something to do with the carriage return. After that, I changed indicators::option::Start{"["} to indicators::option::Start{"\r["} and it worked like a charm:

good

However, I don't like such a workaround. Is it something bad with the indicators library or am I doing something wrong? (I'm using the newest version of the single header indicators lib).

@p-ranav
Copy link
Owner

p-ranav commented Mar 13, 2021

I suppose I could add the carriage return to the progress bar start string always. That way, you don't need to.

I can do this and push an update.

@p-ranav p-ranav self-assigned this Mar 13, 2021
@p-ranav p-ranav added the bug Something isn't working label Mar 13, 2021
@p-ranav
Copy link
Owner

p-ranav commented Mar 13, 2021

Please this if this commit fixes it 4790bfd

@tgalaj tgalaj closed this as completed Mar 15, 2021
@tgalaj
Copy link
Author

tgalaj commented Mar 16, 2021

I'll reopen this issue as the problem still emerges. I found out that you also need to increase the size by 1 (size of "\r" string that you output to the os stream) of the start_length variable to be working properly (best to handle it in the constructor imho).

@tgalaj tgalaj reopened this Mar 16, 2021
@lowern1ght
Copy link

lowern1ght commented Jun 15, 2023

there is still this problem + I tried to use carriage return, but it did not give results
option::Start{"\r["}, - not working

image

fix please <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants