Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/selection.py: 75%
20 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
1"""
2Data structures for the selection.
3"""
4from __future__ import annotations
6from enum import Enum
8__all__ = [
9 "SelectionType",
10 "PasteMode",
11 "SelectionState",
12]
15class SelectionType(Enum):
16 """
17 Type of selection.
18 """
20 #: Characters. (Visual in Vi.)
21 CHARACTERS = "CHARACTERS"
23 #: Whole lines. (Visual-Line in Vi.)
24 LINES = "LINES"
26 #: A block selection. (Visual-Block in Vi.)
27 BLOCK = "BLOCK"
30class PasteMode(Enum):
31 EMACS = "EMACS" # Yank like emacs.
32 VI_AFTER = "VI_AFTER" # When pressing 'p' in Vi.
33 VI_BEFORE = "VI_BEFORE" # When pressing 'P' in Vi.
36class SelectionState:
37 """
38 State of the current selection.
40 :param original_cursor_position: int
41 :param type: :class:`~.SelectionType`
42 """
44 def __init__(
45 self,
46 original_cursor_position: int = 0,
47 type: SelectionType = SelectionType.CHARACTERS,
48 ) -> None:
49 self.original_cursor_position = original_cursor_position
50 self.type = type
51 self.shift_mode = False
53 def enter_shift_mode(self) -> None:
54 self.shift_mode = True
56 def __repr__(self) -> str:
57 return "{}(original_cursor_position={!r}, type={!r})".format(
58 self.__class__.__name__,
59 self.original_cursor_position,
60 self.type,
61 )