Initialize the UnixConsole. Parameters: - f_in (int or file-like object): Input file descriptor or object. - f_out (int or file-like object): Output file descriptor or object. - term (str): Terminal name. - encoding (str): Encoding to use for I/O ope
(
self,
f_in: IO[bytes] | int = 0,
f_out: IO[bytes] | int = 1,
term: str = "",
encoding: str = "",
)
| 131 | |
| 132 | class UnixConsole(Console): |
| 133 | def __init__( |
| 134 | self, |
| 135 | f_in: IO[bytes] | int = 0, |
| 136 | f_out: IO[bytes] | int = 1, |
| 137 | term: str = "", |
| 138 | encoding: str = "", |
| 139 | ): |
| 140 | """ |
| 141 | Initialize the UnixConsole. |
| 142 | |
| 143 | Parameters: |
| 144 | - f_in (int or file-like object): Input file descriptor or object. |
| 145 | - f_out (int or file-like object): Output file descriptor or object. |
| 146 | - term (str): Terminal name. |
| 147 | - encoding (str): Encoding to use for I/O operations. |
| 148 | """ |
| 149 | super().__init__(f_in, f_out, term, encoding) |
| 150 | |
| 151 | self.pollob = poll() |
| 152 | self.pollob.register(self.input_fd, select.POLLIN) |
| 153 | self.input_buffer = b"" |
| 154 | self.input_buffer_pos = 0 |
| 155 | curses.setupterm(term or None, self.output_fd) |
| 156 | self.term = term |
| 157 | |
| 158 | @overload |
| 159 | def _my_getstr(cap: str, optional: Literal[False] = False) -> bytes: ... |
| 160 | |
| 161 | @overload |
| 162 | def _my_getstr(cap: str, optional: bool) -> bytes | None: ... |
| 163 | |
| 164 | def _my_getstr(cap: str, optional: bool = False) -> bytes | None: |
| 165 | r = curses.tigetstr(cap) |
| 166 | if not optional and r is None: |
| 167 | raise InvalidTerminal( |
| 168 | f"terminal doesn't have the required {cap} capability" |
| 169 | ) |
| 170 | return r |
| 171 | |
| 172 | self._bel = _my_getstr("bel") |
| 173 | self._civis = _my_getstr("civis", optional=True) |
| 174 | self._clear = _my_getstr("clear") |
| 175 | self._cnorm = _my_getstr("cnorm", optional=True) |
| 176 | self._cub = _my_getstr("cub", optional=True) |
| 177 | self._cub1 = _my_getstr("cub1", optional=True) |
| 178 | self._cud = _my_getstr("cud", optional=True) |
| 179 | self._cud1 = _my_getstr("cud1", optional=True) |
| 180 | self._cuf = _my_getstr("cuf", optional=True) |
| 181 | self._cuf1 = _my_getstr("cuf1", optional=True) |
| 182 | self._cup = _my_getstr("cup") |
| 183 | self._cuu = _my_getstr("cuu", optional=True) |
| 184 | self._cuu1 = _my_getstr("cuu1", optional=True) |
| 185 | self._dch1 = _my_getstr("dch1", optional=True) |
| 186 | self._dch = _my_getstr("dch", optional=True) |
| 187 | self._el = _my_getstr("el") |
| 188 | self._hpa = _my_getstr("hpa", optional=True) |
| 189 | self._ich = _my_getstr("ich", optional=True) |
| 190 | self._ich1 = _my_getstr("ich1", optional=True) |
nothing calls this directly
no test coverage detected