当前位置: 首页>>代码示例>>Python>>正文


Python termios.TCSAFLUSH属性代码示例

本文整理汇总了Python中termios.TCSAFLUSH属性的典型用法代码示例。如果您正苦于以下问题:Python termios.TCSAFLUSH属性的具体用法?Python termios.TCSAFLUSH怎么用?Python termios.TCSAFLUSH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在termios的用法示例。


在下文中一共展示了termios.TCSAFLUSH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def __init__(self):
        '''Creates a KBHit object that you can call to do various keyboard things.
        '''

        if os.name == 'nt':
            pass
        
        else:
    
            # Save the terminal settings
            self.fd = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.fd)
            self.old_term = termios.tcgetattr(self.fd)
    
            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.new_term)
    
            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
开发者ID:sonofeft,项目名称:RocketCEA,代码行数:22,代码来源:keyboard_hit.py

示例2: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def __init__(self):
        '''Creates a KBHit object that you can call to do various keyboard things.
        '''

        if os.name == 'nt':
            pass

        else:

            # Save the terminal settings
            self.fd = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.fd)
            self.old_term = termios.tcgetattr(self.fd)

            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.new_term)

            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
开发者ID:fandoghpaas,项目名称:fandogh-cli,代码行数:22,代码来源:utils.py

示例3: wait_key

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def wait_key():
    """ Wait for a key press on the console and return it. """
    result = None
    if os.name == 'nt':
        result = input("Press Enter to continue...")
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result 
开发者ID:donwayo,项目名称:ebayKleinanzeigen,代码行数:24,代码来源:kleinanzeigen.py

示例4: getch

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def getch():
        """getch function
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 80)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
开发者ID:mysql,项目名称:mysql-utilities,代码行数:18,代码来源:console.py

示例5: getch

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def getch():
        """Make a get character keyboard method for Posix machines.
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 4)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
开发者ID:mysql,项目名称:mysql-utilities,代码行数:18,代码来源:failover_console.py

示例6: raw

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def raw(self):
        """Return a context manager that enters *raw* mode. Raw mode is
        similar to *cbreak* mode, in that characters typed are immediately
        available to ``inkey()`` with one exception: the interrupt, quit,
        suspend, and flow control characters are all passed through as their
        raw character values instead of generating a signal.
        """
        if self.keyboard_fd is not None:
            # save current terminal mode,
            save_mode = termios.tcgetattr(self.keyboard_fd)
            tty.setraw(self.keyboard_fd, termios.TCSANOW)
            try:
                yield
            finally:
                # restore prior mode,
                termios.tcsetattr(self.keyboard_fd,
                                  termios.TCSAFLUSH,
                                  save_mode)
        else:
            yield 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:22,代码来源:terminal.py

示例7: wait_key

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def wait_key():
    ''' Wait for a key press on the console and return it. '''
    result = None
    if os.name == 'nt':
        import msvcrt
        result = msvcrt.getch()
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result 
开发者ID:bensauer,项目名称:saywizard,代码行数:25,代码来源:wizardofoz.py

示例8: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def __init__(self, is_gui=False):
        self.is_gui = is_gui
        if os.name == "nt" or self.is_gui:
            pass
        else:
            # Save the terminal settings
            self.file_desc = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.file_desc)
            self.old_term = termios.tcgetattr(self.file_desc)

            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.file_desc, termios.TCSAFLUSH, self.new_term)

            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:18,代码来源:keypress.py

示例9: SetTerminalRaw

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def SetTerminalRaw(fd, restore=False):
  """Set controlling terminal to raw mode.

  Set controlling terminal to raw mode and, if requested, register an
  exit handler to restore controlling terminal attribute on exit.

  Args:
    fd: file descriptor of the controlling terminal.
    restore: whether terminal mode should be restored on exit

  Returns:
    None.
  """

  if restore:
    when = termios.TCSAFLUSH
    orig_attr = termios.tcgetattr(fd)
    atexit.register(lambda: termios.tcsetattr(fd, when, orig_attr))
  tty.setraw(fd) 
开发者ID:google,项目名称:ashier,代码行数:21,代码来源:terminal.py

示例10: cleanup_console

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def cleanup_console():
        if old:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old) 
开发者ID:Obijuan,项目名称:simplez-fpga,代码行数:5,代码来源:consola_io.py

示例11: raw

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def raw(self):
        r"""
        A context manager for :func:`tty.setraw`.

        Although both :meth:`break` and :meth:`raw` modes allow each keystroke
        to be read immediately after it is pressed, Raw mode disables
        processing of input and output.

        In cbreak mode, special input characters such as ``^C`` or ``^S`` are
        interpreted by the terminal driver and excluded from the stdin stream.
        In raw mode these values are receive by the :meth:`inkey` method.

        Because output processing is not done, the newline ``'\n'`` is not
        enough, you must also print carriage return to ensure that the cursor
        is returned to the first column::

            with term.raw():
                print("printing in raw mode", end="\r\n")
        """
        if HAS_TTY and self._keyboard_fd is not None:
            # Save current terminal mode:
            save_mode = termios.tcgetattr(self._keyboard_fd)
            save_line_buffered = self._line_buffered
            tty.setraw(self._keyboard_fd, termios.TCSANOW)
            try:
                self._line_buffered = False
                yield
            finally:
                # Restore prior mode:
                termios.tcsetattr(self._keyboard_fd,
                                  termios.TCSAFLUSH,
                                  save_mode)
                self._line_buffered = save_line_buffered
        else:
            yield 
开发者ID:QData,项目名称:deepWordBug,代码行数:37,代码来源:terminal.py

示例12: cleanup

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:4,代码来源:miniterm.py

示例13: pause

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def pause(secs):
    fd = sys.stdin.fileno()

    oldterm = termios.tcgetattr(fd)
    newattr = termios.tcgetattr(fd)
    newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
    termios.tcsetattr(fd, termios.TCSANOW, newattr)

    oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)

    try:
        ctrlc = False
        paused = False
        t = secs / 0.1
        i = 0
        while i < t:
            if keypressed():
                paused = True
                break
            sleep(0.1)
            i += 1

        if paused:
            while True:
                if keypressed():
                    break
                sleep(0.1)
    except KeyboardInterrupt:
        ctrlc = True

    termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
    fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
    if ctrlc:
        sys.exit(1) 
开发者ID:KONAMI,项目名称:EM-uNetPi,代码行数:37,代码来源:Wanem.py

示例14: main

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def main(raw_args):
  parser = argparse.ArgumentParser(
      description="Use your keyboard as your phone's keyboard.")
  logging_common.AddLoggingArguments(parser)
  script_common.AddDeviceArguments(parser)
  args = parser.parse_args(raw_args)

  logging_common.InitializeLogging(args)

  devices = script_common.GetDevices(args.devices, None)
  if len(devices) > 1:
    raise MultipleDevicesError(devices)

  def next_char():
    while True:
      yield sys.stdin.read(1)

  try:
    fd = sys.stdin.fileno()

    # See man 3 termios for more info on what this is doing.
    old_attrs = termios.tcgetattr(fd)
    new_attrs = copy.deepcopy(old_attrs)
    new_attrs[tty.LFLAG] = new_attrs[tty.LFLAG] & ~(termios.ICANON)
    new_attrs[tty.CC][tty.VMIN] = 1
    new_attrs[tty.CC][tty.VTIME] = 0
    termios.tcsetattr(fd, termios.TCSAFLUSH, new_attrs)

    Keyboard(devices[0], next_char())
  finally:
    termios.tcsetattr(fd, termios.TCSAFLUSH, old_attrs)
  return 0 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:34,代码来源:keyboard.py

示例15: cleanup

# 需要导入模块: import termios [as 别名]
# 或者: from termios import TCSAFLUSH [as 别名]
def cleanup(self):
            if self.old is not None:
                termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:5,代码来源:miniterm.py


注:本文中的termios.TCSAFLUSH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。