@@ -648,10 +648,11 @@ def paint(self, about_to_exit=False):
648648 lines = paint .display_linize (self .current_cursor_line + 'X' , width )
649649 # extra character for space for the cursor
650650 cursor_row = current_line_start_row + len (lines ) - 1
651- if self .stdin .has_focus :
651+ if self .stdin .has_focus or self . current_stdouterr_line : #self.stdin.has_focus :
652652 cursor_column = len (self .current_stdouterr_line ) + self .stdin .cursor_offset_in_line
653653 else :
654654 cursor_column = len (self .current_cursor_line ) - len (self ._current_line ) + self .cursor_offset_in_line
655+ assert cursor_column >= 0 , cursor_column
655656
656657 if self .list_win_visible :
657658 #infobox not properly expanding window! try reduce( docs about halfway down a 80x24 terminal
@@ -701,7 +702,7 @@ def paint(self, about_to_exit=False):
701702 ## Debugging shims
702703 def dumb_print_output (self ):
703704 arr , cpos = self .paint ()
704- arr [cpos [0 ], cpos [1 ]] = '~'
705+ arr [cpos [0 ]: cpos [ 0 ] + 1 , cpos [1 ]: cpos [ 1 ] + 1 ] = [ '~' ]
705706 def my_print (msg ):
706707 self .orig_stdout .write (str (msg )+ '\n ' )
707708 my_print ('X' * (self .width + 8 ))
@@ -720,8 +721,14 @@ def my_print(msg):
720721 my_print ('X' * (self .width + 8 ))
721722 return max (len (arr ) - self .height , 0 )
722723
723- def dumb_input (self ):
724- for c in self .orig_stdin .readline ()[:- 1 ]:
724+ def dumb_input (self , requested_refreshes = []):
725+ chars = list (self .orig_stdin .readline ()[:- 1 ])
726+ while chars or requested_refreshes :
727+ if requested_refreshes :
728+ requested_refreshes .pop ()
729+ self .process_event (events .RefreshRequestEvent ())
730+ continue
731+ c = chars .pop (0 )
725732 if c in '/' :
726733 c = '\n '
727734 elif c in '\\ ' :
@@ -822,13 +829,16 @@ def send_to_external_editor(self, filename=None):
822829 self .reevaluate (insert_into_history = True )
823830
824831def simple_repl ():
825- with Repl () as r :
832+ refreshes = []
833+ def request_refresh ():
834+ refreshes .append (1 )
835+ with Repl (stuff_a_refresh_request = request_refresh ) as r :
826836 r .width = 50
827837 r .height = 10
828838 while True :
829839 scrolled = r .dumb_print_output ()
830840 r .scroll_offset += scrolled
831- r .dumb_input ()
841+ r .dumb_input (refreshes )
832842
833843if __name__ == '__main__' :
834844 simple_repl ()
0 commit comments