Skip to content

Commit

Permalink
Support various cursor shapes for more input modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Jul 29, 2024
1 parent 6695411 commit 9e8bf20
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/prompt_toolkit/cursor_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e8bf20

Please sign in to comment.