aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/prompt_toolkit/keys.py
blob: ffa11f813e26fe43adeecda4e921414fa865ac2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from __future__ import unicode_literals 
 
__all__ = ( 
    'Key', 
    'Keys', 
) 
 
 
class Key(object): 
    def __init__(self, name): 
 
        #: Descriptive way of writing keys in configuration files. e.g. <C-A> 
        #: for ``Control-A``. 
        self.name = name 
 
    def __repr__(self): 
        return '%s(%r)' % (self.__class__.__name__, self.name) 
 
 
class Keys(object): 
    Escape = Key('<Escape>') 
 
    ControlA = Key('<C-A>') 
    ControlB = Key('<C-B>') 
    ControlC = Key('<C-C>') 
    ControlD = Key('<C-D>') 
    ControlE = Key('<C-E>') 
    ControlF = Key('<C-F>') 
    ControlG = Key('<C-G>') 
    ControlH = Key('<C-H>') 
    ControlI = Key('<C-I>')  # Tab 
    ControlJ = Key('<C-J>')  # Enter 
    ControlK = Key('<C-K>') 
    ControlL = Key('<C-L>') 
    ControlM = Key('<C-M>')  # Enter 
    ControlN = Key('<C-N>') 
    ControlO = Key('<C-O>') 
    ControlP = Key('<C-P>') 
    ControlQ = Key('<C-Q>') 
    ControlR = Key('<C-R>') 
    ControlS = Key('<C-S>') 
    ControlT = Key('<C-T>') 
    ControlU = Key('<C-U>') 
    ControlV = Key('<C-V>') 
    ControlW = Key('<C-W>') 
    ControlX = Key('<C-X>') 
    ControlY = Key('<C-Y>') 
    ControlZ = Key('<C-Z>') 
 
    ControlSpace       = Key('<C-Space>') 
    ControlBackslash   = Key('<C-Backslash>') 
    ControlSquareClose = Key('<C-SquareClose>') 
    ControlCircumflex  = Key('<C-Circumflex>') 
    ControlUnderscore  = Key('<C-Underscore>') 
    ControlLeft        = Key('<C-Left>') 
    ControlRight       = Key('<C-Right>') 
    ControlUp          = Key('<C-Up>') 
    ControlDown        = Key('<C-Down>') 
 
    Up          = Key('<Up>') 
    Down        = Key('<Down>') 
    Right       = Key('<Right>') 
    Left        = Key('<Left>') 

    ShiftLeft   = Key('<ShiftLeft>')
    ShiftUp     = Key('<ShiftUp>')
    ShiftDown   = Key('<ShiftDown>')
    ShiftRight  = Key('<ShiftRight>')

    Home        = Key('<Home>') 
    End         = Key('<End>') 
    Delete      = Key('<Delete>') 
    ShiftDelete = Key('<ShiftDelete>') 
    ControlDelete = Key('<C-Delete>')
    PageUp      = Key('<PageUp>') 
    PageDown    = Key('<PageDown>') 
    BackTab     = Key('<BackTab>')  # shift + tab 
    Insert      = Key('<Insert>') 
    Backspace   = Key('<Backspace>')
 
    # Aliases.
    Tab         = ControlI 
    Enter       = ControlJ
        # XXX: Actually Enter equals ControlM, not ControlJ,
        #      However, in prompt_toolkit, we made the mistake of translating
        #      \r into \n during the input, so everyone is now handling the
        #      enter key by binding ControlJ.
 
        #      From now on, it's better to bind `Keys.Enter` everywhere,
        #      because that's future compatible, and will still work when we
        #      stop replacing \r by \n.

    F1 = Key('<F1>') 
    F2 = Key('<F2>') 
    F3 = Key('<F3>') 
    F4 = Key('<F4>') 
    F5 = Key('<F5>') 
    F6 = Key('<F6>') 
    F7 = Key('<F7>') 
    F8 = Key('<F8>') 
    F9 = Key('<F9>') 
    F10 = Key('<F10>') 
    F11 = Key('<F11>') 
    F12 = Key('<F12>') 
    F13 = Key('<F13>') 
    F14 = Key('<F14>') 
    F15 = Key('<F15>') 
    F16 = Key('<F16>') 
    F17 = Key('<F17>') 
    F18 = Key('<F18>') 
    F19 = Key('<F19>') 
    F20 = Key('<F20>') 
    F21 = Key('<F21>')
    F22 = Key('<F22>')
    F23 = Key('<F23>')
    F24 = Key('<F24>')
 
    # Matches any key. 
    Any = Key('<Any>') 
 
    # Special 
    CPRResponse = Key('<Cursor-Position-Response>') 
    Vt100MouseEvent = Key('<Vt100-Mouse-Event>') 
    WindowsMouseEvent = Key('<Windows-Mouse-Event>') 
    BracketedPaste = Key('<Bracketed-Paste>') 

    # Key which is ignored. (The key binding for this key should not do
    # anything.)
    Ignore = Key('<Ignore>')