class_docstr: Statemachine that receives :class:`KeyPress` instances and according to the
  key bindings in the given :class:`Registry`, calls the matching handlers.
  
  ::
  
      p = InputProcessor(registry)
  
      # Send keys into the processor.
      p.feed(KeyPress(Keys.ControlX, ''))
      p.feed(KeyPress(Keys.ControlC, '')
  
      # Process all the keys in the queue.
      p.process_keys()
  
      # Now the ControlX-ControlC callback will be called if this sequence is
      # registered in the registry.
  
  :param registry: `BaseRegistry` instance.
  :param cli_ref: weakref to `CommandLineInterface`.
class_docstr_tok: ["Statemachine","that","receives",":","class",":","`","KeyPress","`","instances","and","according","to","the","key","bindings","in","the","given",":","class",":","`","Registry","`",",","calls","the","matching","handlers",".",":",":","p","=","InputProcessor","(","registry",")","#","Send","keys","into","the","processor",".","p.feed","(","KeyPress","(","Keys.ControlX",",","'\u0018","'",")",")","p.feed","(","KeyPress","(","Keys.ControlC",",","'\u0003","'",")","#","Process","all","the","keys","in","the","queue",".","p.process_keys","(",")","#","Now","the","ControlX-ControlC","callback","will","be","called","if","this","sequence","is","#","registered","in","the","registry",".",":","param","registry",":","`","BaseRegistry","`","instance",".",":","param","cli_ref",":","weakref","to","`","CommandLineInterface","`","."]
docstr: Coroutine implementing the key match algorithm. Key strokes are sent
  into this generator, and it calls the appropriate handlers.
docstr_tok: ["Coroutine","implementing","the","key","match","algorithm",".","Key","strokes","are","sent","into","this","generator",",","and","it","calls","the","appropriate","handlers","."]
code: def _process(self):
      """
      Coroutine implementing the key match algorithm. Key strokes are sent
      into this generator, and it calls the appropriate handlers.
      """
      buffer = self.key_buffer
      retry = False
  
      while True:
          if retry:
              retry = False
          else:
              buffer.append((yield))
  
          # If we have some key presses, check for matches.
          if buffer:
              is_prefix_of_longer_match = (
                  self._is_prefix_of_longer_match(buffer)
              )
              matches = self._get_matches(buffer)
  
              # When eager matches were found, give priority to them and also
              # ignore all the longer matches.
              eager_matches = [
                  m for m in matches if m.eager(self._cli_ref())
              ]
  
              if eager_matches:
                  matches = eager_matches
                  is_prefix_of_longer_match = False
  
              # Exact matches found, call handler.
              if not is_prefix_of_longer_match and matches:
                  self._call_handler(
                      matches[-1], key_sequence=buffer[:]
                  )
                  del buffer[:]  # Keep reference.
  
              # No match found.
              elif not is_prefix_of_longer_match and not matches:
                  retry = True
                  found = False
  
                  # Loop over the input, try longest match first and shift.
                  for i in range(len(buffer), 0, -1):
                      matches = self._get_matches(buffer[:i])
                      if matches:
                          self._call_handler(
                              matches[-1], key_sequence=buffer[:i]
                          )
                          del buffer[:i]
                          found = True
                          break
  
                  if not found:
                      del buffer[:1]
  
imports: from __future__ import unicode_literals
  from prompt_toolkit.buffer import EditReadOnlyBuffer
  from prompt_toolkit.filters.cli import ViNavigationMode
  from prompt_toolkit.keys import Keys, Key
  from prompt_toolkit.utils import Event
  from .registry import BaseRegistry
  from collections import deque
  from six.moves import range
  import weakref
  import six
label_desc: Use image node_id 8 for calling the InputProcessor obj's underlying member method code with example usage: obj._process() without return types