6565#
6666CTRL_ARROW_KEYCODE = {
6767 # 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' ,
7070 # for rxvt
71- '\033 Od' : 'ctrl left' ,
72- '\033 Oc' : 'ctrl right' ,
71+ b '\033 Od' : 'ctrl left' ,
72+ b '\033 Oc' : 'ctrl right' ,
7373}
7474
7575def general_keycodes ():
@@ -120,6 +120,7 @@ def insert(self, event):
120120
121121 def push (self , char ):
122122 ord_char = char if isinstance (char , int ) else ord (char )
123+ char = bytes (bytearray ((ord_char ,)))
123124 self .buf .append (ord_char )
124125 if char in self .k :
125126 if self .k is self .ck :
@@ -133,13 +134,13 @@ def push(self, char):
133134 self .insert (Event ('key' , k , self .flush_buf ()))
134135 self .k = self .ck
135136
136- elif self .buf and self .buf [0 ] == 033 : # 033 == escape
137+ elif self .buf and self .buf [0 ] == 27 : # escape
137138 # escape sequence not recognized by our keymap: propagate it
138139 # outside so that i can be recognized as an M-... key (see also
139140 # the docstring in keymap.py, in particular the line \\E.
140141 trace ('unrecognized escape sequence, propagating...' )
141142 self .k = self .ck
142- self .insert (Event ('key' , '\033 ' , '\033 ' ))
143+ self .insert (Event ('key' , '\033 ' , bytearray ( b '\033 ') ))
143144 for c in self .flush_buf ()[1 :]:
144145 self .push (chr (c ))
145146
0 commit comments