Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: Make use of fancy JLine (3) features #12272

Open
lrytz opened this issue Mar 6, 2020 · 9 comments
Open

REPL: Make use of fancy JLine (3) features #12272

lrytz opened this issue Mar 6, 2020 · 9 comments

Comments

@lrytz
Copy link
Member

lrytz commented Mar 6, 2020

Breifly looking through JLine's tickets and examples, there are a number of features that we could potentially make use of to brush up the REPL experience.

Their example class: https://github.com/jline/jline3/blob/master/builtins/src/test/java/org/jline/example/Example.java

I managed to get it to run with mvn install and then running

java -cp builtins/target/classes:builtins/target/test-classes:reader/target/classes:terminal/target/classes org.jline.example.Example

and providing some random args that are then suggested (color, argument, mouse, ...). Then typing tab shows a completion matrix.

There's also the ./demo/jline-repl.sh that you can run after mvn install, not sure what it does :-)

Some features to look at

  • Groups for completions. For example, we could have groups for "core members", "extension methods", "deprecated members", "inherited from AnyRef/Any". This would replace the feature that today more members show up when requesting the same completion twice. random screenshot

  • Show signature of method in a "status bar", or maybe in a completion "group" at the bottom that is visually different. This should replace the double tab feature that today shows the signature of the method in the prompt. It could also display the signature of a member when navigating through the completion matrix with the arrow keys.

    • java -cp builtins/target/classes:builtins/target/test-classes:reader/target/classes:terminal/target/classes org.jline.example.Example status shows a status bar with a counter at the bottom, maybe we can use that?
    • Provide a better auto-suggestion mechanism jline/jline3#254 is a feature request for something similar.
    • There's a feature called TailTipWidgets, I'm not exactly sure what it is, maybe the light-gray explanation that shows up next to completion items when running org.jline.example.Example argument. Picture:
      image
    • For some commands in the Example program, hitting tab after a command is entered, a suggestion in gray then shows up on the next line. This looks like what we could use for signatures.
      image
  • Maybe use autosuggestion? Suggests completing the current command being entered as you type.

  • mouse enables moving the cursor with mouse clicks

There is probably more in JLine that we can make use of.

@SethTisue
Copy link
Member

auto-indentation (https://github.com/jline/jline3/wiki/Auto-Indentation-and-Pairing#auto-indentation) would be cool too — so when you're entering a multi-line thing, e.g a class body would indent automatically

@SethTisue
Copy link
Member

another one: according to https://github.com/jline/jline3/wiki/Language-REPL-Support , if we use the status bar feature, "the location of the error in the input area [can be] highlighted", that's pretty cool

@lrytz
Copy link
Member Author

lrytz commented Mar 7, 2020

🤤 want!

@som-snytt
Copy link

I also found the status bar demo a major reason to try out jline 3. I also fantasized.

@som-snytt
Copy link

We have to do auto-indent, Jan Lahoda just mentioned it for jshell.

The recent upgrade to JLine 3.14.0 allows us to enable auto-indent, so
that typing a '{' and pressing enter will automatically increase the
indent of following lines by 4, and typing a '}' will automatically
decrease the indent. The indent amount is configurable using /set indent.

@martijnhoekstra
Copy link

Those auto-complete groups are so nice. Can we easily get to the scaladoc @group at that point?

@SethTisue
Copy link
Member

if we want to make use of strikethrough text, note that JLine calls it "crossed out". see AttributedStyle.java for the available styles. "faint" might also be useful

@SethTisue
Copy link
Member

We have to do auto-indent, Jan Lahoda just mentioned it for jshell.

I don't intend to tackle this one myself, but perhaps a volunteer would like to.

@SethTisue
Copy link
Member

SethTisue commented Dec 9, 2020

I guess I should make a more blanket statement about this.

As per scala/scala-dev#754 , I intend to make a fresh attempt at grouping tab completions (#12281).

Other than that, I don't intend to tackle anything else mentioned here in this ticket. It's all open for volunteers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants