Prepare the console for input/output operations.
(self)
| 325 | self.flushoutput() |
| 326 | |
| 327 | def prepare(self): |
| 328 | """ |
| 329 | Prepare the console for input/output operations. |
| 330 | """ |
| 331 | self.__svtermstate = tcgetattr(self.input_fd) |
| 332 | raw = self.__svtermstate.copy() |
| 333 | raw.iflag &= ~(termios.INPCK | termios.ISTRIP | termios.IXON) |
| 334 | raw.oflag &= ~(termios.OPOST) |
| 335 | raw.cflag &= ~(termios.CSIZE | termios.PARENB) |
| 336 | raw.cflag |= termios.CS8 |
| 337 | raw.iflag |= termios.BRKINT |
| 338 | raw.lflag &= ~(termios.ICANON | termios.ECHO | termios.IEXTEN) |
| 339 | raw.lflag |= termios.ISIG |
| 340 | raw.cc[termios.VMIN] = 1 |
| 341 | raw.cc[termios.VTIME] = 0 |
| 342 | tcsetattr(self.input_fd, termios.TCSADRAIN, raw) |
| 343 | |
| 344 | # In macOS terminal we need to deactivate line wrap via ANSI escape code |
| 345 | if platform.system() == "Darwin" and os.getenv("TERM_PROGRAM") == "Apple_Terminal": |
| 346 | os.write(self.output_fd, b"\033[?7l") |
| 347 | |
| 348 | self.screen = [] |
| 349 | self.height, self.width = self.getheightwidth() |
| 350 | |
| 351 | self.__buffer = [] |
| 352 | |
| 353 | self.posxy = 0, 0 |
| 354 | self.__gone_tall = 0 |
| 355 | self.__move = self.__move_short |
| 356 | self.__offset = 0 |
| 357 | |
| 358 | self.__maybe_write_code(self._smkx) |
| 359 | |
| 360 | try: |
| 361 | self.old_sigwinch = signal.signal(signal.SIGWINCH, self.__sigwinch) |
| 362 | except ValueError: |
| 363 | pass |
| 364 | |
| 365 | self.__enable_bracketed_paste() |
| 366 | |
| 367 | def restore(self): |
| 368 | """ |
nothing calls this directly
no test coverage detected