Monday, May 25, 2020

Will McGugan: Rich gets Richer

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).

© 2020 Will McGugan

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.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...