Skip to content

Commit 84c9411

Browse files
committed
Shell: Reinstate support for line editing (including arrow keys) and color
Also: * Shell: Improve internal documentation for Crystal's interactive console * Shell: Tests: Cover Ctrl-C handling
1 parent 26a1c87 commit 84c9411

File tree

4 files changed

+650
-101
lines changed

4 files changed

+650
-101
lines changed

src/crystal/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,19 @@ def _on_end_session(self, event: wx.CloseEvent) -> None:
687687
try:
688688
# (Don't insert anything between set_foreground_thread() and MyApp())
689689
if not parsed_args.headless:
690-
# - Queue call of app.OnInit() and _did_launch() after main loop starts
691690
# - When using --shell, don't let wxPython override Ctrl-C handling,
692691
# so that the shell can handle Ctrl-C properly
693-
# - When not using --shell, allow wxPython to override Ctrl-C
692+
# - When not using --shell, allow wxPython to override Ctrl-C to
694693
# exit process immediately (rather than raising KeyboardInterrupt)
694+
shell_handles_ctrl_c = (
695+
shell is not None and
696+
shell.handles_ctrl_c()
697+
)
698+
wx_handles_ctrl_c = not shell_handles_ctrl_c
699+
700+
# Queue call of app.OnInit() and _did_launch() after main loop starts
695701
# NOTE: Shows the dock icon on macOS
696-
app = MyApp(redirect=False, clearSigInt=(shell is None))
702+
app = MyApp(redirect=False, clearSigInt=wx_handles_ctrl_c)
697703
else:
698704
# Queue call of _did_launch() after main loop starts
699705
from crystal.util.xthreading import start_fg_coroutine

0 commit comments

Comments
 (0)