Skip to content

Commit 25e32b4

Browse files
committed
Add modal cursor option for when using vi mode
1 parent fddbc42 commit 25e32b4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

jupyter_console/ptshell.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
4646

4747
from prompt_toolkit.completion import Completer, Completion
48+
from prompt_toolkit.cursor_shapes import ModalCursorShapeConfig
4849
from prompt_toolkit.document import Document
4950
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
5051
from prompt_toolkit.filters import (
@@ -321,6 +322,19 @@ class ZMQTerminalInteractiveShell(SingletonConfigurable):
321322
help="Display the current vi mode (when using vi editing mode)."
322323
).tag(config=True)
323324

325+
modal_cursor = Bool(
326+
False, help="Changes cursor shape depending on vi mode"
327+
).tag(config=True)
328+
329+
ttimeoutlen = Float(
330+
0.01,
331+
config=True,
332+
help=(
333+
"When to flush the input (For flushing escape keys.);"
334+
" like Vim’s ttimeoutlen option"
335+
)
336+
)
337+
324338
highlight_matching_brackets = Bool(True, help="Highlight matching brackets.",).tag(
325339
config=True
326340
)
@@ -572,8 +586,12 @@ def _(event):
572586
style=style,
573587
input_processors=input_processors,
574588
color_depth=(ColorDepth.TRUE_COLOR if self.true_color else None),
589+
cursor=ModalCursorShapeConfig() if self.modal_cursor else None,
575590
)
576591

592+
if self.modal_cursor:
593+
self.pt_cli.app.ttimeoutlen = self.ttimeoutlen
594+
577595
async def prompt_for_code(self):
578596
if self.next_input:
579597
default = self.next_input

0 commit comments

Comments
 (0)