From 18e161e7d8836320ad2896064ad90b9cd6442883 Mon Sep 17 00:00:00 2001 From: haskal Date: Wed, 12 May 2021 16:47:33 -0400 Subject: [PATCH] refactor --- megacom/__init__.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/megacom/__init__.py b/megacom/__init__.py index 9166ebb..0d1c647 100644 --- a/megacom/__init__.py +++ b/megacom/__init__.py @@ -158,23 +158,13 @@ async def megacom(tty: str, baud: int, mode: str) -> None: async def connect_pipe(pin: asyncio.StreamReader, pout: asyncio.StreamWriter, ctrl: bool = False) -> None: - esc: bool = False while not pin.at_eof(): c: bytes = await pin.read(1) if len(c) == 0: continue - if esc: - esc = False - if c == b"\x01": - pout.write(b"\x01") - await pout.drain() - elif c == b"q": - keycodes.exit_flag.set() - break - - if c == b"\x01" and ctrl: - esc = True + c = keycodes.process(c) + if len(c) == 0: continue pout.write(c)