diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-09-06 04:17:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-09-06 04:17:24 +0000 |
commit | 9b77fda0d4171f68760c070895dc5700cb6d1e0f (patch) | |
tree | 37912945e9d35ef62e5a4a1eb07ac224307e5db6 /pgcli/pgtoolbar.py | |
parent | Releasing debian version 3.1.0-3. (diff) | |
download | pgcli-9b77fda0d4171f68760c070895dc5700cb6d1e0f.tar.xz pgcli-9b77fda0d4171f68760c070895dc5700cb6d1e0f.zip |
Merging upstream version 3.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pgcli/pgtoolbar.py')
-rw-r--r-- | pgcli/pgtoolbar.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/pgcli/pgtoolbar.py b/pgcli/pgtoolbar.py index f4289a1..41f903d 100644 --- a/pgcli/pgtoolbar.py +++ b/pgcli/pgtoolbar.py @@ -1,15 +1,23 @@ +from pkg_resources import packaging + +import prompt_toolkit from prompt_toolkit.key_binding.vi_state import InputMode from prompt_toolkit.application import get_app +parse_version = packaging.version.parse + +vi_modes = { + InputMode.INSERT: "I", + InputMode.NAVIGATION: "N", + InputMode.REPLACE: "R", + InputMode.INSERT_MULTIPLE: "M", +} +if parse_version(prompt_toolkit.__version__) >= parse_version("3.0.6"): + vi_modes[InputMode.REPLACE_SINGLE] = "R" + def _get_vi_mode(): - return { - InputMode.INSERT: "I", - InputMode.NAVIGATION: "N", - InputMode.REPLACE: "R", - InputMode.REPLACE_SINGLE: "R", - InputMode.INSERT_MULTIPLE: "M", - }[get_app().vi_state.input_mode] + return vi_modes[get_app().vi_state.input_mode] def create_toolbar_tokens_func(pgcli): |