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

167 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 06:07 +0000

1from __future__ import annotations 

2 

3from enum import Enum 

4from typing import Dict, List 

5 

6__all__ = [ 

7 "Keys", 

8 "ALL_KEYS", 

9] 

10 

11 

12class Keys(str, Enum): 

13 """ 

14 List of keys for use in key bindings. 

15 

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

17 strings. 

18 """ 

19 

20 value: str 

21 

22 Escape = "escape" # Also Control-[ 

23 ShiftEscape = "s-escape" 

24 

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

26 

27 ControlA = "c-a" 

28 ControlB = "c-b" 

29 ControlC = "c-c" 

30 ControlD = "c-d" 

31 ControlE = "c-e" 

32 ControlF = "c-f" 

33 ControlG = "c-g" 

34 ControlH = "c-h" 

35 ControlI = "c-i" # Tab 

36 ControlJ = "c-j" # Newline 

37 ControlK = "c-k" 

38 ControlL = "c-l" 

39 ControlM = "c-m" # Carriage return 

40 ControlN = "c-n" 

41 ControlO = "c-o" 

42 ControlP = "c-p" 

43 ControlQ = "c-q" 

44 ControlR = "c-r" 

45 ControlS = "c-s" 

46 ControlT = "c-t" 

47 ControlU = "c-u" 

48 ControlV = "c-v" 

49 ControlW = "c-w" 

50 ControlX = "c-x" 

51 ControlY = "c-y" 

52 ControlZ = "c-z" 

53 

54 Control1 = "c-1" 

55 Control2 = "c-2" 

56 Control3 = "c-3" 

57 Control4 = "c-4" 

58 Control5 = "c-5" 

59 Control6 = "c-6" 

60 Control7 = "c-7" 

61 Control8 = "c-8" 

62 Control9 = "c-9" 

63 Control0 = "c-0" 

64 

65 ControlShift1 = "c-s-1" 

66 ControlShift2 = "c-s-2" 

67 ControlShift3 = "c-s-3" 

68 ControlShift4 = "c-s-4" 

69 ControlShift5 = "c-s-5" 

70 ControlShift6 = "c-s-6" 

71 ControlShift7 = "c-s-7" 

72 ControlShift8 = "c-s-8" 

73 ControlShift9 = "c-s-9" 

74 ControlShift0 = "c-s-0" 

75 

76 ControlBackslash = "c-\\" 

77 ControlSquareClose = "c-]" 

78 ControlCircumflex = "c-^" 

79 ControlUnderscore = "c-_" 

80 

81 Left = "left" 

82 Right = "right" 

83 Up = "up" 

84 Down = "down" 

85 Home = "home" 

86 End = "end" 

87 Insert = "insert" 

88 Delete = "delete" 

89 PageUp = "pageup" 

90 PageDown = "pagedown" 

91 

92 ControlLeft = "c-left" 

93 ControlRight = "c-right" 

94 ControlUp = "c-up" 

95 ControlDown = "c-down" 

96 ControlHome = "c-home" 

97 ControlEnd = "c-end" 

98 ControlInsert = "c-insert" 

99 ControlDelete = "c-delete" 

100 ControlPageUp = "c-pageup" 

101 ControlPageDown = "c-pagedown" 

102 

103 ShiftLeft = "s-left" 

104 ShiftRight = "s-right" 

105 ShiftUp = "s-up" 

106 ShiftDown = "s-down" 

107 ShiftHome = "s-home" 

108 ShiftEnd = "s-end" 

109 ShiftInsert = "s-insert" 

110 ShiftDelete = "s-delete" 

111 ShiftPageUp = "s-pageup" 

112 ShiftPageDown = "s-pagedown" 

113 

114 ControlShiftLeft = "c-s-left" 

115 ControlShiftRight = "c-s-right" 

116 ControlShiftUp = "c-s-up" 

117 ControlShiftDown = "c-s-down" 

118 ControlShiftHome = "c-s-home" 

119 ControlShiftEnd = "c-s-end" 

120 ControlShiftInsert = "c-s-insert" 

121 ControlShiftDelete = "c-s-delete" 

122 ControlShiftPageUp = "c-s-pageup" 

123 ControlShiftPageDown = "c-s-pagedown" 

124 

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

126 

127 F1 = "f1" 

128 F2 = "f2" 

129 F3 = "f3" 

130 F4 = "f4" 

131 F5 = "f5" 

132 F6 = "f6" 

133 F7 = "f7" 

134 F8 = "f8" 

135 F9 = "f9" 

136 F10 = "f10" 

137 F11 = "f11" 

138 F12 = "f12" 

139 F13 = "f13" 

140 F14 = "f14" 

141 F15 = "f15" 

142 F16 = "f16" 

143 F17 = "f17" 

144 F18 = "f18" 

145 F19 = "f19" 

146 F20 = "f20" 

147 F21 = "f21" 

148 F22 = "f22" 

149 F23 = "f23" 

150 F24 = "f24" 

151 

152 ControlF1 = "c-f1" 

153 ControlF2 = "c-f2" 

154 ControlF3 = "c-f3" 

155 ControlF4 = "c-f4" 

156 ControlF5 = "c-f5" 

157 ControlF6 = "c-f6" 

158 ControlF7 = "c-f7" 

159 ControlF8 = "c-f8" 

160 ControlF9 = "c-f9" 

161 ControlF10 = "c-f10" 

162 ControlF11 = "c-f11" 

163 ControlF12 = "c-f12" 

164 ControlF13 = "c-f13" 

165 ControlF14 = "c-f14" 

166 ControlF15 = "c-f15" 

167 ControlF16 = "c-f16" 

168 ControlF17 = "c-f17" 

169 ControlF18 = "c-f18" 

170 ControlF19 = "c-f19" 

171 ControlF20 = "c-f20" 

172 ControlF21 = "c-f21" 

173 ControlF22 = "c-f22" 

174 ControlF23 = "c-f23" 

175 ControlF24 = "c-f24" 

176 

177 # Matches any key. 

178 Any = "<any>" 

179 

180 # Special. 

181 ScrollUp = "<scroll-up>" 

182 ScrollDown = "<scroll-down>" 

183 

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

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

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

187 BracketedPaste = "<bracketed-paste>" 

188 

189 SIGINT = "<sigint>" 

190 

191 # For internal use: key which is ignored. 

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

193 Ignore = "<ignore>" 

194 

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

196 ControlSpace = ControlAt 

197 Tab = ControlI 

198 Enter = ControlM 

199 Backspace = ControlH 

200 

201 # ShiftControl was renamed to ControlShift in 

202 # 888fcb6fa4efea0de8333177e1bbc792f3ff3c24 (20 Feb 2020). 

203 ShiftControlLeft = ControlShiftLeft 

204 ShiftControlRight = ControlShiftRight 

205 ShiftControlHome = ControlShiftHome 

206 ShiftControlEnd = ControlShiftEnd 

207 

208 

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

210 

211 

212# Aliases. 

213KEY_ALIASES: dict[str, str] = { 

214 "backspace": "c-h", 

215 "c-space": "c-@", 

216 "enter": "c-m", 

217 "tab": "c-i", 

218 # ShiftControl was renamed to ControlShift. 

219 "s-c-left": "c-s-left", 

220 "s-c-right": "c-s-right", 

221 "s-c-home": "c-s-home", 

222 "s-c-end": "c-s-end", 

223}