|
35 | 35 | import fmtstr.events as events |
36 | 36 | from bpython.scrollfrontend.friendly import NotImplementedError |
37 | 37 |
|
38 | | -INFOBOX_ONLY_BELOW = True #TODO make this a config option if it isn't already |
39 | | -EDITOR_KEY = 'F7' #TODO put this in config if it gets to stay in |
40 | | - |
41 | 38 | #TODO implement paste mode and figure out what the deal with config.paste_time is |
42 | 39 | #TODO figure out how config.auto_display_list=False behaves and implement it |
43 | 40 | #TODO figure out how config.list_win_visible behaves and implement it |
@@ -152,7 +149,7 @@ def __init__(self, locals_=None, config=None): |
152 | 149 |
|
153 | 150 | self.status_bar = StatusBar(_('welcome to bpython'), _( |
154 | 151 | " <%s> Rewind <%s> Save <%s> Pastebin <%s> Editor" |
155 | | - ) % (config.undo_key, config.save_key, config.pastebin_key, EDITOR_KEY)) |
| 152 | + ) % (config.undo_key, config.save_key, config.pastebin_key, config.external_editor_key)) |
156 | 153 | self.rl_char_sequences = get_updated_char_sequences(key_dispatch, config) |
157 | 154 | logging.debug("starting parent init") |
158 | 155 | super(Repl, self).__init__(interp, config) |
@@ -297,7 +294,7 @@ def process_event(self, e): |
297 | 294 | logging.debug('starting pastebin thread') |
298 | 295 | t.start() |
299 | 296 | self.interact.wait_for_request_or_notify() |
300 | | - elif e in key_dispatch[EDITOR_KEY]: |
| 297 | + elif e in key_dispatch[self.config.external_editor_key]: |
301 | 298 | self.send_to_external_editor() |
302 | 299 | #TODO add PAD keys hack as in bpython.cli |
303 | 300 | else: |
@@ -557,7 +554,7 @@ def paint(self, about_to_exit=False): |
557 | 554 | self.clean_up_current_line_for_exit() # exception to not changing state! |
558 | 555 |
|
559 | 556 | width, min_height = self.width, self.height |
560 | | - show_status_bar = bool(self.status_bar.current_line) |
| 557 | + show_status_bar = bool(self.status_bar.current_line) and (self.config.scroll_fill_terminal or self.status_bar.has_focus) |
561 | 558 | if show_status_bar: |
562 | 559 | min_height -= 1 |
563 | 560 |
|
@@ -604,37 +601,44 @@ def paint(self, about_to_exit=False): |
604 | 601 | #infobox not properly expanding window! try reduce( docs about halfway down a 80x24 terminal |
605 | 602 | #TODO what's the desired behavior here? Currently uses only the space already on screen, |
606 | 603 | # scrolling down only if there would have been more space above the current line, but being forced to put below |
| 604 | + #TODO above description is not accurate - sometimes screen scrolls for docstring message |
607 | 605 | logging.debug('infobox display code running') |
608 | 606 | visible_space_above = history.height |
609 | 607 | visible_space_below = min_height - cursor_row - 1 |
610 | 608 |
|
611 | 609 | info_max_rows = max(visible_space_above, visible_space_below) |
612 | 610 | infobox = paint.paint_infobox(info_max_rows, int(width * self.config.cli_suggestion_width), self.matches, self.argspec, self.current_word, self.docstring, self.config) |
613 | 611 |
|
614 | | - if visible_space_above >= infobox.height and not INFOBOX_ONLY_BELOW: |
| 612 | + if visible_space_above >= infobox.height and self.config.scroll_list_above: |
615 | 613 | arr[current_line_start_row - infobox.height:current_line_start_row, 0:infobox.width] = infobox |
616 | 614 | else: |
617 | 615 | arr[cursor_row + 1:cursor_row + 1 + infobox.height, 0:infobox.width] = infobox |
618 | 616 | logging.debug('slamming infobox of shape %r into arr of shape %r', infobox.shape, arr.shape) |
619 | 617 |
|
620 | 618 | logging.debug('about to exit: %r', about_to_exit) |
621 | 619 | if show_status_bar: |
622 | | - if about_to_exit: |
623 | | - arr[max(arr.height, min_height), :] = FSArray(1, width) |
| 620 | + if self.config.scroll_fill_terminal: |
| 621 | + if about_to_exit: |
| 622 | + arr[max(arr.height, min_height), :] = FSArray(1, width) |
| 623 | + else: |
| 624 | + arr[max(arr.height, min_height), :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config) |
| 625 | + |
| 626 | + if self.presentation_mode: |
| 627 | + rows = arr.height |
| 628 | + columns = arr.width |
| 629 | + last_key_box = paint.paint_last_events(rows, columns, [pp_event(x) for x in self.last_events if x]) |
| 630 | + arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box |
624 | 631 | else: |
625 | | - arr[max(arr.height, min_height), :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config) |
626 | | - |
627 | | - if self.presentation_mode: |
628 | | - rows = arr.height |
629 | | - columns = arr.width |
630 | | - last_key_box = paint.paint_last_events(rows, columns, [pp_event(x) for x in self.last_events if x]) |
631 | | - arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box |
632 | | - #logging.debug(last_key_box[:]) |
633 | | - #logging.debug(arr[:]) |
| 632 | + statusbar_row = min_height + 1 if arr.height == min_height else arr.height |
| 633 | + if about_to_exit: |
| 634 | + arr[statusbar_row, :] = FSArray(1, width) |
| 635 | + else: |
| 636 | + arr[statusbar_row, :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config) |
634 | 637 |
|
635 | 638 | if self.config.color_scheme['background'] not in ('d', 'D'): |
636 | 639 | for r in range(arr.height): |
637 | 640 | arr[r] = fmtstr(arr[r], bg=color_for_letter(self.config.color_scheme['background'])) |
| 641 | + logging.debug('returning arr of size %r', arr.shape) |
638 | 642 | return arr, (cursor_row, cursor_column) |
639 | 643 |
|
640 | 644 | ## Debugging shims |
|
0 commit comments