@@ -288,22 +288,30 @@ def move_cursor_to_coords(self, *args):
288
288
return False
289
289
290
290
def keypress (self , size , key ):
291
+ if urwid .command_map [key ] in ['cursor up' , 'cursor down' ]:
292
+ # Do not handle up/down arrow, leave them for the repl.
293
+ return key
294
+
291
295
self ._bpy_may_move_cursor = True
292
296
try :
293
- # Do not handle up/down arrow, leave them for the repl.
294
- if urwid .command_map [key ] in ('cursor up' , 'cursor down' ):
295
- return key
297
+ if urwid .command_map [key ] == 'cursor max left' :
298
+ self .edit_pos = 0
299
+ elif urwid .command_map [key ] == 'cursor max right' :
300
+ self .edit_pos = len (self .get_edit_text ())
296
301
elif key == 'backspace' :
297
302
line = self .get_edit_text ()
298
303
cpos = len (line ) - self .edit_pos
299
304
if not (cpos or len (line ) % self .tab_length or line .strip ()):
300
305
self .set_edit_text (line [:- self .tab_length ])
301
- return None
306
+ else :
307
+ return urwid .Edit .keypress (self , size , key )
302
308
elif key == 'pastebin' :
303
309
# do pastebin
304
310
pass
305
- # TODO: Add in specific keypress fetching code here
306
- return urwid .Edit .keypress (self , size , key )
311
+ else :
312
+ # TODO: Add in specific keypress fetching code here
313
+ return urwid .Edit .keypress (self , size , key )
314
+ return None
307
315
finally :
308
316
self ._bpy_may_move_cursor = False
309
317
0 commit comments