make readline_wrap a staticmethod
This commit is contained in:
parent
78090e80b9
commit
a463c62d69
1 changed files with 15 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue