@@ -610,6 +610,7 @@ def done(self):
610610
611611 @property
612612 def current_line_formatted (self ):
613+ """The colored current line (no prompt, not wrapped)"""
613614 if self .config .syntax :
614615 fs = bpythonparse (format (self .tokenize (self ._current_line ), self .formatter ))
615616 else :
@@ -622,10 +623,18 @@ def current_line_formatted(self):
622623
623624 @property
624625 def lines_for_display (self ):
626+ """All display lines (wrapped, colored, with prompts)"""
625627 return self .display_lines + self .display_buffer_lines
626628
627629 @property
628630 def current_word (self ):
631+ """Returns the "current word", based on what's directly left of the cursor.
632+ examples inclue "socket.socket.metho" or "self.reco" or "yiel"
633+
634+ cw() is currently an alias, but cw() is used by bpyton.repl.Repl
635+ so must match its definition of current word - changing how it behaves
636+ has many repercussions.
637+ """
629638 words = re .split (r'([\w_][\w0-9._]*[(]?)' , self ._current_line )
630639 chars = 0
631640 cw = None
@@ -650,7 +659,7 @@ def current_word(self, value):
650659
651660 @property
652661 def display_buffer_lines (self ):
653- """The lines build from the display buffer"""
662+ """The display lines (wrapped, colored, with prompts) for the current buffer"""
654663 lines = []
655664 for display_line in self .display_buffer :
656665 display_line = (func_for_letter (self .config .color_scheme ['prompt_more' ])(self .ps2 )
@@ -662,19 +671,22 @@ def display_buffer_lines(self):
662671
663672 @property
664673 def display_line_with_prompt (self ):
674+ """colored line with prompt"""
665675 return (func_for_letter (self .config .color_scheme ['prompt' ])(self .ps1 )
666676 if self .done else
667677 func_for_letter (self .config .color_scheme ['prompt_more' ])(self .ps2 )) + self .current_line_formatted
668678
669679 @property
670680 def current_cursor_line (self ):
681+ """Current line, either output/input or Python prompt + code"""
671682 value = (self .current_output_line +
672683 ('' if self .coderunner .running else self .display_line_with_prompt ))
673684 logging .debug ('current cursor line: %r' , value )
674685 return value
675686
676687 @property
677688 def current_output_line (self ):
689+ """line of output currently being written, and stdin typed"""
678690 return self .current_stdouterr_line + self .stdin .current_line
679691
680692 @current_output_line .setter
@@ -685,6 +697,17 @@ def current_output_line(self, value):
685697 def paint (self , about_to_exit = False , user_quit = False ):
686698 """Returns an array of min_height or more rows and width columns, plus cursor position
687699
700+ Also increments self.scroll_offset by the amount the terminal must have scrolled
701+ to display the entire array.
702+ """
703+ arr , (row , col ) = self ._paint (about_to_exit = about_to_exit , user_quit = user_quit )
704+ if arr .height > self .height :
705+ self .scroll_offset += arr .height - self .height
706+ return arr , (row , col )
707+
708+ def _paint (self , about_to_exit = False , user_quit = False ):
709+ """Returns an array of min_height or more rows and width columns, plus cursor position
710+
688711 Paints the entire screen - ideally the terminal display layer will take a diff and only
689712 write to the screen in portions that have changed, but the idea is that we don't need
690713 to worry about that here, instead every frame is completely redrawn because
0 commit comments