-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipython_config.py
38 lines (26 loc) · 1.02 KB
/
ipython_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
from prompt_toolkit.key_binding.vi_state import InputMode, ViState
def get_input_mode(self):
if sys.version_info[0] == 3:
from prompt_toolkit.application.current import get_app
app = get_app()
# Decrease input flush timeout from 500ms to 10ms.
app.ttimeoutlen = 0.01
# Decrease handler call timeout from 1s to 250ms.
app.timeoutlen = 0.25
return self._input_mode
def set_input_mode(self, mode):
shape = {InputMode.NAVIGATION: 2, InputMode.REPLACE: 4}.get(mode, 6)
cursor = "\x1b[{} q".format(shape)
if hasattr(sys.stdout, "_cli"):
write = sys.stdout._cli.output.write_raw
else:
write = sys.stdout.write
write(cursor)
sys.stdout.flush()
self._input_mode = mode
ViState._input_mode = InputMode.INSERT
ViState.input_mode = property(get_input_mode, set_input_mode)
# Shortcut style to use at the prompt. 'vi' or 'emacs'.
c.TerminalInteractiveShell.editing_mode = "vi"
c.TerminalInteractiveShell.prompt_includes_vi_mode = False