Prepare the console for input/output operations.
(self)
| 339 | self.flushoutput() |
| 340 | |
| 341 | def prepare(self): |
| 342 | """ |
| 343 | Prepare the console for input/output operations. |
| 344 | """ |
| 345 | self.__buffer = [] |
| 346 | |
| 347 | self.__svtermstate = tcgetattr(self.input_fd) |
| 348 | raw = self.__svtermstate.copy() |
| 349 | raw.iflag &= ~(termios.INPCK | termios.ISTRIP | termios.IXON) |
| 350 | raw.oflag &= ~(termios.OPOST) |
| 351 | raw.cflag &= ~(termios.CSIZE | termios.PARENB) |
| 352 | raw.cflag |= termios.CS8 |
| 353 | raw.iflag |= termios.BRKINT |
| 354 | raw.lflag &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN) |
| 355 | raw.lflag |= termios.ISIG |
| 356 | raw.cc[termios.VMIN] = 1 |
| 357 | raw.cc[termios.VTIME] = 0 |
| 358 | self.__input_fd_set(raw) |
| 359 | |
| 360 | # In macOS terminal we need to deactivate line wrap via ANSI escape code |
| 361 | if self.is_apple_terminal: |
| 362 | os.write(self.output_fd, b"\033[?7l") |
| 363 | |
| 364 | self.screen = [] |
| 365 | self.height, self.width = self.getheightwidth() |
| 366 | |
| 367 | self.posxy = 0, 0 |
| 368 | self.__gone_tall = 0 |
| 369 | self.__move = self.__move_short |
| 370 | self.__offset = 0 |
| 371 | |
| 372 | self.__maybe_write_code(self._smkx) |
| 373 | |
| 374 | try: |
| 375 | self.old_sigwinch = signal.signal(signal.SIGWINCH, self.__sigwinch) |
| 376 | except ValueError: |
| 377 | pass |
| 378 | |
| 379 | self.__enable_bracketed_paste() |
| 380 | |
| 381 | def restore(self): |
| 382 | """ |