(self, blocking)
Interpret all key events.
Interpret all key events.
Interpret all key events .
def _fill_buffer(self, blocking):
        """Interpret all key events."""
        while True:
            nevents = wintypes.DWORD()
            _GetNumberOfConsoleInputEvents(self._hstdin, byref(nevents))
            if not nevents.value and not blocking:
                return
            # only ever block on first loop
            blocking = False
            if nevents.value > 0:
                input_buffer = (INPUT_RECORD * nevents.value)()
                nread = wintypes.DWORD()
                _ReadConsoleInputW(
                    self._hstdin,
                    cast(input_buffer, POINTER(INPUT_RECORD)),
                    nevents.value, byref(nread)
                )
                for event in input_buffer:
                    if event.EventType != 1: # KEY_EVENT
                        continue
                    char, key, mods = self._translate_event(event)
                    if char or key:
                        self._input_buffer.append((char, key, mods))
                        if char == u'\x1a':
                            # ctrl-z is end of input on windows console
                            return
                        if self._echo:
                            _ConsoleWriter.write(self._hstdout, char.replace(u'\r', u'\n'))
            time.sleep(0.01)
def _fill_buffer ( self , blocking ) : while True : nevents = wintypes . DWORD ( ) _GetNumberOfConsoleInputEvents ( self . _hstdin , byref ( nevents ) ) if not nevents . value and not blocking : return # only ever block on first loop blocking = False if nevents . value > 0 : input_buffer = ( INPUT_RECORD * nevents . value ) ( ) nread = wintypes . DWORD ( ) _ReadConsoleInputW ( self . _hstdin , cast ( input_buffer , POINTER ( INPUT_RECORD ) ) , nevents . value , byref ( nread ) ) for event in input_buffer : if event . EventType != 1 : # KEY_EVENT continue char , key , mods = self . _translate_event ( event ) if char or key : self . _input_buffer . append ( ( char , key , mods ) ) if char == u'\x1a' : # ctrl-z is end of input on windows console return if self . _echo : _ConsoleWriter . write ( self . _hstdout , char . replace ( u'\r' , u'\n' ) ) time . sleep ( 0.01 )