From 9e8bf206304930d4fb14f5d552808bbebb56715a Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Mon, 29 Jul 2024 12:25:28 +0800 Subject: [PATCH] Support various cursor shapes for more input modes --- src/prompt_toolkit/cursor_shapes.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/prompt_toolkit/cursor_shapes.py b/src/prompt_toolkit/cursor_shapes.py index 453b72c3c..cbd8e593f 100644 --- a/src/prompt_toolkit/cursor_shapes.py +++ b/src/prompt_toolkit/cursor_shapes.py @@ -69,10 +69,23 @@ class ModalCursorShapeConfig(CursorShapeConfig): def get_cursor_shape(self, application: Application[Any]) -> CursorShape: if application.editing_mode == EditingMode.VI: - if application.vi_state.input_mode == InputMode.INSERT: + if application.vi_state.input_mode in { + InputMode.NAVIGATION, + }: + return CursorShape.BLOCK + if application.vi_state.input_mode in { + InputMode.INSERT, + InputMode.INSERT_MULTIPLE, + }: return CursorShape.BEAM - if application.vi_state.input_mode == InputMode.REPLACE: + if application.vi_state.input_mode == { + InputMode.REPLACE, + InputMode.REPLACE_SINGLE, + }: return CursorShape.UNDERLINE + elif application.editing_mode == EditingMode.EMACS: + # like vi's INSERT + return CursorShape.BEAM # Default return CursorShape.BLOCK