selection.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. Data structures for the selection.
  3. """
  4. from __future__ import unicode_literals
  5. __all__ = (
  6. 'SelectionType',
  7. 'PasteMode',
  8. 'SelectionState',
  9. )
  10. class SelectionType(object):
  11. """
  12. Type of selection.
  13. """
  14. #: Characters. (Visual in Vi.)
  15. CHARACTERS = 'CHARACTERS'
  16. #: Whole lines. (Visual-Line in Vi.)
  17. LINES = 'LINES'
  18. #: A block selection. (Visual-Block in Vi.)
  19. BLOCK = 'BLOCK'
  20. class PasteMode(object):
  21. EMACS = 'EMACS' # Yank like emacs.
  22. VI_AFTER = 'VI_AFTER' # When pressing 'p' in Vi.
  23. VI_BEFORE = 'VI_BEFORE' # When pressing 'P' in Vi.
  24. class SelectionState(object):
  25. """
  26. State of the current selection.
  27. :param original_cursor_position: int
  28. :param type: :class:`~.SelectionType`
  29. """
  30. def __init__(self, original_cursor_position=0, type=SelectionType.CHARACTERS):
  31. self.original_cursor_position = original_cursor_position
  32. self.type = type
  33. def __repr__(self):
  34. return '%s(original_cursor_position=%r, type=%r)' % (
  35. self.__class__.__name__,
  36. self.original_cursor_position, self.type)