MCPcopy Index your code
hub / github.com/python/cpython / Console

Class Console

Lib/_pyrepl/console.py:49–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48@dataclass
49class 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 """

Callers 1

get_readerMethod · 0.85

Calls 1

fieldFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…