Returns an array of min_height or more rows and width columns, plus cursor position Paints the entire screen - ideally the terminal display layer will take a diff and only write to the screen in portions that have changed, but the idea is that we don't need to worry
(
self,
about_to_exit=False,
user_quit=False,
try_preserve_history_height=30,
min_infobox_height=5,
)
| 1541 | return line_with_padding_len - len(full_line) |
| 1542 | |
| 1543 | def paint( |
| 1544 | self, |
| 1545 | about_to_exit=False, |
| 1546 | user_quit=False, |
| 1547 | try_preserve_history_height=30, |
| 1548 | min_infobox_height=5, |
| 1549 | ) -> tuple[FSArray, tuple[int, int]]: |
| 1550 | """Returns an array of min_height or more rows and width columns, plus |
| 1551 | cursor position |
| 1552 | |
| 1553 | Paints the entire screen - ideally the terminal display layer will take |
| 1554 | a diff and only write to the screen in portions that have changed, but |
| 1555 | the idea is that we don't need to worry about that here, instead every |
| 1556 | frame is completely redrawn because less state is cool! |
| 1557 | |
| 1558 | try_preserve_history_height is the the number of rows of content that |
| 1559 | must be visible before the suggestion box scrolls the terminal in order |
| 1560 | to display more than min_infobox_height rows of suggestions, docs etc. |
| 1561 | """ |
| 1562 | # The hairiest function in the curtsies |
| 1563 | if about_to_exit: |
| 1564 | # exception to not changing state! |
| 1565 | self.clean_up_current_line_for_exit() |
| 1566 | |
| 1567 | width, min_height = self.width, self.height |
| 1568 | show_status_bar = ( |
| 1569 | bool(self.status_bar.should_show_message) |
| 1570 | or self.status_bar.has_focus |
| 1571 | ) and not self.request_paint_to_pad_bottom |
| 1572 | if show_status_bar: |
| 1573 | # because we're going to tack the status bar on at the end, shoot |
| 1574 | # for an array one less than the height of the screen |
| 1575 | min_height -= 1 |
| 1576 | |
| 1577 | current_line_start_row = len(self.lines_for_display) - max( |
| 1578 | 0, self.scroll_offset |
| 1579 | ) |
| 1580 | # TODO how is the situation of self.scroll_offset < 0 possible? |
| 1581 | # or show_status_bar and about_to_exit ? |
| 1582 | if self.request_paint_to_clear_screen: |
| 1583 | self.request_paint_to_clear_screen = False |
| 1584 | arr = FSArray(min_height + current_line_start_row, width) |
| 1585 | elif self.request_paint_to_pad_bottom: |
| 1586 | # min_height - 1 for startup banner with python version |
| 1587 | height = min(self.request_paint_to_pad_bottom, min_height - 1) |
| 1588 | arr = FSArray(height, width) |
| 1589 | self.request_paint_to_pad_bottom = 0 |
| 1590 | else: |
| 1591 | arr = FSArray(0, width) |
| 1592 | # TODO test case of current line filling up the whole screen (there |
| 1593 | # aren't enough rows to show it) |
| 1594 | |
| 1595 | current_line = paint.paint_current_line( |
| 1596 | min_height, width, self.current_cursor_line |
| 1597 | ) |
| 1598 | # needs to happen before we calculate contents of history because |
| 1599 | # calculating self.current_cursor_line has the side effect of |
| 1600 | # unhighlighting parens in buffer |