我们从Python开源项目中,提取了以下48个代码示例,用于说明如何使用termios.tcflush()。
def a_input(prompt: str) -> str: """Async input prompt.""" readable = [] # type: List[int] print(prompt, end='') sys.stdout.flush() while not readable: readable, _, _ = select.select([sys.stdin], [], [], 0) try: await asyncio.sleep(0.1) except futures.CancelledError: print("input cancelled...") termios.tcflush(sys.stdin, termios.TCIFLUSH) raise return sys.stdin.readline().rstrip() # [ Classes ]
def reset_input_buffer(self): """Clear input buffer, discarding all that is in the buffer.""" if not self.is_open: raise portNotOpenError termios.tcflush(self.fd, termios.TCIFLUSH)
def reset_output_buffer(self): """\ Clear output buffer, aborting the current output and discarding all that is in the buffer. """ if not self.is_open: raise portNotOpenError termios.tcflush(self.fd, termios.TCOFLUSH)
def forgetinput(self): termios.tcflush(self.input_fd, termios.TCIFLUSH)
def flushInput(self): """Clear input buffer, discarding all that is in the buffer.""" if not self._isOpen: raise portNotOpenError termios.tcflush(self.fd, TERMIOS.TCIFLUSH)
def flushOutput(self): """Clear output buffer, aborting the current output and discarding all that is in the buffer.""" if not self._isOpen: raise portNotOpenError termios.tcflush(self.fd, TERMIOS.TCOFLUSH)
def flushOutput(self): """\ Clear output buffer, aborting the current output and discarding all that is in the buffer. """ if not self._isOpen: raise portNotOpenError termios.tcflush(self.fd, TERMIOS.TCOFLUSH)
def flushInput(self): """Clear input buffer, discarding all that is in the buffer.""" termios.tcflush(self._f.fileno(), termios.TCIFLUSH)
def flushOutput(self): """Clear output buffer, aborting the current output and discarding all that is in the buffer.""" termios.tcflush(self._f.fileno(), termios.TCOFLUSH)
def flush(self): """ flush stdin... untested on Windows" """ if os.name == 'nt': while self.kbhit(): self.getch() else: termios.tcflush(sys.stdin, termios.TCIOFLUSH) return # Test
def getch(self): termios.tcflush(0, termios.TCIFLUSH) # XXX Leave this in? return os.read(self._fd, 1)
def close(self, delay = 0): if delay: time.sleep(delay) termios.tcflush(self._fd, termios.TCIFLUSH) termios.tcsetattr(self._fd, termios.TCSAFLUSH, self._old)