Handle remote print callback in tests

This commit is contained in:
Kovid Goyal
2022-02-22 11:47:44 +05:30
parent 05617f7dca
commit cb32a0b8fc
2 changed files with 17 additions and 6 deletions

View File

@@ -301,6 +301,13 @@ def text_sanitizer(as_ansi: bool, add_wrap_markers: bool) -> Callable[[str], str
return remove_wrap_markers
def process_remote_print(msg: bytes) -> str:
from base64 import standard_b64decode
from .cli import green
text = standard_b64decode(msg).decode('utf-8', 'replace')
return text.replace('\x1b', green(r'\e')).replace('\a', green(r'\a')).replace('\0', green(r'\0'))
class EdgeWidths:
left: Optional[float]
top: Optional[float]
@@ -845,11 +852,7 @@ class Window:
get_boss().handle_remote_cmd(cmd, self)
def handle_remote_print(self, msg: bytes) -> None:
from base64 import standard_b64decode
from .cli import green
text = standard_b64decode(msg).decode('utf-8')
text = text.replace('\x1b', green(r'\e')).replace('\a', green(r'\a')).replace('\0', green(r'\0'))
text = process_remote_print(msg)
print(text, end='', file=sys.stderr)
sys.stderr.flush()