1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-09-19 17:58:44 +03:00

Display vi mode in the toolbar

I've been confused about what mode I'm in so many times ...
This commit is contained in:
Joakim Koljonen 2016-12-07 02:59:27 +01:00
parent d964c74bc4
commit 0129e49f7f
No known key found for this signature in database
GPG Key ID: AF0327B5131CD164

View File

@ -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'))