p-ranav / indicators

Activity Indicators for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to let indicator don't cover the print message?

nickhuangxinyu opened this issue · comments

indicators is a great tool.

it show the process dynamically, but when I need to print message in my code.

the indicators bar will cover my print message will bar. and my message is disappeared.

Is there any method can let me see the message, and indicators bar process meantime?

You could set the postfix text of the bar. That way, your message will be visible to the right of the bar:

bar.set_option(option::PostfixText{"My message here"});

e.g., you can see the message "Extracting Archive" below:

image

@p-ranav
this is good for one line message, when I need to show several lines of message, is there any method to show?

Most modern terminals support ANSI escape codes so you can print "\n\033[A\033[1L" before printing each line to insert it above the progress bar. Maybe this should be mentioned in the readme since it's a common question.

If you can't or don't want to change all your std::cout::operator<< calls, there's a relatively simple way to force std::cout to add "\n\033[A\033[1L" before each line using boost iostreams: https://github.com//issues/107