@@ -65,17 +65,18 @@ def process_event(self, e):
65
65
self .repl .run_code_and_maybe_finish ()
66
66
elif e in ["\x1b " ]: #ESC
67
67
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 " ]:
72
69
line = self .current_line
73
- self .repl .send_to_stdin (line )
70
+ self .repl .send_to_stdin (line + ' \n ' )
74
71
self .has_focus = False
75
72
self .current_line = ''
76
73
self .cursor_offset_in_line = 0
77
- #self.repl.coderunner.run_code(for_code=line)
78
74
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
79
80
else :
80
81
self .repl .send_to_stdin (self .current_line )
81
82
@@ -270,14 +271,8 @@ def process_event(self, e):
270
271
271
272
elif self .status_bar .has_focus :
272
273
return self .status_bar .process_event (e )
273
- elif self .stdin .has_focus :
274
- return self .stdin .process_event (e )
275
274
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
281
276
elif isinstance (e , events .PasteEvent ):
282
277
ctrl_char = compress_paste_event (e )
283
278
if ctrl_char is not None :
@@ -290,6 +285,15 @@ def process_event(self, e):
290
285
self .process_simple_event (ee )
291
286
self .update_completion ()
292
287
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
+
293
297
elif e in self .rl_char_sequences :
294
298
self .cursor_offset_in_line , self ._current_line = self .rl_char_sequences [e ](self .cursor_offset_in_line , self ._current_line )
295
299
self .update_completion ()
@@ -601,7 +605,7 @@ def send_to_stderr(self, error):
601
605
602
606
def send_to_stdin (self , line ):
603
607
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 ))
605
609
self .current_output_line = ''
606
610
#self.display_lines = self.display_lines[:len(self.display_lines) - self.stdin.old_num_lines]
607
611
#lines = paint.display_linize(line, self.width)
0 commit comments