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 |
sgr(1) |
ef.dim |
Decreased intensity |
sgr(2) |
ef.italic (alias i) |
Italic.. |
sgr(3) |
ef.underl (alias u) |
Underline.. |
sgr(4) |
ef.blink |
Blink.. |
sgr(5) |
ef.inverse |
Inverse fore- and background |
sgr(7) |
ef.hidden |
Conceal/Hide |
sgr(8) |
ef.strike |
Strike-through |
sgr(9) |
ef.rs |
Reset effects |
sgr(22), sgr(23), sgr(24), sgr(25), sgr(27), sgr(28), sgr(29) |
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")
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")
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")
TODO:
Add examples for strike, blink, etc..