How to use the sty.fg.red 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 / muting.py View on Github external
from .. import Example


print("\n\nMUTING\n" + "="*80)

# ===== Start =====
Example("mute formatting")
from sty import fg

fg.mute()

a = fg.red + 'This red forground was muted.' + fg.rs
b = fg(10) + 'This green foreground was muted.' + fg.rs
c = fg(100, 140, 180) + "This blue foreground was muted." + fg.rs

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
github feluxe / sty / tests / docs / getting_started.py View on Github external
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 =====
github feluxe / sty / make.py View on Github external
def build_docs(cfg: Cfg):

    q = (
        f"{fg.red}WARNING{fg.rs}\n"
        "Documentation changes and code changes should use seperate commits.\n"
        "Only proceed if there are no uncommited code changes.\n\n"
        "Do you want to build the documentation pages?"
    )
    if not prmt.confirm(q, 'n'):
        return

    # Build Static Page with Sphinx
    sp.run(['make', 'html'], cwd='sphinx')

    build_html_dir = 'sphinx/_build/html'

    if os.path.isfile(f"{build_html_dir}/index.html"):
        shutil.rmtree('docs', ignore_errors=True)
        shutil.copytree(build_html_dir, 'docs')
        shutil.rmtree(build_html_dir, ignore_errors=True)
github thesofproject / sof / tools / coredumper / sof-coredump-reader.py View on Github external
return "{}:{:d}".format(self.filename.decode(), self.line_no)
	if FileInfo is None:
		raise RuntimeError(
			"FileInfoFactory: failed to produce FileInfo({0})"
				.format(arch.name)
		)
	return FileInfo

class Colourer():
	#TODO: Add detection of 8bit/24bit terminal
	#      Add 8bit/24bit colours (with flag, maybe --colour=24bit)
	#      Use this below as fallback only
	__print = partial(stdout_print)
	if CAN_COLOUR == True:
		__style = {
			'o' : fg.red,
			'O' : fg.yellow,
			'y' : fg.blue,
			'Y' : fg.cyan,
			'D' : fg.white + bg.red,
		}
	matchings          = []
	matchingsInParenth = []
	matchingsInStderr  = []
	def __init__(self):
		if CAN_COLOUR == True:
			self.matchings = [
				(
					lambda x: self.enstyleNumHex(x.group()),
					re.compile(r'\b([A-Fa-f0-9]{8})\b')
				),
				(
github albertwujj / HearthEnv / hearthenv / envs / hearthEnv.py View on Github external
specials += "W"
			if c.taunt:
				specials += "T"
			if c.divine_shield:
				specials += "D"
			if c.poisonous:
				specials += "P"
			if c.silenced:
				specials += "S"
			if c.frozen:
				specials += "F"
			if c.cannot_attack_heroes:
				specials += "H"
			c_health = str(c.max_health)
			if c.max_health != c.health:
				c_health = fg.red + str(c.health) + fg.rs + "/" + c_health
			if player is self.game.current_player:
				card += p(*color_can_attack(c), c.atk, c_health, *specials)
			else:
				card += p(c, c.atk, c_health, *specials)
			field.append(card)
		pout.append("FIELD: " + p(*field, s=", ")) # line 3
		return pout
github albertwujj / HearthEnv / hearthenv / utils / color_card.py View on Github external
from hearthstone.enums import Race
from sty import fg, bg, ef, rs

race_to_color = {Race.BEAST: fg.green, Race.DEMON: fg.magenta, Race.DRAGON: fg.red, Race.ELEMENTAL: fg.yellow, Race.MURLOC : fg.cyan,
				 Race.PIRATE: fg.blue, Race.TOTEM: fg.black }
# unused
def color_race(*card):
	""" colors cards according to their in-game race
	"""
	ret = []
	for i in card:
		if hasattr(i, "race") and i.race in race_to_color:
			ret.append("" + race_to_color[i.race] + str(i) + fg.rs)
		else:

			ret.append(str(i))
	return ret

def color_powered(*cards):
	""" colors cards if they are "powered up" (yellow in hand in official Hearthstone)