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 on Powershell does not looking well #7

Open
toshiro92 opened this issue Jan 2, 2019 · 3 comments
Open

Progress Bar on Powershell does not looking well #7

toshiro92 opened this issue Jan 2, 2019 · 3 comments

Comments

@toshiro92
Copy link

toshiro92 commented Jan 2, 2019

Hi !

I am currently working with Powershell command line on Windows 10, and I've seen that the minibar characters used does not seems to be working well, as it can be seen below:

image

Is there anything to deal with ? Like install or change a font ?

Note: I've used the below template:
{i}/{total} {bar} {elapsed}s {eta}

@refi64
Copy link

refi64 commented Jan 2, 2019

You need to enable ANSI color codes. Try something like:

#include <Windows.h>

int main() {
  HANDLE console = GetStdConsole(STD_OUTPUT_HANDLE);
  DWORD mode;
  GetConsoleMode(console, &mode);
  mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  SetConsoleMode(console, mode);
  // ...
}

Note that this only works on Windows 10.

Of course, you also need to handle any errors from these functions. You can see their documentation online (try Googling their names) for more info.

You can also instead enable it globally on your system on Windows 10, pipe the output of your program to Out-Host (.\myprogram | Out-Host), or on earlier Windows version, you can install ansicon.

@toshiro92
Copy link
Author

Ok great, thank you for this tip. I've tried the global method on my system through the Registry. However, there is still the character used by the minibar which does not seems to be recognized:

image

@canassa
Copy link
Owner

canassa commented Jan 7, 2019

My understanding of Windows terminals is very minimal, how does Powershell handle UTF-8 characters?

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