|
8 | 8 | import subprocess |
9 | 9 | from pathlib import Path |
10 | 10 |
|
11 | | -from mathicsscript.termshell import ShellEscapeException, TerminalShell, mma_lexer |
| 11 | +from mathicsscript.termshell import ( |
| 12 | + ShellEscapeException, |
| 13 | + TerminalShellPromptToolKit, |
| 14 | + mma_lexer, |
| 15 | +) |
| 16 | +from mathicsscript.termshell_gnu import TerminalShellGNUReadline |
12 | 17 |
|
13 | 18 | from mathicsscript.format import format_output |
14 | 19 |
|
@@ -134,10 +139,11 @@ def out(self, out): |
134 | 139 | help="don't print message at startup", |
135 | 140 | ) |
136 | 141 | @click.option( |
137 | | - "--readline/--no-readline", |
138 | | - default=have_readline, |
| 142 | + "--readline", |
| 143 | + type=click.Choice(["GNU", "Prompt", "None"], case_sensitive=False), |
| 144 | + default="Prompt", |
139 | 145 | show_default=True, |
140 | | - help="GNU Readline line editing. If this is off completion and command history are also turned off", |
| 146 | + help="""Readline method. "Prompt" is usually best. GNU Readline is better than "None" most of the time.""", |
141 | 147 | ) |
142 | 148 | @click.option( |
143 | 149 | "--completion/--no-completion", |
@@ -246,7 +252,17 @@ def main( |
246 | 252 | "Settings`$PygmentsShowTokens", from_python(True if pygments_tokens else False) |
247 | 253 | ) |
248 | 254 |
|
249 | | - shell = TerminalShell(definitions, style, readline, completion, unicode, prompt) |
| 255 | + readline = "none" if (execute or file and not persist) else readline.lower() |
| 256 | + if readline == "prompt": |
| 257 | + shell = TerminalShellPromptToolKit( |
| 258 | + definitions, style, completion, unicode, prompt |
| 259 | + ) |
| 260 | + else: |
| 261 | + want_readline = readline == "gnu" |
| 262 | + shell = TerminalShellGNUReadline( |
| 263 | + definitions, style, want_readline, completion, unicode, prompt |
| 264 | + ) |
| 265 | + |
250 | 266 | load_settings(shell) |
251 | 267 | if run: |
252 | 268 | with open(run, "r") as ifile: |
|
0 commit comments