##// END OF EJS Templates
Add flag for simple_prompt....
Matthias Bussonnier -
Show More
@@ -0,0 +1,4 b''
1 when using IPython as a subprocess, like for emacs inferior-shell, IPython can
2 be started with --simple-prompt flag, which will bypass the prompt_toolkit
3 input layer. In this mode completion, prompt color and many other features are
4 disabled.
@@ -102,6 +102,11 b" addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',"
102 'Turn on auto editing of files with syntax errors.',
102 'Turn on auto editing of files with syntax errors.',
103 'Turn off auto editing of files with syntax errors.'
103 'Turn off auto editing of files with syntax errors.'
104 )
104 )
105 addflag('simple-prompt', 'TerminalInteractiveShell.simple_prompt',
106 "Force simple minimal prompt using `raw_input`",
107 "Use a rich interactive prompt with prompt_toolkit",
108 )
109
105 addflag('banner', 'TerminalIPythonApp.display_banner',
110 addflag('banner', 'TerminalIPythonApp.display_banner',
106 "Display a banner upon starting IPython.",
111 "Display a banner upon starting IPython.",
107 "Don't display a banner upon starting IPython."
112 "Don't display a banner upon starting IPython."
@@ -31,6 +31,7 b' from .pt_inputhooks import get_inputhook_func'
31 from .interactiveshell import get_default_editor, TerminalMagics
31 from .interactiveshell import get_default_editor, TerminalMagics
32 from .ptutils import IPythonPTCompleter, IPythonPTLexer
32 from .ptutils import IPythonPTCompleter, IPythonPTLexer
33
33
34 _use_simple_prompt = 'IPY_TEST_SIMPLE_PROMPT' in os.environ or not sys.stdin.isatty()
34
35
35 class TerminalInteractiveShell(InteractiveShell):
36 class TerminalInteractiveShell(InteractiveShell):
36 colors_force = True
37 colors_force = True
@@ -46,6 +47,18 b' class TerminalInteractiveShell(InteractiveShell):'
46 debugger_history = None
47 debugger_history = None
47 debugger_cls = TerminalPdb
48 debugger_cls = TerminalPdb
48
49
50 simple_prompt = Bool(_use_simple_prompt,
51 help="""Use `raw_input` for the REPL, without completion, multiline input, and prompt colors.
52
53 Useful when controlling IPython as a subprocess, and piping STDIN/OUT/ERR. Known usage are:
54 IPython own testing machinery, and emacs inferior-shell integration through elpy.
55
56 This mode default to `True` if the `IPY_TEST_SIMPLE_PROMPT`
57 environment variable is set, or the current terminal is not a tty.
58
59 """
60 ).tag(config=True)
61
49 autoedit_syntax = Bool(False,
62 autoedit_syntax = Bool(False,
50 help="auto editing of files with syntax errors.",
63 help="auto editing of files with syntax errors.",
51 ).tag(config=True)
64 ).tag(config=True)
@@ -117,7 +130,7 b' class TerminalInteractiveShell(InteractiveShell):'
117 ]
130 ]
118
131
119 def init_prompt_toolkit_cli(self):
132 def init_prompt_toolkit_cli(self):
120 if ('IPY_TEST_SIMPLE_PROMPT' in os.environ) or not sys.stdin.isatty():
133 if self.simple_prompt:
121 # Fall back to plain non-interactive output for tests.
134 # Fall back to plain non-interactive output for tests.
122 # This is very limited, and only accepts a single line.
135 # This is very limited, and only accepts a single line.
123 def prompt():
136 def prompt():
General Comments 0
You need to be logged in to leave comments. Login now