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)