From 0aa69489e9de1ddd323f75353b50c58f55292bca Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 25 Feb 2026 05:02:17 -0500 Subject: [PATCH] rewrite bottom toolbar, but keep it compact * recast show_fish_help() as show_initial_toolbar_help() since it is be used more generally * recast show_suggestion_tip() as show_initial_toolbar_help() so that the caller matches the callee * make a toolbar section divider with a vertical bar * add Tab to permanent list of suggested keys * add F1 to permanent list of suggested keys * add F2 to permanent list of suggested keys and show smart-complete status * only highlight the "ON" part of multiline when on, and remove space. Constraining the total highlighted characters to a smaller number makes the line in general more readable, though the styling of the highlighted letters depends on the configuration. * only highlight the Vi modes when vi edit mode is on, and remove space * only show delimiter text if non-standard or initial, and make the text shorter * make right-arrow help text explain _which_ suggestions are referred to, avoiding the confusing word "complete" * make "refreshing" message shorter with a Unicode ellipsis A key feature of the reorganization is that transient text only can appear on the right, so the keystroke help stays more aligned. --- changelog.md | 1 + mycli/clitoolbar.py | 55 ++++++++++++++++++++++++++++++++------------- mycli/main.py | 4 ++-- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index 7c82df44..edc8eb20 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ Features * Add `\bug` command. * Let the `F1` key open a browser to mycli.net/docs and emit help text. * Add documentation index URL to inline help. +* Rewrite bottom toolbar, showing more statuses, but staying compact. Bug Fixes diff --git a/mycli/clitoolbar.py b/mycli/clitoolbar.py index a249a35c..1cd2a062 100644 --- a/mycli/clitoolbar.py +++ b/mycli/clitoolbar.py @@ -7,35 +7,60 @@ from mycli.packages import special -def create_toolbar_tokens_func(mycli, show_fish_help: Callable) -> Callable: +def create_toolbar_tokens_func(mycli, show_initial_toolbar_help: Callable) -> Callable: """Return a function that generates the toolbar tokens.""" def get_toolbar_tokens() -> list[tuple[str, str]]: - result = [("class:bottom-toolbar", " ")] + divider = ('class:bottom-toolbar', ' │ ') - if mycli.multi_line: - delimiter = special.get_current_delimiter() - result.append(( - "class:bottom-toolbar", - f' ({"Semi-colon" if delimiter == ";" else "Delimiter"} [{delimiter}] will end the line) ', - )) + result = [("class:bottom-toolbar", "[Tab] Complete")] + + result.append(divider) + result.append(("class:bottom-toolbar", "[F1] Help")) + + if mycli.completer.smart_completion: + result.append(divider) + result.append(("class:bottom-toolbar", "[F2] Smart-complete:")) + result.append(("class:bottom-toolbar.on", "ON")) + else: + result.append(divider) + result.append(("class:bottom-toolbar", "[F2] Smart-complete:")) + result.append(("class:bottom-toolbar.off", "OFF")) if mycli.multi_line: - result.append(("class:bottom-toolbar.on", "[F3] Multiline: ON ")) + result.append(divider) + result.append(("class:bottom-toolbar", "[F3] Multiline:")) + result.append(("class:bottom-toolbar.on", "ON")) else: - result.append(("class:bottom-toolbar.off", "[F3] Multiline: OFF ")) + result.append(divider) + result.append(("class:bottom-toolbar", "[F3] Multiline:")) + result.append(("class:bottom-toolbar.off", "OFF")) + if mycli.prompt_app.editing_mode == EditingMode.VI: - result.append(("class:bottom-toolbar.on", f"Vi-mode ({_get_vi_mode()})")) + result.append(divider) + result.append(("class:bottom-toolbar", "Vi:")) + result.append(("class:bottom-toolbar.on", _get_vi_mode())) if mycli.toolbar_error_message: - result.append(("class:bottom-toolbar", " " + mycli.toolbar_error_message)) + result.append(divider) + result.append(("class:bottom-toolbar", mycli.toolbar_error_message)) mycli.toolbar_error_message = None - if show_fish_help(): - result.append(("class:bottom-toolbar", " Right-arrow to complete suggestion")) + if mycli.multi_line: + delimiter = special.get_current_delimiter() + if delimiter != ';' or show_initial_toolbar_help(): + result.append(divider) + result.append(('class:bottom-toolbar', '"')) + result.append(('class:bottom-toolbar.on', delimiter)) + result.append(('class:bottom-toolbar', '" ends a statement')) + + if show_initial_toolbar_help(): + result.append(divider) + result.append(("class:bottom-toolbar", "right-arrow accepts full-line suggestion")) if mycli.completion_refresher.is_refreshing(): - result.append(("class:bottom-toolbar", " Refreshing completions...")) + result.append(divider) + result.append(("class:bottom-toolbar", "Refreshing completions…")) return result diff --git a/mycli/main.py b/mycli/main.py index 00904399..bd47da88 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -922,7 +922,7 @@ def get_continuation(width: int, _two: int, _three: int) -> AnyFormattedText: continuation = " " return [("class:continuation", continuation)] - def show_suggestion_tip() -> bool: + def show_initial_toolbar_help() -> bool: return iterations < 2 # Keep track of whether or not the query is mutating. In case @@ -1228,7 +1228,7 @@ def one_iteration(text: str | None = None) -> None: query = Query(text, successful, mutating) self.query_history.append(query) - get_toolbar_tokens = create_toolbar_tokens_func(self, show_suggestion_tip) + get_toolbar_tokens = create_toolbar_tokens_func(self, show_initial_toolbar_help) if self.wider_completion_menu: complete_style = CompleteStyle.MULTI_COLUMN else: