This commit is contained in:
Kovid Goyal 2021-10-31 15:41:19 +05:30
parent 4ffcbc8274
commit 336c7ddca8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,6 @@
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
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')

View File

@ -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)