diff --git a/kitty/rc/send_text.py b/kitty/rc/send_text.py index 6067efc03..c61675ba2 100644 --- a/kitty/rc/send_text.py +++ b/kitty/rc/send_text.py @@ -2,7 +2,6 @@ # License: GPLv3 Copyright: 2020, Kovid Goyal import base64 -import os import sys from typing import TYPE_CHECKING, List, Optional, Union @@ -73,7 +72,7 @@ Do not send text to the active window, even if it is one of the matched windows. while keep_going: if not tty.wait_till_read_available(): break - data = os.read(tty.tty_fd, limit) + data = tty.read(limit) if not data: break decoded_data = data.decode('utf-8') diff --git a/kitty/utils.py b/kitty/utils.py index a05970566..0a3d4bc9c 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -461,6 +461,9 @@ class TTYIO: rd = select.select([self.tty_fd], [], [])[0] return bool(rd) + def read(self, limit: int) -> bytes: + return os.read(self.tty_fd, limit) + def send(self, data: Union[str, bytes, Iterable[Union[str, bytes]]]) -> None: if isinstance(data, (str, bytes)): write_all(self.tty_fd, data)