Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/prompt_toolkit/keys.py: 100%

166 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-20 06:09 +0000

1from __future__ import annotations 

2 

3from enum import Enum 

4 

5__all__ = [ 

6 "Keys", 

7 "ALL_KEYS", 

8] 

9 

10 

11class Keys(str, Enum): 

12 """ 

13 List of keys for use in key bindings. 

14 

15 Note that this is an "StrEnum", all values can be compared against 

16 strings. 

17 """ 

18 

19 value: str 

20 

21 Escape = "escape" # Also Control-[ 

22 ShiftEscape = "s-escape" 

23 

24 ControlAt = "c-@" # Also Control-Space. 

25 

26 ControlA = "c-a" 

27 ControlB = "c-b" 

28 ControlC = "c-c" 

29 ControlD = "c-d" 

30 ControlE = "c-e" 

31 ControlF = "c-f" 

32 ControlG = "c-g" 

33 ControlH = "c-h" 

34 ControlI = "c-i" # Tab 

35 ControlJ = "c-j" # Newline 

36 ControlK = "c-k" 

37 ControlL = "c-l" 

38 ControlM = "c-m" # Carriage return 

39 ControlN = "c-n" 

40 ControlO = "c-o" 

41 ControlP = "c-p" 

42 ControlQ = "c-q" 

43 ControlR = "c-r" 

44 ControlS = "c-s" 

45 ControlT = "c-t" 

46 ControlU = "c-u" 

47 ControlV = "c-v" 

48 ControlW = "c-w" 

49 ControlX = "c-x" 

50 ControlY = "c-y" 

51 ControlZ = "c-z" 

52 

53 Control1 = "c-1" 

54 Control2 = "c-2" 

55 Control3 = "c-3" 

56 Control4 = "c-4" 

57 Control5 = "c-5" 

58 Control6 = "c-6" 

59 Control7 = "c-7" 

60 Control8 = "c-8" 

61 Control9 = "c-9" 

62 Control0 = "c-0" 

63 

64 ControlShift1 = "c-s-1" 

65 ControlShift2 = "c-s-2" 

66 ControlShift3 = "c-s-3" 

67 ControlShift4 = "c-s-4" 

68 ControlShift5 = "c-s-5" 

69 ControlShift6 = "c-s-6" 

70 ControlShift7 = "c-s-7" 

71 ControlShift8 = "c-s-8" 

72 ControlShift9 = "c-s-9" 

73 ControlShift0 = "c-s-0" 

74 

75 ControlBackslash = "c-\\" 

76 ControlSquareClose = "c-]" 

77 ControlCircumflex = "c-^" 

78 ControlUnderscore = "c-_" 

79 

80 Left = "left" 

81 Right = "right" 

82 Up = "up" 

83 Down = "down" 

84 Home = "home" 

85 End = "end" 

86 Insert = "insert" 

87 Delete = "delete" 

88 PageUp = "pageup" 

89 PageDown = "pagedown" 

90 

91 ControlLeft = "c-left" 

92 ControlRight = "c-right" 

93 ControlUp = "c-up" 

94 ControlDown = "c-down" 

95 ControlHome = "c-home" 

96 ControlEnd = "c-end" 

97 ControlInsert = "c-insert" 

98 ControlDelete = "c-delete" 

99 ControlPageUp = "c-pageup" 

100 ControlPageDown = "c-pagedown" 

101 

102 ShiftLeft = "s-left" 

103 ShiftRight = "s-right" 

104 ShiftUp = "s-up" 

105 ShiftDown = "s-down" 

106 ShiftHome = "s-home" 

107 ShiftEnd = "s-end" 

108 ShiftInsert = "s-insert" 

109 ShiftDelete = "s-delete" 

110 ShiftPageUp = "s-pageup" 

111 ShiftPageDown = "s-pagedown" 

112 

113 ControlShiftLeft = "c-s-left" 

114 ControlShiftRight = "c-s-right" 

115 ControlShiftUp = "c-s-up" 

116 ControlShiftDown = "c-s-down" 

117 ControlShiftHome = "c-s-home" 

118 ControlShiftEnd = "c-s-end" 

119 ControlShiftInsert = "c-s-insert" 

120 ControlShiftDelete = "c-s-delete" 

121 ControlShiftPageUp = "c-s-pageup" 

122 ControlShiftPageDown = "c-s-pagedown" 

123 

124 BackTab = "s-tab" # shift + tab 

125 

126 F1 = "f1" 

127 F2 = "f2" 

128 F3 = "f3" 

129 F4 = "f4" 

130 F5 = "f5" 

131 F6 = "f6" 

132 F7 = "f7" 

133 F8 = "f8" 

134 F9 = "f9" 

135 F10 = "f10" 

136 F11 = "f11" 

137 F12 = "f12" 

138 F13 = "f13" 

139 F14 = "f14" 

140 F15 = "f15" 

141 F16 = "f16" 

142 F17 = "f17" 

143 F18 = "f18" 

144 F19 = "f19" 

145 F20 = "f20" 

146 F21 = "f21" 

147 F22 = "f22" 

148 F23 = "f23" 

149 F24 = "f24" 

150 

151 ControlF1 = "c-f1" 

152 ControlF2 = "c-f2" 

153 ControlF3 = "c-f3" 

154 ControlF4 = "c-f4" 

155 ControlF5 = "c-f5" 

156 ControlF6 = "c-f6" 

157 ControlF7 = "c-f7" 

158 ControlF8 = "c-f8" 

159 ControlF9 = "c-f9" 

160 ControlF10 = "c-f10" 

161 ControlF11 = "c-f11" 

162 ControlF12 = "c-f12" 

163 ControlF13 = "c-f13" 

164 ControlF14 = "c-f14" 

165 ControlF15 = "c-f15" 

166 ControlF16 = "c-f16" 

167 ControlF17 = "c-f17" 

168 ControlF18 = "c-f18" 

169 ControlF19 = "c-f19" 

170 ControlF20 = "c-f20" 

171 ControlF21 = "c-f21" 

172 ControlF22 = "c-f22" 

173 ControlF23 = "c-f23" 

174 ControlF24 = "c-f24" 

175 

176 # Matches any key. 

177 Any = "<any>" 

178 

179 # Special. 

180 ScrollUp = "<scroll-up>" 

181 ScrollDown = "<scroll-down>" 

182 

183 CPRResponse = "<cursor-position-response>" 

184 Vt100MouseEvent = "<vt100-mouse-event>" 

185 WindowsMouseEvent = "<windows-mouse-event>" 

186 BracketedPaste = "<bracketed-paste>" 

187 

188 SIGINT = "<sigint>" 

189 

190 # For internal use: key which is ignored. 

191 # (The key binding for this key should not do anything.) 

192 Ignore = "<ignore>" 

193 

194 # Some 'Key' aliases (for backwards-compatibility). 

195 ControlSpace = ControlAt 

196 Tab = ControlI 

197 Enter = ControlM 

198 Backspace = ControlH 

199 

200 # ShiftControl was renamed to ControlShift in 

201 # 888fcb6fa4efea0de8333177e1bbc792f3ff3c24 (20 Feb 2020). 

202 ShiftControlLeft = ControlShiftLeft 

203 ShiftControlRight = ControlShiftRight 

204 ShiftControlHome = ControlShiftHome 

205 ShiftControlEnd = ControlShiftEnd 

206 

207 

208ALL_KEYS: list[str] = [k.value for k in Keys] 

209 

210 

211# Aliases. 

212KEY_ALIASES: dict[str, str] = { 

213 "backspace": "c-h", 

214 "c-space": "c-@", 

215 "enter": "c-m", 

216 "tab": "c-i", 

217 # ShiftControl was renamed to ControlShift. 

218 "s-c-left": "c-s-left", 

219 "s-c-right": "c-s-right", 

220 "s-c-home": "c-s-home", 

221 "s-c-end": "c-s-end", 

222}