Skip to content

Commit d749916

Browse files
committed
Reinstante GNU Readline as an option...
Option --readline is now a choice: GNU, Prompt, or None Prompt is prompt-toolkit and is the default. However in some situations where the terminal is limited we sometimes need GNU or none.
1 parent bdc89bf commit d749916

File tree

5 files changed

+398
-452
lines changed

5 files changed

+398
-452
lines changed

mathicsscript/__main__.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
import subprocess
99
from pathlib import Path
1010

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
1217

1318
from mathicsscript.format import format_output
1419

@@ -134,10 +139,11 @@ def out(self, out):
134139
help="don't print message at startup",
135140
)
136141
@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",
139145
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.""",
141147
)
142148
@click.option(
143149
"--completion/--no-completion",
@@ -246,7 +252,17 @@ def main(
246252
"Settings`$PygmentsShowTokens", from_python(True if pygments_tokens else False)
247253
)
248254

249-
shell = TerminalShell(definitions, style, readline, completion, unicode, prompt)
255+
readline = 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+
250266
load_settings(shell)
251267
if run:
252268
with open(run, "r") as ifile:

0 commit comments

Comments
 (0)