MCPcopy Index your code
hub / github.com/RustPython/RustPython / Console

Class Console

Lib/_pyrepl/console.py:47–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

get_readerMethod · 0.85

Calls 1

fieldFunction · 0.90

Tested by

no test coverage detected