@@ -65,17 +65,18 @@ def process_event(self, e):
6565 self .repl .run_code_and_maybe_finish ()
6666 elif e in ["\x1b " ]: #ESC
6767 pass
68- else : # add normal character
69- self .add_input_character (e )
70-
71- if self .current_line .endswith (("\n " , "\r " )):
68+ elif e in ["\n " , "\r " ]:
7269 line = self .current_line
73- self .repl .send_to_stdin (line )
70+ self .repl .send_to_stdin (line + ' \n ' )
7471 self .has_focus = False
7572 self .current_line = ''
7673 self .cursor_offset_in_line = 0
77- #self.repl.coderunner.run_code(for_code=line)
7874 self .repl .run_code_and_maybe_finish (for_code = line )
75+ else : # add normal character
76+ self .add_input_character (e )
77+
78+ if self .current_line .endswith (("\n " , "\r " )):
79+ pass
7980 else :
8081 self .repl .send_to_stdin (self .current_line )
8182
@@ -270,14 +271,8 @@ def process_event(self, e):
270271
271272 elif self .status_bar .has_focus :
272273 return self .status_bar .process_event (e )
273- elif self .stdin .has_focus :
274- return self .stdin .process_event (e )
275274
276- elif isinstance (e , events .SigIntEvent ):
277- logging .debug ('received sigint event' )
278- self .keyboard_interrupt ()
279- self .update_completion ()
280- return
275+ # handles paste events for both stdin and repl
281276 elif isinstance (e , events .PasteEvent ):
282277 ctrl_char = compress_paste_event (e )
283278 if ctrl_char is not None :
@@ -290,6 +285,15 @@ def process_event(self, e):
290285 self .process_simple_event (ee )
291286 self .update_completion ()
292287
288+ elif self .stdin .has_focus :
289+ return self .stdin .process_event (e )
290+
291+ elif isinstance (e , events .SigIntEvent ):
292+ logging .debug ('received sigint event' )
293+ self .keyboard_interrupt ()
294+ self .update_completion ()
295+ return
296+
293297 elif e in self .rl_char_sequences :
294298 self .cursor_offset_in_line , self ._current_line = self .rl_char_sequences [e ](self .cursor_offset_in_line , self ._current_line )
295299 self .update_completion ()
@@ -601,7 +605,7 @@ def send_to_stderr(self, error):
601605
602606 def send_to_stdin (self , line ):
603607 if line .endswith ('\n ' ):
604- self .display_lines .extend (paint .display_linize (self .current_output_line [: - 1 ] , self .width ))
608+ self .display_lines .extend (paint .display_linize (self .current_output_line , self .width ))
605609 self .current_output_line = ''
606610 #self.display_lines = self.display_lines[:len(self.display_lines) - self.stdin.old_num_lines]
607611 #lines = paint.display_linize(line, self.width)
0 commit comments