How to use the sty.Style function in sty

To help you get started, we’ve selected a few sty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feluxe / sty / tests / docs / customizing.py View on Github external
Example("customizing the register-objects: assignment")
from sty import fg, ef, rs, Style, RgbFg, Sgr

fg.my_red = Style(RgbFg(255, 0, 0))

a = fg.my_red + 'This text has red fg.' + fg.rs

print(a)
# ===== End =====

# ===== Start =====
Example("customizing the register-objects: compose")
from sty import fg, ef, rs, Style, RgbFg, Sgr

fg.blue_bold = Style(RgbFg(0, 100, 200), Sgr(1))
fg.green_italic = Style(fg.green, ef.i)

a = fg.blue_bold + 'This text has bold blue fg.' + rs.all
b = fg.green_italic + 'This text has italic green fg' + rs.all

print(a, b, sep='\n')
# ===== End =====

# ===== Start =====
Example("customizing the register-objects: set_style")
from sty import fg, RgbFg

fg.set_style('my_red', RgbFg(255, 0, 0))

a = fg.my_red + 'This text has red fg.' + fg.rs

print(a)