Effects

Sty uses ANSI SGR parameters to apply effects. More about ANSI Select Graphic Rendition (SGR) on wikipedia: ANSI SGR

Sty’s default effect register

These are the default attributes for the sty.ef register-object.

Attribute

Description

Default Renderer

ef.bold (alias b)

Bold or increased intensity

sty.renderfunc.sgr(1)

ef.dim

Decreased intensity

sty.renderfunc.sgr(2)

ef.italic (alias i)

Italic..

sty.renderfunc.sgr(3)

ef.underl (alias u)

Underline..

sty.renderfunc.sgr(4)

ef.blink

Blink..

sty.renderfunc.sgr(5)

ef.inverse

Inverse fore- and background

sty.renderfunc.sgr(7)

ef.hidden

Conceal/Hide

sty.renderfunc.sgr(8)

ef.strike

Strike-through

sty.renderfunc.sgr(9)

Italic

from sty import ef, fg, rs

a = ef.italic + 'Italic.' + rs.italic

# There are shorthands for this:
b = ef.i + fg.blue + 'Italic.' + rs.i + ' Not italic but blue.' + rs.fg

print(a, b, sep='\n')
italic example

Bold

from sty import ef, fg, rs

a = ef.bold + 'Bold.' + rs.bold_dim

# This has shorthands too:
b = ef.b + 'Bold.' + rs.bold_dim + fg.li_yellow + ' Not bold but yellow.' + rs.fg

print(a, b, sep='\n')
bold example

Underline

from sty import ef, fg, rs

a = ef.underl + 'Underlined.' + rs.underl

# Shorthand version:
b = ef.u + 'Underlined.' + rs.u + fg.green + ' Not underlined but green.' + rs.fg

print(a, b, sep='\n')
underline example

TODO:

Add examples for strike, blink, etc..