How to use the sty.rendertype.RenderType 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 / sty / primitive.py View on Github external
def _render_rules(
    renderfuncs,
    rules,
) -> Tuple[str, List[RenderType]]:

    rendered: str = ''
    flattened_rules = []

    if isinstance(rules, RenderType):
        f1: Callable = renderfuncs[type(rules)]
        rendered += f1(*rules.args)
        flattened_rules.append(rules)

    elif isinstance(rules, Style):
        r1, r2 = _render_rules(renderfuncs, rules.rules)
        rendered += r1
        flattened_rules.extend(r2)

    elif isinstance(rules, (list, tuple)):

        for rule in rules:

            r1, r2 = _render_rules(renderfuncs, rule)
            rendered += r1
            flattened_rules.extend(r2)
github feluxe / sty / sty / primitive.py View on Github external
def __init__(self):
        self.renderfuncs: Dict[RenderType, Callable] = {}
        self.is_muted = False
        self.eightbit_call = lambda x: x
        self.rgb_call = lambda r, g, b: (r, g, b)
github feluxe / sty / sty / rendertype.py View on Github external
class EightbitBg(RenderType):
    """
    Define Eightbit Background.

    More info about 8-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

    :param num: Eightbit number.
    """

    def __init__(self, num: int):
        self.args = [num]


class RgbFg(RenderType):
    """
    Define RGB Foreground.

    More info about 24-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit

    :param r: Red.
    :param g: Green.
    :param b: Blue.
    """

    def __init__(self, r: int, g: int, b: int):
        self.args = [r, g, b]


class RgbBg(RenderType):
    """
github feluxe / sty / sty / rendertype.py View on Github external
"""
"""


class RenderType:
    args: list = []


class Sgr(RenderType):
    """
    Define SGR styling rule.

    More info about SGR parameters: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR

    :param num: A SGR number.
    """

    def __init__(self, num: int):
        self.args = [num]


class EightbitFg(RenderType):
    """
    Define Eightbit Foreground.
github feluxe / sty / sty / rendertype.py View on Github external
class RgbFg(RenderType):
    """
    Define RGB Foreground.

    More info about 24-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit

    :param r: Red.
    :param g: Green.
    :param b: Blue.
    """

    def __init__(self, r: int, g: int, b: int):
        self.args = [r, g, b]


class RgbBg(RenderType):
    """
    Define RGB Background.

    More info about 24-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit

    :param r: Red.
    :param g: Green.
    :param b: Blue.
    """

    def __init__(self, r: int, g: int, b: int):
        self.args = [r, g, b]
github feluxe / sty / sty / rendertype.py View on Github external
class Sgr(RenderType):
    """
    Define SGR styling rule.

    More info about SGR parameters: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR

    :param num: A SGR number.
    """

    def __init__(self, num: int):
        self.args = [num]


class EightbitFg(RenderType):
    """
    Define Eightbit Foreground.

    More info about 8-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

    :param num: Eightbit number.
    """

    def __init__(self, num: int):
        self.args = [num]


class EightbitBg(RenderType):
    """
    Define Eightbit Background.
github feluxe / sty / sty / rendertype.py View on Github external
class EightbitFg(RenderType):
    """
    Define Eightbit Foreground.

    More info about 8-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

    :param num: Eightbit number.
    """

    def __init__(self, num: int):
        self.args = [num]


class EightbitBg(RenderType):
    """
    Define Eightbit Background.

    More info about 8-bit terminal colors: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

    :param num: Eightbit number.
    """

    def __init__(self, num: int):
        self.args = [num]


class RgbFg(RenderType):
    """
    Define RGB Foreground.