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: After every command, make sure that if we are in Vi navigation mode, we
  never put the cursor after the last character of a line. (Unless it's
  an empty line.)
docstr_tok: ["After","every","command",",","make","sure","that","if","we","are","in","Vi","navigation","mode",",","we","never","put","the","cursor","after","the","last","character","of","a","line",".","(","Unless","it's","an","empty","line",".",")"]
code: def _fix_vi_cursor_position(self, event):
      """
      After every command, make sure that if we are in Vi navigation mode, we
      never put the cursor after the last character of a line. (Unless it's
      an empty line.)
      """
      cli = self._cli_ref()
      if cli:
          buff = cli.current_buffer
          preferred_column = buff.preferred_column
  
          if (
              ViNavigationMode()(event.cli)
              and buff.document.is_cursor_at_the_end_of_line
              and len(buff.document.current_line) > 0
          ):
              buff.cursor_position -= 1
  
              # Set the preferred_column for arrow up/down again.
              # (This was cleared after changing the cursor position.)
              buff.preferred_column = preferred_column
  
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 12 for calling the InputProcessor obj's underlying member method code with example usage: obj._fix_vi_cursor_position(event) without return types