diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-08-14 16:58:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 10:11:48 +0000 |
commit | 4edd467b28c895483cd5468d51d1c6824a21715a (patch) | |
tree | 04a4f32d617905acfc23653025b6e8d3899f51c6 /litecli/clitoolbar.py | |
parent | Initial commit. (diff) | |
download | litecli-4edd467b28c895483cd5468d51d1c6824a21715a.tar.xz litecli-4edd467b28c895483cd5468d51d1c6824a21715a.zip |
Adding upstream version 1.5.0.upstream/1.5.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'litecli/clitoolbar.py')
-rw-r--r-- | litecli/clitoolbar.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/litecli/clitoolbar.py b/litecli/clitoolbar.py new file mode 100644 index 0000000..05d0bfd --- /dev/null +++ b/litecli/clitoolbar.py @@ -0,0 +1,51 @@ +from __future__ import unicode_literals + +from prompt_toolkit.key_binding.vi_state import InputMode +from prompt_toolkit.enums import EditingMode +from prompt_toolkit.application import get_app + + +def create_toolbar_tokens_func(cli, show_fish_help): + """ + Return a function that generates the toolbar tokens. + """ + + def get_toolbar_tokens(): + result = [] + result.append(("class:bottom-toolbar", " ")) + + if cli.multi_line: + result.append( + ("class:bottom-toolbar", " (Semi-colon [;] will end the line) ") + ) + + if cli.multi_line: + result.append(("class:bottom-toolbar.on", "[F3] Multiline: ON ")) + else: + result.append(("class:bottom-toolbar.off", "[F3] Multiline: OFF ")) + if cli.prompt_app.editing_mode == EditingMode.VI: + result.append( + ("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode())) + ) + + if show_fish_help(): + result.append( + ("class:bottom-toolbar", " Right-arrow to complete suggestion") + ) + + if cli.completion_refresher.is_refreshing(): + result.append(("class:bottom-toolbar", " Refreshing completions...")) + + return result + + return get_toolbar_tokens + + +def _get_vi_mode(): + """Get the current vi mode for display.""" + return { + InputMode.INSERT: "I", + InputMode.NAVIGATION: "N", + InputMode.REPLACE: "R", + InputMode.INSERT_MULTIPLE: "M", + }[get_app().vi_state.input_mode] |