@@ -288,22 +288,30 @@ def move_cursor_to_coords(self, *args):
288288 return False
289289
290290 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+
291295 self ._bpy_may_move_cursor = True
292296 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 ())
296301 elif key == 'backspace' :
297302 line = self .get_edit_text ()
298303 cpos = len (line ) - self .edit_pos
299304 if not (cpos or len (line ) % self .tab_length or line .strip ()):
300305 self .set_edit_text (line [:- self .tab_length ])
301- return None
306+ else :
307+ return urwid .Edit .keypress (self , size , key )
302308 elif key == 'pastebin' :
303309 # do pastebin
304310 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
307315 finally :
308316 self ._bpy_may_move_cursor = False
309317
0 commit comments