@@ -63,6 +63,9 @@ def process_event(self, e):
6363 if e in rl_char_sequences :
6464 self .cursor_offset_in_line , self .current_line = rl_char_sequences [e ](self .cursor_offset_in_line , self .current_line )
6565 #TODO EOF on ctrl-d
66+ elif isinstance (e , events .SigIntEvent ):
67+ self .coderunner .sigint_happened = True
68+ self .repl .run_code_and_maybe_finish ()
6669 else : # add normal character
6770 logging .debug ('adding normal char %r to current line' , e )
6871 c = e if py3 else e .encode ('utf8' )
@@ -227,11 +230,6 @@ def process_event(self, e):
227230 if isinstance (e , events .RefreshRequestEvent ):
228231 assert self .coderunner .code_is_waiting
229232 self .run_code_and_maybe_finish ()
230- elif isinstance (e , events .SigIntEvent ):
231- logging .debug ('received sigint event' )
232- self .keyboard_interrupt ()
233- self .update_completion ()
234- return
235233 elif isinstance (e , events .WindowChangeEvent ):
236234 logging .debug ('window change to %d %d' , e .width , e .height )
237235 self .width , self .height = e .width , e .height
@@ -240,6 +238,12 @@ def process_event(self, e):
240238 elif self .stdin .has_focus :
241239 result = self .stdin .process_event (e )
242240
241+ elif isinstance (e , events .SigIntEvent ):
242+ logging .debug ('received sigint event' )
243+ self .keyboard_interrupt ()
244+ self .update_completion ()
245+ return
246+
243247 elif e in self .rl_char_sequences :
244248 self .cursor_offset_in_line , self ._current_line = self .rl_char_sequences [e ](self .cursor_offset_in_line , self ._current_line )
245249 self .update_completion ()
@@ -274,8 +278,6 @@ def process_event(self, e):
274278 raise NotImplementedError ()
275279 elif e in key_dispatch [self .config .suspend_key ]: #TODO
276280 raise SystemExit ()
277- elif e == "" :
278- raise KeyboardInterrupt ()
279281 elif e in ("" ,) + key_dispatch [self .config .exit_key ]:
280282 raise SystemExit ()
281283 elif e in ("\n " , "\r " , "PAD_ENTER" ):
0 commit comments