##// END OF EJS Templates
Merge pull request #11390 from Carreau/vim-lov...
Matthias Bussonnier -
r24698:a704d028 merge
parent child Browse files
Show More
@@ -12,7 +12,7 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 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,17 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 not hasattr(self.shell.pt_app, 'editing_mode'):
18 return ''
19 if self.shell.pt_app.editing_mode == 'VI':
20 return '['+str(self.shell.pt_app.app.vi_state.input_mode)[3:6]+'] '
21 return ''
22
23
16 def in_prompt_tokens(self):
24 def in_prompt_tokens(self):
17 return [
25 return [
26 (Token.Prompt, self.vi_mode() ),
18 (Token.Prompt, 'In ['),
27 (Token.Prompt, 'In ['),
19 (Token.PromptNum, str(self.shell.execution_count)),
28 (Token.PromptNum, str(self.shell.execution_count)),
20 (Token.Prompt, ']: '),
29 (Token.Prompt, ']: '),
General Comments 0
You need to be logged in to leave comments. Login now