diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-09-06 04:17:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-09-06 04:17:09 +0000 |
commit | 76d27bc43d56d7ef3ca0090fb199777888adf7c3 (patch) | |
tree | b6d3d562a0be03d404426bb43aff62174be3dc5e /pgcli/pgtoolbar.py | |
parent | Adding upstream version 3.1.0. (diff) | |
download | pgcli-76d27bc43d56d7ef3ca0090fb199777888adf7c3.tar.xz pgcli-76d27bc43d56d7ef3ca0090fb199777888adf7c3.zip |
Adding upstream version 3.2.0.upstream/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): |