@@ -450,33 +450,21 @@ def process_key_event(self, e):
450
450
if self .status_bar .has_focus : return self .status_bar .process_event (e )
451
451
if self .stdin .has_focus : return self .stdin .process_event (e )
452
452
453
- if e in key_dispatch [self .config .toggle_file_watch_key ]:
454
- return self .toggle_file_watch ()
455
-
456
- elif e in key_dispatch [self .config .reimport_key ]:
457
- self .clear_modules_and_reevaluate ()
458
-
459
- elif (e in ("<RIGHT>" , '<Ctrl-f>' ) and self .config .curtsies_right_arrow_completion
453
+ if (e in ("<RIGHT>" , '<Ctrl-f>' ) and self .config .curtsies_right_arrow_completion
460
454
and self .cursor_offset == len (self .current_line )):
461
455
self .current_line += self .current_suggestion
462
456
self .cursor_offset = len (self .current_line )
463
457
464
- elif e in self .rl_char_sequences :
465
- self .cursor_offset , self .current_line = self .rl_char_sequences [e ](self .cursor_offset , self .current_line )
466
-
467
- # readline history commands
468
458
elif e in ("<UP>" ,) + key_dispatch [self .config .up_one_line_key ]:
469
- self .rl_history .enter (self .current_line )
470
- self ._set_current_line (self .rl_history .back (False , search = self .config .curtsies_right_arrow_completion ),
471
- reset_rl_history = False )
472
- self ._set_cursor_offset (len (self .current_line ), reset_rl_history = False )
473
-
459
+ self .up_one_line ()
474
460
elif e in ("<DOWN>" ,) + key_dispatch [self .config .down_one_line_key ]:
475
- self .rl_history .enter (self .current_line )
476
- self ._set_current_line (self .rl_history .forward (False , search = self .config .curtsies_right_arrow_completion ),
477
- reset_rl_history = False )
478
- self ._set_cursor_offset (len (self .current_line ), reset_rl_history = False )
479
-
461
+ self .down_one_line ()
462
+ elif e in self .rl_char_sequences :
463
+ self .cursor_offset , self .current_line = self .rl_char_sequences [e ](self .cursor_offset , self .current_line )
464
+ elif e in key_dispatch [self .config .reimport_key ]:
465
+ self .clear_modules_and_reevaluate ()
466
+ elif e in key_dispatch [self .config .toggle_file_watch_key ]:
467
+ return self .toggle_file_watch ()
480
468
elif e in key_dispatch [self .config .clear_screen_key ]:
481
469
self .request_paint_to_clear_screen = True
482
470
elif e in key_dispatch [self .config .show_source_key ]:
@@ -570,6 +558,18 @@ def on_control_d(self):
570
558
else :
571
559
self .current_line = self .current_line [:self .cursor_offset ] + self .current_line [self .cursor_offset + 1 :]
572
560
561
+ def up_one_line (self ):
562
+ self .rl_history .enter (self .current_line )
563
+ self ._set_current_line (self .rl_history .back (False , search = self .config .curtsies_right_arrow_completion ),
564
+ reset_rl_history = False )
565
+ self ._set_cursor_offset (len (self .current_line ), reset_rl_history = False )
566
+
567
+ def down_one_line (self ):
568
+ self .rl_history .enter (self .current_line )
569
+ self ._set_current_line (self .rl_history .forward (False , search = self .config .curtsies_right_arrow_completion ),
570
+ reset_rl_history = False )
571
+ self ._set_cursor_offset (len (self .current_line ), reset_rl_history = False )
572
+
573
573
def process_simple_keypress (self , e ):
574
574
if e in (u"<Ctrl-j>" , u"<Ctrl-m>" , u"<PADENTER>" ):
575
575
self .on_enter ()
0 commit comments