##// END OF EJS Templates
Update `ptshell.py` to use new traitlets API.
Matthias Bussonnier -
Show More
@@ -13,7 +13,7 b' from IPython.core.interactiveshell import InteractiveShell'
13 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
13 from IPython.utils.py3compat import PY3, cast_unicode_py2, input
14 from IPython.utils.terminal import toggle_set_term_title, set_term_title
14 from IPython.utils.terminal import toggle_set_term_title, set_term_title
15 from IPython.utils.process import abbrev_cwd
15 from IPython.utils.process import abbrev_cwd
16 from traitlets import Bool, CBool, Unicode, Dict, Integer
16 from traitlets import Bool, CBool, Unicode, Dict, Integer, observe
17
17
18 from prompt_toolkit.completion import Completer, Completion
18 from prompt_toolkit.completion import Completer, Completion
19 from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode
19 from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER, EditingMode
@@ -91,7 +91,7 b' class IPythonPTLexer(Lexer):'
91 class TerminalInteractiveShell(InteractiveShell):
91 class TerminalInteractiveShell(InteractiveShell):
92 colors_force = True
92 colors_force = True
93
93
94 space_for_menu = Integer(6, config=True, help='Number of line at the bottom of the screen '
94 space_for_menu = Integer(6).tag(config=True, help='Number of line at the bottom of the screen '
95 'to reserve for the completion menu')
95 'to reserve for the completion menu')
96
96
97 def _space_for_menu_changed(self, old, new):
97 def _space_for_menu_changed(self, old, new):
@@ -99,47 +99,48 b' class TerminalInteractiveShell(InteractiveShell):'
99
99
100 pt_cli = None
100 pt_cli = None
101
101
102 autoedit_syntax = CBool(False, config=True,
102 autoedit_syntax = CBool(False).tag(config=True,
103 help="auto editing of files with syntax errors.")
103 help="auto editing of files with syntax errors.")
104
104
105 confirm_exit = CBool(True, config=True,
105 confirm_exit = CBool(True).tag(config=True,
106 help="""
106 help="""
107 Set to confirm when you try to exit IPython with an EOF (Control-D
107 Set to confirm when you try to exit IPython with an EOF (Control-D
108 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
108 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
109 you can force a direct exit without any confirmation.""",
109 you can force a direct exit without any confirmation.""",
110 )
110 )
111 editing_mode = Unicode('emacs', config=True,
111 editing_mode = Unicode('emacs').tag(config=True,
112 help="Shortcut style to use at the prompt. 'vi' or 'emacs'.",
112 help="Shortcut style to use at the prompt. 'vi' or 'emacs'.",
113 )
113 )
114
114
115 mouse_support = Bool(False, config=True,
115 mouse_support = Bool(False).tag(config=True,
116 help="Enable mouse support in the prompt"
116 help="Enable mouse support in the prompt"
117 )
117 )
118
118
119 highlighting_style = Unicode('default', config=True,
119 highlighting_style = Unicode('default').tag(config=True,
120 help="The name of a Pygments style to use for syntax highlighting: \n %s" % ', '.join(get_all_styles())
120 help="The name of a Pygments style to use for syntax highlighting: \n %s" % ', '.join(get_all_styles())
121 )
121 )
122
122
123 def _highlighting_style_changed(self, old, new):
123 def _highlighting_style_changed(self, old, new):
124 self._style = self._make_style_from_name(self.highlighting_style)
124 self._style = self._make_style_from_name(self.highlighting_style)
125
125
126 highlighting_style_overrides = Dict(config=True,
126 highlighting_style_overrides = Dict().tag(config=True,
127 help="Override highlighting format for specific tokens"
127 help="Override highlighting format for specific tokens"
128 )
128 )
129
129
130 editor = Unicode(get_default_editor(), config=True,
130 editor = Unicode(get_default_editor()).tag(config=True,
131 help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
131 help="Set the editor used by IPython (default to $EDITOR/vi/notepad)."
132 )
132 )
133
133
134 term_title = Bool(True, config=True,
134 term_title = Bool(True).tag(config=True,
135 help="Automatically set the terminal title"
135 help="Automatically set the terminal title"
136 )
136 )
137
137
138 display_completions_in_columns = Bool(False, config=True,
138 display_completions_in_columns = Bool(False).tag(config=True,
139 help="Display a multi column completion menu.",
139 help="Display a multi column completion menu.",
140 )
140 )
141
141
142 def _term_title_changed(self, name, new_value):
142 @observe('term_title')
143 def _term_title_changed(self, change):
143 self.init_term_title()
144 self.init_term_title()
144
145
145 def init_term_title(self):
146 def init_term_title(self):
General Comments 0
You need to be logged in to leave comments. Login now