Recent Releases of sty

sty - v1.0.5

Code Changes:

  • Add py.typed file for better typing support. Thanks! @Eisfunke
  • Use explicit imports: from .lib import is now from sty.lib import.
  • More and better doc-strings. help(x) should be much more useful now.

Other:

  • Add svg logo. Thanks! @kubinka0505
  • Replace pipenv with poetry.
  • Remove make.py build system.
  • Remove all dev dependencies.

- Python
Published by feluxe about 2 years ago

sty - v1.0.4

This is not really a software release. The only thing which changed is the README.rst within the pypi package in order to render correctly on https://pypi.org/project/sty/

- Python
Published by feluxe about 4 years ago

sty - v1.0.3

This is not really a software release. The only thing which changed is the README.rst within the pypi package in order to render correctly on https://pypi.org/project/sty/

- Python
Published by feluxe about 4 years ago

sty - v1.0.2

This is not really a software release. The only thing which changed is the README.rst within the pypi package in order to render correctly on https://pypi.org/project/sty/

- Python
Published by feluxe about 4 years ago

sty - v1.0.1

This is not really a software release. The only thing which changed is the README.rst within the pypi package in order to render correctly on https://pypi.org/project/sty/

- Python
Published by feluxe about 4 years ago

sty - v1.0.0

Sty v1.0.0 released 🎉

At this point sty can be considered stable.

The "release candidate" phase was given a lot of time and nothing critical was reported for a while. All features that are planned for the future are compatible with the existing interfaces.

Nothing changed since rc.2.

- Python
Published by feluxe about 4 years ago

sty - 1.0.0-rc.2

This release fixes a nasty typo within the reset register. (Thanks a lot @technikian for fixing this!)

Unfortunately this introduces a minor breaking change....

Breaking Changes

  • Renamed sty.rs.rs into sty.rs.ef.

- Python
Published by feluxe over 4 years ago

sty - 1.0.0-rc.1

This should be the last breaking change for any version which starts with 1.

Breaking Changes

  • Deprecated methods .set_style(...) and .get_style(...) were finally removed.

Non Breaking Changes

  • sty is now fully typed.

- Python
Published by feluxe about 5 years ago

sty - 1.0.0-rc.0

Sty version 1.0.0 is now feature complete.

  • I'm going to support Python version >=3.7 indefinitely.
  • Sty will follow semver so there won't be any breaking changes for version 1.x.x after 1.0.0 was released.
  • This is a pre-release (rc.0). I'll release 1.0.0 in a couple of month if no major bugs are reported.

Breaking Changes

The grey palette changed from:

```python liblack = Rule(Render.sgr, 90) black = Rule(Render.sgr, 30) dablack = Rule(Render.eightbit_fg, 0)

liwhite = Rule(Render.sgr, 97) white = Rule(Render.sgr, 37) dawhite = Rule(Render.eightbit_fg, 249) ```

to:

python black = Rule(Render.sgr, 30) da_grey = Rule(Render.sgr, 90) grey = Rule(Render.eightbit_fg, 249) li_grey = Rule(Render.sgr, 37) white = Rule(Render.sgr, 97)

Which means:

  • li_black is now da_grey
  • black remains black
  • da_black is now black
  • li_white is now white
  • white is now li_grey
  • da_white is now grey

Non Breaking Changes

The effect-register and the reset-register now have a ef.rs and a rs.ef attribute, these can be used for resetting all effects in one go. E.g.:

python a = f"{ef.bold}{ef.italic}hello world{ef.rs}"

- Python
Published by feluxe about 5 years ago

sty - 1.0.0-beta.6

New effect names

These effects were renamed:

faint is now dim conceal is now hidden reverse is now inverse blink_fast is now blink underline is now underl

Drop blink_fast

Blink fast doesn't seem to be supported by most modern terminals. It was dropped for a cleaner api and possible unwanted side-effects.

Merge resetters for bold and dim

Fixes: #3

It turns out that most terminal use the same reset sequence for both bold and dim. That means rs.bold and rs.dim have to be merged into rs.bold_dim and rs.dim_bold. This sucks, but since that's how terminals do it, I don't see a better way to solve this in sty.

That measn rs.bold, rs.b, rs.dim (formaly rs.faint) were dropped in favor of rs.bold_dim and rs.dim_bold.

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.7

This release comes with a lot of changes, including a complete rewrite of the Base class and a rework of the Customization API. From now on you can mute/unmute styles as well.

Highlights * Rework of Customization API * Rework of the Base class. * New Rule type for assigning rules to attributes. * New Render enum storing render-function names. * New way of assigning renderers and special call functions in the register-class definition. * Ability to replace/add render-functions for register-objects * Ability to mute/unmute register-objects.

Render-functions moved

The default render functions moved from sty.renderer to sty.renderfunc.

Changes within the customization API

Before Beta 7 new rules were assigned like this:

```python from sty import fg

Direct attribute assignment

fg.orange = ('rgb', (255, 150, 50))

Attribute assignment via method

fg.set('my_color', 'eightbit', 51) `` SinceBeta 7` you do it like this:

```python from sty import fg, Rule, Render

Direct attribute assignment

fg.orange = Rule(Render.rgb_fg, 255, 150, 50)

Attribute assignment via method

fg.setrule('mycolor', Rule(Render.eightbit_fg, 51)) ```

You can see there are a couple of changes.

set method renamed to set_rule

fg.set(.. is now fg.set_rule(...

The Rule type

We now use the Rule type (see example above) to set new styling/formatting rules for attributes. This makes for a cleaner Base class and a more structured API.

The Render enum There is a new Render enum (see example above), which provides the renderer names. That means you can select a renderer via the Render enum:

python Rule(Render.rgb_fg, 10, 20, 30)

The old style of selecting render functions by string still works as well:

python Rule('rgb_fg', 10, 20, 30)

New register-class definition

Before Beta 7 you could extend the default register classes like this:

```python from sty.register import FgRegister

Extend default Fg register.

class MyFgRegister(FgRegister):

# Set a custom render-function
def custom_rgb_fg(self, *args):
    return my_custom_rgb_fg_func(*args)

# Set render-function for rgb call. 
def _rgb_call(self, *args):
    return my_custom_rgb_fg_func(*args)

black = ('sgr', 31)
red = ('sgr', 34)
orange = ('custom_rgb_fg', (255, 128, 0))
# ...

```

In Beta 7 you do it like this:

```python import sty from sty import FgRegister, Rule, Render

Extend the enum with the name of your new render-funtion.

class Render(sty.Render): customrgbfg = 'customrgbfg'

Extend default Fg register.

class MyFgRegister(FgRegister):

# Set a custom render-function
def __init__(self):
    super().__init__() # Call super to apply render-functions from parent FgRegister.
    self.set_renderer(Render.custom_rgb_fg, my_custom_rgb_fg)

# Set render-function for rgb call. 
rgb_call = Rule(Render.rgb_fg)

black = Rule(Render.sgr, 31)
red = Rule(Render.sgr, 34)
orange = Rule(Render.custom_rgb_bg, 255, 128, 0)
# ...

``` As you see in the example above, they way we assign render-functions and the way we set render-functions for the special call methods has changed.

I suggest adding the name of the new renderer to the Render enum as shown above.

The new set_renderer method

You can now add/change render-functions for each register-object:

```python from sty import fg, Render

def mycustomrenderfunc(): # ...

fg.setrenderer(Render.rgbfg, mycustomrenderfunc) ```

Muting / Silencing / Disabling formatting

This is now possible.

The mute and unmute methods

Sometimes its useful to disable the formatting for a register-object. You can do so by invoking the mute and unmute methods:

```python a = fg.red + 'This text is red.' + fg.rs

fg.mute()

b = fg.red + 'This text is NOT red.' + fg.rs

fg.unmute()

c = fg.red + 'This text is red.' + fg.rs ```

The mute and unmute batch functions

If you want to mute multiple register-objects at the same time you can use the mute and unmute functions that you find in sty.mute, sty.unmute:

```python from sty import fg, bg, ef, rs, mute, unmute

a1 = fg.red + 'This text is red.' + fg.rs a2 = bg.red + 'This bg is red.' + bg.rs a3 = ef.italic + 'This text is italic' + ef.rs

mute(fg, bg, ef, rs)

b1 = fg.red + 'This text is NOT red.' + fg.rs b2 = bg.red + 'This bg is NOT red.' + bg.rs b3 = ef.italic + 'This text is NOT italic' + ef.rs

unmute(fg, bg, ef, rs)

c1 = fg.red + 'This text is red.' + fg.rs c2 = bg.red + 'This bg is red.' + bg.rs c3 = ef.italic + 'This text is italic' + ef.rs ```

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.8

No breaking changes with this release.

You can now set multiple style rules on a single attribute

This works now:

python fg.green_ul = Rule(Render.sgr, 32), Rule(Render.sgr, 4) fg.red_i = Rule(Render.sgr, 31), ef.i fg.blue_b = fg.blue + ef.b

Same for set_rule:

python fg.set_rule('teal_b', (Rule(Render.eightbit_fg, 51), Rule(Render.sgr, 1))) fg.set_rule('green_i', (fg.green, ef.i)) fg.set_rule('red_u', (Rule(Render.sgr, 31), ef.underl))

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.9

I ran a bunch of performance tests on sty and I realized, that attribute access performance was unnecessarily bad. I figured that this was mainly due to the customization API, being somewhat complicated internally. The main goal of this release was to improve performance and simplify the customization API.

I think this brings us close to v1.0.0.

Highlights * Increase access performance (a lot!) * Simplify customiziation API * Better linter compatibility (mypy, pylint, etc.) * Move documentation from gitub README to sphinx page. * Add as_dict, as_namedtuple, copy methods. * Improve tests

Breaking changes

The customization API was rewritten. Please refer to the docs: https://feluxe.github.io/sty/docs/customizing.html

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.10

This release contains some bug fixes and cleanups.

Fixed issues:

  • Broken Python attribute protocol. #17
  • Double is_muted. #18
  • Fix pypi project description. #20

Breaking changes

sty's minimal required version increased from 3.5 to 3.6.

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.11

The Base class was refactored as a follow up of #17. The Base class doesn't need to derive from dict anymore. We now derive from object. This makes the code somewhat simpler. It also increased access performance a lot.

There are some basic access performance tests in the tests directory now.

Breaking Changes

The refactoring of the Base class let to one simple change in the customization interface.

When you create a register class, you now have to call super().__init__(), inside the __init__() method:

```python class FgRegister(Base):

yellow: str
red: str
# ...

def __init__(self):

    super().__init__() # <--- This is necessary now.

    self.set_renderfunc(Sgr, renderfunc.sgr)
    self.set_renderfunc(EightbitFg, renderfunc.eightbit_fg)
    # ...

```

- Python
Published by feluxe over 6 years ago

sty - 1.0.0-beta.12

Release 1.0.0b12. Multiple changes:

  • Implement Style() type: This changes the way in which Sty's Register() class sets, reads and renders styling rules. This allows for a more Pythonic customization interface.
    This change obsoletes set_style() and get_style(), thus the two methods are now deprecated.
  • Change yapf line-length to 88.

Documentation will be update with the next commits.

Breaking Changes

There are two breaking changes within the customization interface, which are easy to fix:

  • sty.Base was renamed to sty.Register.
  • sty.Render was renamed to sty.RenderType.

- Python
Published by feluxe over 6 years ago