65
65
#
66
66
CTRL_ARROW_KEYCODE = {
67
67
# for xterm, gnome-terminal, xfce terminal, etc.
68
- '\033 [1;5D' : 'ctrl left' ,
69
- '\033 [1;5C' : 'ctrl right' ,
68
+ b '\033 [1;5D' : 'ctrl left' ,
69
+ b '\033 [1;5C' : 'ctrl right' ,
70
70
# for rxvt
71
- '\033 Od' : 'ctrl left' ,
72
- '\033 Oc' : 'ctrl right' ,
71
+ b '\033 Od' : 'ctrl left' ,
72
+ b '\033 Oc' : 'ctrl right' ,
73
73
}
74
74
75
75
def general_keycodes ():
@@ -120,6 +120,7 @@ def insert(self, event):
120
120
121
121
def push (self , char ):
122
122
ord_char = char if isinstance (char , int ) else ord (char )
123
+ char = bytes (bytearray ((ord_char ,)))
123
124
self .buf .append (ord_char )
124
125
if char in self .k :
125
126
if self .k is self .ck :
@@ -133,13 +134,13 @@ def push(self, char):
133
134
self .insert (Event ('key' , k , self .flush_buf ()))
134
135
self .k = self .ck
135
136
136
- elif self .buf and self .buf [0 ] == 033 : # 033 == escape
137
+ elif self .buf and self .buf [0 ] == 27 : # escape
137
138
# escape sequence not recognized by our keymap: propagate it
138
139
# outside so that i can be recognized as an M-... key (see also
139
140
# the docstring in keymap.py, in particular the line \\E.
140
141
trace ('unrecognized escape sequence, propagating...' )
141
142
self .k = self .ck
142
- self .insert (Event ('key' , '\033 ' , '\033 ' ))
143
+ self .insert (Event ('key' , '\033 ' , bytearray ( b '\033 ') ))
143
144
for c in self .flush_buf ()[1 :]:
144
145
self .push (chr (c ))
145
146
0 commit comments