##// END OF EJS Templates
Give some love to the VI mode....
Matthias Bussonnier -
Show More
@@ -12,7 +12,7 b' from IPython.utils.terminal import toggle_set_term_title, set_term_title'
12 from IPython.utils.process import abbrev_cwd
12 from IPython.utils.process import abbrev_cwd
13 from traitlets import (
13 from traitlets import (
14 Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union,
14 Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union,
15 Any,
15 Any, validate
16 )
16 )
17
17
18 from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
18 from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
@@ -131,6 +131,23 b' class TerminalInteractiveShell(InteractiveShell):'
131 highlighting. To see available styles, run `pygmentize -L styles`."""
131 highlighting. To see available styles, run `pygmentize -L styles`."""
132 ).tag(config=True)
132 ).tag(config=True)
133
133
134 @validate('editing_mode')
135 def _validate_editing_mode(self, proposal):
136 if proposal['value'].lower() == 'vim':
137 proposal['value']= 'vi'
138 elif proposal['value'].lower() == 'default':
139 proposal['value']= 'emacs'
140
141 if hasattr(EditingMode, proposal['value'].upper()):
142 return proposal['value'].lower()
143
144 return self.editing_mode
145
146
147 @observe('editing_mode')
148 def _editing_mode(self, change):
149 u_mode = change.new.upper()
150 self.pt_app.editing_mode = u_mode
134
151
135 @observe('highlighting_style')
152 @observe('highlighting_style')
136 @observe('colors')
153 @observe('colors')
@@ -13,8 +13,15 b' class Prompts(object):'
13 def __init__(self, shell):
13 def __init__(self, shell):
14 self.shell = shell
14 self.shell = shell
15
15
16 def vi_mode(self):
17 if self.shell.pt_app.editing_mode == 'VI':
18 return '['+str(self.shell.pt_app.app.vi_state.input_mode)[3:6]+'] '
19 return ''
20
21
16 def in_prompt_tokens(self):
22 def in_prompt_tokens(self):
17 return [
23 return [
24 (Token.Prompt, self.vi_mode() ),
18 (Token.Prompt, 'In ['),
25 (Token.Prompt, 'In ['),
19 (Token.PromptNum, str(self.shell.execution_count)),
26 (Token.PromptNum, str(self.shell.execution_count)),
20 (Token.Prompt, ']: '),
27 (Token.Prompt, ']: '),
General Comments 0
You need to be logged in to leave comments. Login now