DRYer
This commit is contained in:
parent
4ffcbc8274
commit
336c7ddca8
@ -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')
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user