Skip to content
This repository was archived by the owner on Sep 10, 2026. It is now read-only.

v4.1.0: The stylish update

Choose a tag to compare

@bczsalba bczsalba released this 16 Mar 18:22
· 571 commits to master since this release

This update is focused on the brand-spanking new StyleManager API. Previously, styles were "managed" as a single dictionary, which while simple and robust, was very limited, ugly and in general not the best. This was a leftover design decision from even before TIM was an idea, just to put its age into perspective.

The new API allows users to use JS-like dotted syntax, such as Container.styles.border = "60 bold" to achieve what was previously Container.set_style("border", MarkupFormatter("[60 bold]{item}"). As you could notice, the given values are also much simpler now: Anything that is not already a StyleCall will be converted into one, and if the passed value was a string with no valid markup it will be parsed into [{{passed_value}}]{item}. You can also set multiple styles at one time, using "__" (double underscore) character to separate them.

Getters are also the same way. Instead of a private Container._get_style("border") call, one can now use Container.styles.border. It also returns an already instantiated StyleCall, unlike the previous API which created them on every new call.

Best of all, the old API remains to work! I wouldn't bet on this continuing forever, so all new code should be written using the new version. If it does ever get removed I'll be sure to make it very obvious and loud.

Refactors

  • Implement new StyleManager class & API (e4c0036)
  • Improve Container.debug to shorten itself & use type(self) (e8ccd35)

Additions

  • Add value readout to ptg -g (a86e591)

Bugfixes

  • Fix ESC not being outputted in ptg -g (661e5ce)