erg-lang / erg

A statically typed language compatible with Python

Home Page:http://erg-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unified exit keybinding in REPL

Hanaasagi opened this issue · comments

Type exit in REPL, we will see

Use exit() or Ctrl-D (i.e. EOF) to exit

This is a message from Python interpreter.

  • When compiled without --features full-repl, Ctrl-d does not work. we need to use Ctrl-c to exit.

  • When compiled with --features full-repl, Ctrl-c has no effect, and Ctrl-d doesn't work either. We need to use Ctrl-z.

match (code, modifiers) {
(KeyCode::Char('z'), KeyModifiers::CONTROL) => {
println!();
line.clear();
line.push_str(":exit");
return Ok(());
}

This inconsistent behavior is quite confusing.

At least, the REPL should be able to exit with Ctrl-D when built with --features full-repl.
Without full-repl, it should modify messages from Python.

At least, the REPL should be able to exit with Ctrl-D when built with --features full-repl.

Yes, I think so.

Without full-repl, it should modify messages from Python.

In a terminal environment, Ctrl-D tmeans EOF, indicating that the user has no more input. I tested the behavior of following REPL. I don't think the message needs to be modified. Using Ctrl-D to exit seems to be a convention.

key python node ghci irb
ctrl-d exit exit exit exit

Maybe support Ctrl + D/Z at the same time