Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 40 additions & 15 deletions mycli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down