Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.24k stars 1.72k forks source link

[BUG] rich.progress should fallback to use ─ instead of - #1877

Closed pcroland closed 3 months ago

pcroland commented 2 years ago

So I use wsltty mainly where rich.progress uses the ━━ character for the progress bar. I checked it in cmd.exe and it showed -- for the progress bar. The fallback should be ── (also used in tables), it would give a connected line. img

btw: is there any terminal that does not support the character?

wasi-master commented 2 years ago

If triage accepts this then I can open a PR

willmcgugan commented 2 years ago

This would would need to handle options.ascii_only to default to hyphens.

wasi-master commented 2 years ago

@willmcgugan If you don't mind, I just need a way to detect if the current terminal if command prompt or not

I found the line where the bar is set and was thinking about some logic like this:

bar = "-" if ascii else ("─" if USING_COMMAND_PROMPT else "━")

Now the only problem is I don't know how to detect if command prompt is being used. Or do you suggest any alternatives?

willmcgugan commented 2 years ago

Try options.is_terminal

wasi-master commented 2 years ago

Okay thanks

wasi-master commented 2 years ago

So the change I mentioned above works, but it has one unexpected side effect. basically options.is_terminal is for checking if the output is a terminal, not specifically command prompt, and because of that the normal behavior also changes. now one thing I notice is that it defaults to ASCII Mode on Command prompt.

So I went on to test if ASCII mode is necessary. and it looks like it isn't since the normal character also works for me, so I checked a bunch of encodings and most of them seem to work fine. now I am a bit stuck on what to do next

image

On Powershell with Windows Terminal

Before: image After: image

If you want the default character to change to the thinner one then you can add

pcroland commented 2 years ago

This is still an issue as of now. The fallback character can simply be a . It's even available in CP437 IBM so every terminal supports it in theory.

github-actions[bot] commented 3 months ago

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual