refaktor / rye

homoiconic dynamic programming language with some new ideas
https://ryelang.org
Apache License 2.0
462 stars 22 forks source link

Use Microliner in console #257

Closed rokostik closed 3 months ago

rokostik commented 4 months ago

This PR replaces the refaktor/liner with Microliner in the console repl so it's the same liner for both wasm and console.

When testing it out on MacOS I noticed two bugs:

  1. CMD+backspace (should delete from cursor to start of the line) doesn't work and I couldn't figure out how to make it work.
  2. Microliner doesn't behave well if the text overflows the console width (also an issue on wasm repl). This was handled in the old liner and should be fixed.

Otherwise everything that I've tested looks fine but we should also test on Linux and Windows before merging.

rokostik commented 3 months ago

I needed to move some things around and constrain them with build flags in ed47ea3 because eiannone/keyboard is imported in evaldo (which is imported by main_wasm.go) and it requires x/sys/unix which is not available on wasm.

refaktor commented 3 months ago

I am testing it ... The first issue is not crucial, but I will try to figure out the text overflow problem before merge.

I see you already implemented or made possible the interactive display for blocks and spreadsheets which wasn't working in microliner before! That is GREAT!

stefanb commented 3 months ago

If refaktor/liner isn't used anymore it should be removed from go.mod file using go mod tidy.

rokostik commented 3 months ago

If refaktor/liner isn't used anymore it should be removed from go.mod file using go mod tidy.

@stefanb It's still used in DoRyeRepl_OLD not sure if @refaktor wants to keep this code.

refaktor commented 3 months ago

Maybe for a while as a backup, until we se that then new liner really works. Currently I still haven't solved the line wrapping issue. We also need to test the microliner based console on windows before merge.

refaktor commented 3 months ago

Ok, I made the line overflow (to multiple lines) with syntax highlighting work ... at least when typing in ... haven't worked yet on cursor behaviour, and typing in differente positions but I think this will be easier and it didn't work that well now either way.

cwarden commented 3 months ago

It looks like this broke history and emacs keybindings. Ctrl-n/Down, Ctrl-p/Up, and Ctrl-u stopped working after 3efe639ddd8fee7df52bbdd7b801620afc16ba5f.

refaktor commented 3 months ago

I made some updates yesterday to microliner ... the main issue, multiline support works much better but still not for all cases (using arrow keys to go back to previous lines).

@cwarden You mean these keybindings don't work if you run Rye console in ansi-term in Emacs or in some other way?

cwarden commented 3 months ago

I meant that some of the emacs-style keybindings stopped working in the rye repl when running in a terminal. The combinations, Ctrl-n, -p, -u, are the three I regularly use that I noticed no longer work.

cwarden commented 3 months ago

294 restores Ctrl-n, -p, -u.

Up/Down/Left/Right not working seems to be a bug in github.com/eiannone/keyboard. In alacritty, keyboard.GetKey() returns rune 91 and Key 27 for all four keys. In xterm, it returns keyboard.KeyArrowUp, keyboard.KeyArrowDown, etc.