Since my last post on Rich there have been a number of improvements. Here are the major highlights:

Indeterminate progress bars

Progress bars now have an indeterminate state which displays a pulsing animation. This a fairly common thing from graphical UIs, here's what it looks like in the terminal:

To see it in action install Rich and run the following:

python -m rich.progress

Or just watch this video.

You can use this new state to show when something is working, but before you know how many 'steps' are involved. For instance, when making a request over the internet, you won't know how many bytes you have to download until you get a response. Rather than show a progress bar at 0% you can show this pulse effect while waiting on the server.

16.7 million colours in Windows Terminal

Rich now detects the new Windows Terminal and enables truecolor support. Previously colours were downgraded to 8-bit, but now you can enjoy the full 16.7 million colours in Windows.

More text styles

I've added support for the following terminal styles: double underline, framed, encircled, and overlined. Of the new 4 styles, I've only see double underline and overline supported, and only on Ubuntu terminal. The lack of support is why they didn't go in version 1.0, but if your terminal supports these new styles, you're in luck.

I don't even know what frame and encircled is supposed to look like. Let me know if you are using a terminal that supports them (send me a screenshot).

The overline and double underline terminal styles on Ubuntu.

Console markup abbreviations

Rich supported abbreviate styles in markup, for instance "[b]Bold[/b]", but only a single abbreviated style could be applied in a tag. If you wanted bold and italic you would have to write "[b][i]Bold and italic[/i][/b]". Now you can write "[b i]Bold and italic[/b i]".

Fixed

A number of minor fixes and one one serious. There was a possibility of a deadlock in progress bars. If you are using progress bars, please upgrade.

Optimizations

I've made a number of optimizations in rendering styles which have made Rich faster across the board. You're unlikely to notice anything unless you are generating many pages of rich text (perhaps with a large markdown file).

Coverage

Coverage has reached 97% which is not bad at all. To be honest though it is the use of type annotations throughout which gives me the most confidence.

Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
William

Rich now detects the new Windows Terminal and enables truecolor support.

That is actually seriously impressive. Can you point me to where the code for that part is? I'd like to understand how you do that, as I've been trying to figure out how to do that for some time...

gravatar
Will McGugan

Windows Terminal sets an env var called WT_SESSION. I read this on a post from MS, I'm not sure how official this is but it seems to be the case. Here's the code in Rich.

gravatar
William

I remember reading about WT_SESSION. Maybe I should stop over thinking things and just use it.

However, one issue I've run into is that environmental variables are inherited by processes spawned by Windows Terminal. For example, I like to start Visual Studio Code from the current directory in Windows Terminal. And VS Code doesn't support as many colour codes to Windows Terminal.

However, just tonight, I discovered a solution to that: have VS Code drop that environmental variable. Here's the snippit to add to your VS Code settings:

// VS Code settings.json
{
    // other settings
    "terminal.integrated.env.windows": {
        "WT_SESSION": null
    }
}

Anyway, very cool library; thank you for making and sharing this, and for making sure it has Windows support. I'm excited to start using it for my own projects!

gravatar
Marius Gedminas

Have you tried resizing the gnome-terminal window while python -m rich.progress is running?

(I wonder if that's even fixable in practice, without clearing the entire screen.)

gravatar
Will McGugan

Resizing smaller tends to make it glitch. But I think you're right, there may not be a decent solution for that.