summaryrefslogtreecommitdiffstats
path: root/pgcli/pgtoolbar.py
diff options
context:
space:
mode:
authorJoakim Koljonen <koljonen@outlook.com>2016-12-07 02:59:27 +0100
committerJoakim Koljonen <koljonen@outlook.com>2016-12-07 03:00:50 +0100
commit0129e49f7fffe2c17dcb4ad1e67911e2edb970db (patch)
treefbac98a08ef9266ec0523067f4d0bd26a1e3b1f6 /pgcli/pgtoolbar.py
parentd964c74bc414f8c51d4b146511f6dede93aa1c65 (diff)
Display vi mode in the toolbar
I've been confused about what mode I'm in so many times ...
Diffstat (limited to 'pgcli/pgtoolbar.py')
-rw-r--r--pgcli/pgtoolbar.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pgcli/pgtoolbar.py b/pgcli/pgtoolbar.py
index 74144bb9..84db715d 100644
--- a/pgcli/pgtoolbar.py
+++ b/pgcli/pgtoolbar.py
@@ -1,6 +1,14 @@
from pygments.token import Token
from prompt_toolkit.enums import DEFAULT_BUFFER
+from prompt_toolkit.key_binding.vi_state import InputMode
+def _get_vi_mode(cli):
+ return {
+ InputMode.INSERT: 'I',
+ InputMode.NAVIGATION: 'N',
+ InputMode.REPLACE: 'R',
+ InputMode.INSERT_MULTIPLE: 'M',
+ }[cli.vi_state.input_mode]
def create_toolbar_tokens_func(get_vi_mode_enabled, get_is_refreshing):
"""
@@ -31,7 +39,7 @@ def create_toolbar_tokens_func(get_vi_mode_enabled, get_is_refreshing):
result.append((token,' (Semi-colon [;] will end the line) '))
if get_vi_mode_enabled():
- result.append((token.On, '[F4] Vi-mode'))
+ result.append((token.On, '[F4] Vi-mode (' + _get_vi_mode(cli) + ')'))
else:
result.append((token.On, '[F4] Emacs-mode'))