Skip to content

Commit 196ddfa

Browse files
committed
Initialize dict directly
1 parent 715fb70 commit 196ddfa

File tree

1 file changed

+126
-127
lines changed

1 file changed

+126
-127
lines changed

curtsies/curtsieskeys.py

Lines changed: 126 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -8,131 +8,130 @@
88
# TODO add PAD keys hack as in bpython.cli
99

1010
# fmt: off
11-
CURTSIES_NAMES = dict([
12-
(b' ', '<SPACE>'),
13-
(b'\x1b ', '<Esc+SPACE>'),
14-
(b'\t', '<TAB>'),
15-
(b'\x1b[Z', '<Shift-TAB>'),
16-
(b'\x1b[A', '<UP>'),
17-
(b'\x1b[B', '<DOWN>'),
18-
(b'\x1b[C', '<RIGHT>'),
19-
(b'\x1b[D', '<LEFT>'),
20-
(b'\x1bOA', '<UP>'), # in issue 92 its shown these should be normal arrows,
21-
(b'\x1bOB', '<DOWN>'), # not ctrl-arrows as we previously had them.
22-
(b'\x1bOC', '<RIGHT>'),
23-
(b'\x1bOD', '<LEFT>'),
24-
25-
(b'\x1b[1;5A', '<Ctrl-UP>'),
26-
(b'\x1b[1;5B', '<Ctrl-DOWN>'),
27-
(b'\x1b[1;5C', '<Ctrl-RIGHT>'), # reported by myint
28-
(b'\x1b[1;5D', '<Ctrl-LEFT>'), # reported by myint
29-
30-
(b'\x1b[5A', '<Ctrl-UP>'), # not sure about these, someone wanted them for bpython
31-
(b'\x1b[5B', '<Ctrl-DOWN>'),
32-
(b'\x1b[5C', '<Ctrl-RIGHT>'),
33-
(b'\x1b[5D', '<Ctrl-LEFT>'),
34-
35-
(b'\x1b[1;9A', '<Esc+UP>'),
36-
(b'\x1b[1;9B', '<Esc+DOWN>'),
37-
(b'\x1b[1;9C', '<Esc+RIGHT>'),
38-
(b'\x1b[1;9D', '<Esc+LEFT>'),
39-
40-
(b'\x1b[1;10A', '<Esc+Shift-UP>'),
41-
(b'\x1b[1;10B', '<Esc+Shift-DOWN>'),
42-
(b'\x1b[1;10C', '<Esc+Shift-RIGHT>'),
43-
(b'\x1b[1;10D', '<Esc+Shift-LEFT>'),
44-
45-
(b'\x1bOP', '<F1>'),
46-
(b'\x1bOQ', '<F2>'),
47-
(b'\x1bOR', '<F3>'),
48-
(b'\x1bOS', '<F4>'),
49-
50-
# see bpython #626
51-
(b'\x1b[11~', '<F1>'),
52-
(b'\x1b[12~', '<F2>'),
53-
(b'\x1b[13~', '<F3>'),
54-
(b'\x1b[14~', '<F4>'),
55-
56-
(b'\x1b[15~', '<F5>'),
57-
(b'\x1b[17~', '<F6>'),
58-
(b'\x1b[18~', '<F7>'),
59-
(b'\x1b[19~', '<F8>'),
60-
(b'\x1b[20~', '<F9>'),
61-
(b'\x1b[21~', '<F10>'),
62-
(b'\x1b[23~', '<F11>'),
63-
(b'\x1b[24~', '<F12>'),
64-
(b'\x00', '<Ctrl-SPACE>'),
65-
(b'\x1c', '<Ctrl-\\>'),
66-
(b'\x1d', '<Ctrl-]>'),
67-
(b'\x1e', '<Ctrl-6>'),
68-
(b'\x1f', '<Ctrl-/>'),
69-
(b'\x7f', '<BACKSPACE>'), # for some folks this is ctrl-backspace apparently
70-
(b'\x1b\x7f', '<Esc+BACKSPACE>'),
71-
(b'\xff', '<Meta-BACKSPACE>'),
72-
(b'\x1b\x1b[A', '<Esc+UP>'), # uncertain about these four
73-
(b'\x1b\x1b[B', '<Esc+DOWN>'),
74-
(b'\x1b\x1b[C', '<Esc+RIGHT>'),
75-
(b'\x1b\x1b[D', '<Esc+LEFT>'),
76-
(b'\x1b', '<ESC>'),
77-
(b'\x1b[1~', '<HOME>'),
78-
(b'\x1b[4~', '<END>'),
79-
(b'\x1b\x1b[5~','<Esc+PAGEUP>'),
80-
(b'\x1b\x1b[6~','<Esc+PAGEDOWN>'),
81-
82-
(b'\x1b[H', '<HOME>'), # reported by amorozov in bpython #490
83-
(b'\x1b[F', '<END>'), # reported by amorozov in bpython #490
84-
85-
(b'\x1bOH', '<HOME>'), # reported by mixmastamyk in curtsies #78
86-
(b'\x1bOF', '<END>'), # reported by mixmastamyk in curtsies #78
87-
88-
# not fixing for back compat.
89-
# (b"\x1b[1~", u'<FIND>'), # find
90-
91-
(b"\x1b[2~", '<INSERT>'), # insert (0)
92-
(b"\x1b[3~", '<DELETE>'), # delete (.), "Execute"
93-
(b"\x1b[3;5~", '<Ctrl-DELETE>'),
94-
95-
# not fixing for back compat.
96-
# (b"\x1b[4~", u'<SELECT>'), # select
97-
98-
(b"\x1b[5~", '<PAGEUP>'), # pgup (9)
99-
(b"\x1b[6~", '<PAGEDOWN>'), # pgdown (3)
100-
(b"\x1b[7~", '<HOME>'), # home
101-
(b"\x1b[8~", '<END>'), # end
102-
(b"\x1b[OA", '<UP>'), # up (8)
103-
(b"\x1b[OB", '<DOWN>'), # down (2)
104-
(b"\x1b[OC", '<RIGHT>'), # right (6)
105-
(b"\x1b[OD", '<LEFT>'), # left (4)
106-
(b"\x1b[OF", '<END>'), # end (1)
107-
(b"\x1b[OH", '<HOME>'), # home (7)
108-
109-
# reported by cool-RR
110-
(b"\x1b[[A", '<F1>'),
111-
(b"\x1b[[B", '<F2>'),
112-
(b"\x1b[[C", '<F3>'),
113-
(b"\x1b[[D", '<F4>'),
114-
(b"\x1b[[E", '<F5>'),
115-
# cool-RR says the rest were good, see issue #99
116-
117-
#reported by alethiophile see issue #119
118-
(b"\x1b[1;3C", '<Meta-RIGHT>'), #alt-right
119-
(b"\x1b[1;3B", '<Meta-DOWN>'), #alt-down
120-
(b"\x1b[1;3D", '<Meta-LEFT>'), #alt-left
121-
(b"\x1b[1;3A", '<Meta-UP>'), #alt-up
122-
(b"\x1b[5;3~", '<Meta-PAGEUP>'), #alt-pageup
123-
(b"\x1b[6;3~", '<Meta-PAGEDOWN>'), #alt-pagedown
124-
(b"\x1b[1;3H", '<Meta-HOME>'), #alt-home
125-
(b"\x1b[1;3F", '<Meta-END>'), #alt-end
126-
(b"\x1b[1;2C", '<Shift-RIGHT>'),
127-
(b"\x1b[1;2B", '<Shift-RIGHT>'),
128-
(b"\x1b[1;2D", '<Shift-RIGHT>'),
129-
(b"\x1b[1;2A", '<Shift-RIGHT>'),
130-
(b"\x1b[3;2~", '<Shift-DELETE>'),
131-
(b"\x1b[5;2~", '<Shift-PAGEUP>'),
132-
(b"\x1b[6;2~", '<Shift-PAGEDOWN>'),
133-
(b"\x1b[1;2H", '<Shift-HOME>'),
134-
(b"\x1b[1;2F", '<Shift-END>'),
135-
#end of keys reported by alethiophile
136-
137-
])
11+
CURTSIES_NAMES = {
12+
b' ': '<SPACE>',
13+
b'\x1b ': '<Esc+SPACE>',
14+
b'\t': '<TAB>',
15+
b'\x1b[Z': '<Shift-TAB>',
16+
b'\x1b[A': '<UP>',
17+
b'\x1b[B': '<DOWN>',
18+
b'\x1b[C': '<RIGHT>',
19+
b'\x1b[D': '<LEFT>',
20+
b'\x1bOA': '<UP>', # in issue 92 its shown these should be normal arrows,
21+
b'\x1bOB': '<DOWN>', # not ctrl-arrows as we previously had them.
22+
b'\x1bOC': '<RIGHT>',
23+
b'\x1bOD': '<LEFT>',
24+
25+
b'\x1b[1;5A': '<Ctrl-UP>',
26+
b'\x1b[1;5B': '<Ctrl-DOWN>',
27+
b'\x1b[1;5C': '<Ctrl-RIGHT>', # reported by myint
28+
b'\x1b[1;5D': '<Ctrl-LEFT>', # reported by myint
29+
30+
b'\x1b[5A': '<Ctrl-UP>', # not sure about these, someone wanted them for bpython
31+
b'\x1b[5B': '<Ctrl-DOWN>',
32+
b'\x1b[5C': '<Ctrl-RIGHT>',
33+
b'\x1b[5D': '<Ctrl-LEFT>',
34+
35+
b'\x1b[1;9A': '<Esc+UP>',
36+
b'\x1b[1;9B': '<Esc+DOWN>',
37+
b'\x1b[1;9C': '<Esc+RIGHT>',
38+
b'\x1b[1;9D': '<Esc+LEFT>',
39+
40+
b'\x1b[1;10A': '<Esc+Shift-UP>',
41+
b'\x1b[1;10B': '<Esc+Shift-DOWN>',
42+
b'\x1b[1;10C': '<Esc+Shift-RIGHT>',
43+
b'\x1b[1;10D': '<Esc+Shift-LEFT>',
44+
45+
b'\x1bOP': '<F1>',
46+
b'\x1bOQ': '<F2>',
47+
b'\x1bOR': '<F3>',
48+
b'\x1bOS': '<F4>',
49+
50+
# see bpython #626
51+
b'\x1b[11~': '<F1>',
52+
b'\x1b[12~': '<F2>',
53+
b'\x1b[13~': '<F3>',
54+
b'\x1b[14~': '<F4>',
55+
56+
b'\x1b[15~': '<F5>',
57+
b'\x1b[17~': '<F6>',
58+
b'\x1b[18~': '<F7>',
59+
b'\x1b[19~': '<F8>',
60+
b'\x1b[20~': '<F9>',
61+
b'\x1b[21~': '<F10>',
62+
b'\x1b[23~': '<F11>',
63+
b'\x1b[24~': '<F12>',
64+
b'\x00': '<Ctrl-SPACE>',
65+
b'\x1c': '<Ctrl-\\>',
66+
b'\x1d': '<Ctrl-]>',
67+
b'\x1e': '<Ctrl-6>',
68+
b'\x1f': '<Ctrl-/>',
69+
b'\x7f': '<BACKSPACE>', # for some folks this is ctrl-backspace apparently
70+
b'\x1b\x7f': '<Esc+BACKSPACE>',
71+
b'\xff': '<Meta-BACKSPACE>',
72+
b'\x1b\x1b[A': '<Esc+UP>', # uncertain about these four
73+
b'\x1b\x1b[B': '<Esc+DOWN>',
74+
b'\x1b\x1b[C': '<Esc+RIGHT>',
75+
b'\x1b\x1b[D': '<Esc+LEFT>',
76+
b'\x1b': '<ESC>',
77+
b'\x1b[1~': '<HOME>',
78+
b'\x1b[4~': '<END>',
79+
b'\x1b\x1b[5~':'<Esc+PAGEUP>',
80+
b'\x1b\x1b[6~':'<Esc+PAGEDOWN>',
81+
82+
b'\x1b[H': '<HOME>', # reported by amorozov in bpython #490
83+
b'\x1b[F': '<END>', # reported by amorozov in bpython #490
84+
85+
b'\x1bOH': '<HOME>', # reported by mixmastamyk in curtsies #78
86+
b'\x1bOF': '<END>', # reported by mixmastamyk in curtsies #78
87+
88+
# not fixing for back compat.
89+
# (b"\x1b[1~": u'<FIND>', # find
90+
91+
b"\x1b[2~": '<INSERT>', # insert (0)
92+
b"\x1b[3~": '<DELETE>', # delete (.), "Execute"
93+
b"\x1b[3;5~": '<Ctrl-DELETE>',
94+
95+
# not fixing for back compat.
96+
# (b"\x1b[4~": u'<SELECT>', # select
97+
98+
b"\x1b[5~": '<PAGEUP>', # pgup (9)
99+
b"\x1b[6~": '<PAGEDOWN>', # pgdown (3)
100+
b"\x1b[7~": '<HOME>', # home
101+
b"\x1b[8~": '<END>', # end
102+
b"\x1b[OA": '<UP>', # up (8)
103+
b"\x1b[OB": '<DOWN>', # down (2)
104+
b"\x1b[OC": '<RIGHT>', # right (6)
105+
b"\x1b[OD": '<LEFT>', # left (4)
106+
b"\x1b[OF": '<END>', # end (1)
107+
b"\x1b[OH": '<HOME>', # home (7)
108+
109+
# reported by cool-RR
110+
b"\x1b[[A": '<F1>',
111+
b"\x1b[[B": '<F2>',
112+
b"\x1b[[C": '<F3>',
113+
b"\x1b[[D": '<F4>',
114+
b"\x1b[[E": '<F5>',
115+
# cool-RR says the rest were good: see issue #99
116+
117+
# reported by alethiophile see issue #119
118+
b"\x1b[1;3C": '<Meta-RIGHT>', # alt-right
119+
b"\x1b[1;3B": '<Meta-DOWN>', # alt-down
120+
b"\x1b[1;3D": '<Meta-LEFT>', # alt-left
121+
b"\x1b[1;3A": '<Meta-UP>', # alt-up
122+
b"\x1b[5;3~": '<Meta-PAGEUP>', # alt-pageup
123+
b"\x1b[6;3~": '<Meta-PAGEDOWN>', # alt-pagedown
124+
b"\x1b[1;3H": '<Meta-HOME>', # alt-home
125+
b"\x1b[1;3F": '<Meta-END>', # alt-end
126+
b"\x1b[1;2C": '<Shift-RIGHT>',
127+
b"\x1b[1;2B": '<Shift-RIGHT>',
128+
b"\x1b[1;2D": '<Shift-RIGHT>',
129+
b"\x1b[1;2A": '<Shift-RIGHT>',
130+
b"\x1b[3;2~": '<Shift-DELETE>',
131+
b"\x1b[5;2~": '<Shift-PAGEUP>',
132+
b"\x1b[6;2~": '<Shift-PAGEDOWN>',
133+
b"\x1b[1;2H": '<Shift-HOME>',
134+
b"\x1b[1;2F": '<Shift-END>',
135+
# end of keys reported by alethiophile
136+
}
138137
# fmt: on

0 commit comments

Comments
 (0)