Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fg.unmute()
d = fg.red + 'The mute switch is off, so this is red.' + fg.rs
e = fg(10) + 'The mute switch is off, so this is green.' + fg.rs
f = fg(100, 140, 180) + 'The mute switch is off, so this is blue.' + fg.rs
print(a, b, c, d, e, f, sep='\n')
# ===== End =====
# ===== Start =====
Example("mute formatting batch")
from sty import mute, unmute, ef, fg, bg, rs
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' + rs.italic
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' + rs.italic
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' + rs.italic
print(a1, a2, a3, b1, b2, b3, c1, c2, c3, sep='\n')
# ===== End =====
from .. import Example
print("\n\nEFFECTS\n" + "="*80)
# ===== Start =====
Example("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')
# ===== End =====
# ===== Start =====
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
from .. import Example
from random import randint
print("\n\nGETTING STARTED\n" + "=" * 80)
# ===== Start =====
Example("gettings started: sty all the strings")
from sty import fg, bg, ef, rs
foo = fg.red + 'This is red text!' + fg.rs
bar = bg.blue + 'This has a blue background!' + bg.rs
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs
# Add custom colors:
from sty import Style, RgbFg
fg.orange = Style(RgbFg(255, 150, 50))
buf = fg.orange + 'Yay, Im orange.' + fg.rs
print(foo, bar, baz, qux, qui, buf, sep='\n')
# ===== End =====
# ===== Start =====
Example("gettings started: select dynamically")
def i(self):
if terminal_colors() == 0:
return self.copy(self._body)
text = self._body
text = sty.ef.italic + text + sty.rs.all
return self.copy(text)