| 47 | |
| 48 | @dataclass |
| 49 | class Console(ABC): |
| 50 | posxy: tuple[int, int] |
| 51 | screen: list[str] = field(default_factory=list) |
| 52 | height: int = 25 |
| 53 | width: int = 80 |
| 54 | |
| 55 | def __init__( |
| 56 | self, |
| 57 | f_in: IO[bytes] | int = 0, |
| 58 | f_out: IO[bytes] | int = 1, |
| 59 | term: str = "", |
| 60 | encoding: str = "", |
| 61 | ): |
| 62 | self.encoding = encoding or sys.getdefaultencoding() |
| 63 | |
| 64 | if isinstance(f_in, int): |
| 65 | self.input_fd = f_in |
| 66 | else: |
| 67 | self.input_fd = f_in.fileno() |
| 68 | |
| 69 | if isinstance(f_out, int): |
| 70 | self.output_fd = f_out |
| 71 | else: |
| 72 | self.output_fd = f_out.fileno() |
| 73 | |
| 74 | @abstractmethod |
| 75 | def refresh(self, screen: list[str], xy: tuple[int, int]) -> None: ... |
| 76 | |
| 77 | @abstractmethod |
| 78 | def prepare(self) -> None: ... |
| 79 | |
| 80 | @abstractmethod |
| 81 | def restore(self) -> None: ... |
| 82 | |
| 83 | @abstractmethod |
| 84 | def move_cursor(self, x: int, y: int) -> None: ... |
| 85 | |
| 86 | @abstractmethod |
| 87 | def set_cursor_vis(self, visible: bool) -> None: ... |
| 88 | |
| 89 | @abstractmethod |
| 90 | def getheightwidth(self) -> tuple[int, int]: |
| 91 | """Return (height, width) where height and width are the height |
| 92 | and width of the terminal window in characters.""" |
| 93 | ... |
| 94 | |
| 95 | @abstractmethod |
| 96 | def get_event(self, block: bool = True) -> Event | None: |
| 97 | """Return an Event instance. Returns None if |block| is false |
| 98 | and there is no event pending, otherwise waits for the |
| 99 | completion of an event.""" |
| 100 | ... |
| 101 | |
| 102 | @abstractmethod |
| 103 | def push_char(self, char: int | bytes) -> None: |
| 104 | """ |
| 105 | Push a character to the console event queue. |
| 106 | """ |
no test coverage detected
searching dependent graphs…