| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3fce108 commit 9a4a71a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,7 @@ def loadini(struct, configfile): | |||
| 82 | 82 | 'delete': 'C-d', | |
| 83 | 83 | 'down_one_line': 'C-n', | |
| 84 | 84 | 'exit': '', | |
| 85 | + 'external_editor': 'F7', | ||
| 85 | 86 | 'last_output': 'F9', | |
| 86 | 87 | 'pastebin': 'F8', | |
| 87 | 88 | 'save': 'C-s', | |
@@ -95,6 +96,10 @@ def loadini(struct, configfile): | |||
| 95 | 96 | 'suggestion_width': 0.8, | |
| 96 | 97 | 'trim_prompts': False, | |
| 97 | 98 | }, | |
| 99 | + 'scroll': { | ||
| 100 | + 'list_above' : False, | ||
| 101 | + 'fill_terminal' : False, | ||
| 102 | + }, | ||
| 98 | 103 | 'gtk': { | |
| 99 | 104 | 'font': 'monospace 10', | |
| 100 | 105 | 'color_scheme': 'default'}}) | |
@@ -135,6 +140,7 @@ def loadini(struct, configfile): | |||
| 135 | 140 | struct.delete_key = config.get('keyboard', 'delete') | |
| 136 | 141 | struct.exit_key = config.get('keyboard', 'exit') | |
| 137 | 142 | struct.last_output_key = config.get('keyboard', 'last_output') | |
| 143 | + struct.external_editor_key = config.get('keyboard', 'external_editor') | ||
| 138 | 144 | ||
| 139 | 145 | struct.pastebin_confirm = config.getboolean('general', 'pastebin_confirm') | |
| 140 | 146 | struct.pastebin_private = config.getboolean('general', 'pastebin_private') | |
@@ -157,6 +163,9 @@ def loadini(struct, configfile): | |||
| 157 | 163 | ||
| 158 | 164 | struct.gtk_font = config.get('gtk', 'font') | |
| 159 | 165 | ||
| 166 | + struct.scroll_list_above = config.getboolean('scroll', 'list_above') | ||
| 167 | + struct.scroll_fill_terminal = config.getboolean('scroll', 'fill_terminal') | ||
| 168 | + | ||
| 160 | 169 | color_scheme_name = config.get('general', 'color_scheme') | |
| 161 | 170 | color_gtk_scheme_name = config.get('gtk', 'color_scheme') | |
| 162 | 171 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ def process_event(self, e): | |||
| 61 | 61 | else: | |
| 62 | 62 | self.response_queue.put(False) | |
| 63 | 63 | self.escape() | |
| 64 | - elif e == ['\x1b', '\t']: | ||
| 64 | + elif e in ['\x1b', '\t', '\x1b\t', '\x1b\x1b']: | ||
| 65 | 65 | self.response_queue.put(False) | |
| 66 | 66 | self.escape() | |
| 67 | 67 | else: # add normal character | |
@@ -110,7 +110,7 @@ def confirm(self, q): | |||
| 110 | 110 | return self.response_queue.get() | |
| 111 | 111 | def file_prompt(self, s): | |
| 112 | 112 | """Expected to return a file name, given """ | |
| 113 | - self.prompt = s | ||
| 113 | + self.prompt = s.replace('Esc', 'Tab') | ||
| 114 | 114 | self.in_prompt = True | |
| 115 | 115 | self.request_or_notify_queue.put(s) | |
| 116 | 116 | r = self.response_queue.get() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,9 +35,6 @@ | |||
| 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -259,3 +259,20 @@ Default: Monospace 10 | |||
| 259 | 259 | ||
| 260 | 260 | The font to be used by the GTK version. | |
| 261 | 261 | ||
| 262 | + scroll | ||
| 263 | + ------ | ||
| 264 | + This refers to the ``[scroll]`` section in your config file. | ||
| 265 | + | ||
| 266 | + .. versionadded:: 0.13 | ||
| 267 | + | ||
| 268 | + fill_terminal | ||
| 269 | + ^^^^^^^^^^^^^ | ||
| 270 | + Default: True | ||
| 271 | + | ||
| 272 | + Whether bpython should take up the whole terminal, and always display a status bar at the bottom. | ||
| 273 | + | ||
| 274 | + list_above | ||
| 275 | + ^^^^^^^^^^ | ||
| 276 | + Default: False | ||
| 277 | + | ||
| 278 | + When there is space above the current line, whether the suggestions list will be displayed there instead of below the current line. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments