diff --git a/pyansi/__init__.py b/pyansi/__init__.py index c5662cb..6e854da 100644 --- a/pyansi/__init__.py +++ b/pyansi/__init__.py @@ -39,21 +39,6 @@ def check_annotations(func: Callable) -> Callable: return wrapped -def readline_wrap(func: Callable) -> Callable: - """wrap output in SOH/STX so that readline handles prompts properly""" - - @wraps(func) - def wrapped(ansi: ANSI, *args, **kwargs): - result = "" - if ansi.readline_wrap: - result += ansi.SOH - result += func(ansi, *args, **kwargs) - if ansi.readline_wrap: - result += ansi.STX - - return wrapped - - class Mode(Enum): C0 = auto() C1 = auto() @@ -191,6 +176,21 @@ class ANSI: mode: Mode wrap: bool + @staticmethod + def readline_wrap(func: Callable) -> Callable: + """wrap output in SOH/STX so that readline handles prompts properly""" + + @wraps(func) + def wrapped(ansi: Self, *args, **kwargs): + result = "" + if ansi.wrap: + result += ansi.SOH + result += func(ansi, *args, **kwargs) + if ansi.wrap: + result += ansi.STX + + return wrapped + def __init__(self: Self, mode: Mode = Mode.C0, wrap: bool = False) -> None: self.mode = mode self.wrap = wrap