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

Method prepare

Lib/_pyrepl/unix_console.py:327–365  ·  view source on GitHub ↗

Prepare the console for input/output operations.

(self)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 7

getheightwidthMethod · 0.95
__maybe_write_codeMethod · 0.95
tcgetattrFunction · 0.70
tcsetattrFunction · 0.70
copyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected