rich icon indicating copy to clipboard operation
rich copied to clipboard

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

Open pcroland opened this issue 2 years ago • 7 comments

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?

pcroland avatar Jan 28 '22 10:01 pcroland

If triage accepts this then I can open a PR

wasi-master avatar Feb 09 '22 17:02 wasi-master

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

willmcgugan avatar Feb 11 '22 11:02 willmcgugan

@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?

wasi-master avatar Feb 16 '22 15:02 wasi-master

Try options.is_terminal

willmcgugan avatar Feb 16 '22 15:02 willmcgugan

Okay thanks

wasi-master avatar Feb 17 '22 02:02 wasi-master

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

wasi-master avatar Feb 18 '22 11:02 wasi-master

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.

pcroland avatar Sep 08 '22 10:09 pcroland