erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.7k stars 55 forks source link

Fix REPL #431

Closed C-BJ closed 1 year ago

C-BJ commented 1 year ago

Fixes #429 Fixes #428

  1. Delete the code of cursor change
  2. Support Ctrl + D/Z to exit at the same time

@mtshiba

GreasySlug commented 1 year ago

It is common for the cursor shape to be Line in input mode, etc Perhaps that was the intent of the implementation Since you can change the shape, why don't you change it back to the Block shape at the end of the REPL?

    pub fn read(&mut self) -> String {
    ...
        execute!(output, MoveToColumn(0), SetCursorShape(CursorShape::Block)).unwrap();
    ...
    }

If not, please remove the following code that changes the shape of the cursor

    pub fn read(&mut self) -> String {
    ...
        execute!(output, SetCursorShape(CursorShape::Line)).unwrap();
    ...
    }
C-BJ commented 1 year ago

I think I was thinking the same thing at first, but it's possible that the terminal cursor wasn't block to begin with.

GreasySlug commented 1 year ago

Does it compile successfully?

cargo run --features full
mtshiba commented 1 year ago

BTW, Ctrl+Z seems to have a different meaning than normal exit (Ctrl+D, exit()); a command entered with Ctrl+Z is "paused" by Linux convention. A paused command becomes a background process and can be resumed with the fg command.

Erg should do the same.

C-BJ commented 1 year ago

I did this because, on Windows, Python prompts you to exit with Ctrl + Z instead of D Maybe we should do different things for different system