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

TailTipWidget Enabling by default #571

Closed
rnc opened this issue Sep 16, 2020 · 5 comments
Closed

TailTipWidget Enabling by default #571

rnc opened this issue Sep 16, 2020 · 5 comments

Comments

@rnc
Copy link

rnc commented Sep 16, 2020

I have followed https://github.com/jline/jline3/wiki/Autosuggestions (which has

TailTipWidgets tailtipWidgets = new TailTipWidgets(reader, tailTips, 5, TipType.COMPLETER);
// Enable autosuggestions 
tailtipWidgets.enable();

) but I get Widgets can only be called during a readLine call.

For code like

                new TailTipWidgets(reader, systemRegistry::commandDescription, 5, TailTipWidgets.TipType.COMPLETER);
                KeyMap<Binding> keyMap = reader.getKeyMaps().get("main");
                keyMap.bind(new Reference("tailtip-toggle"), KeyMap.alt("s"));

what is the correct way of enabling it by default (so the user doesn't have to press Alt-s to enable it)

@mattirn
Copy link
Collaborator

mattirn commented Sep 16, 2020

It should work... I have modified Groovy REPL so that tailtip widgets are enabled https://github.com/mattirn/jline3/tree/widget-enable, see the last commit mattirn@c1a7b29. In my PC it works as expected.

@rnc
Copy link
Author

rnc commented Sep 16, 2020

It should work... I have modified Groovy REPL so that tailtip widgets are enabled https://github.com/mattirn/jline3/tree/widget-enable, see the last commit mattirn@c1a7b29. In my PC it works as expected.

Thanks for the reply!

I guess I must be missing something in my configuration. I am using jline via picocli (which brings in org.jline:jline:jar:3.15.0 ). Maybe that is affecting it / making a difference?

The code is https://github.com/rnc/bacon/blob/JLINE3/cli/src/main/java/org/jboss/pnc/bacon/cli/App.java#L156 pushed to branch JLINE3 and running via the produced shaded jar gives:

java -jar cli/target/bacon.jar
Exception in thread "main" java.lang.IllegalStateException: Widgets can only be called during a `readLine` call
        at org.jline.reader.impl.LineReaderImpl.callWidget(LineReaderImpl.java:832)
        at org.jline.builtins.Widgets.callWidget(Widgets.java:91)
        at org.jline.builtins.Widgets$TailTipWidgets.toggleKeyBindings(Widgets.java:1068)
        at org.jline.builtins.Widgets$TailTipWidgets.enable(Widgets.java:834)
        at org.jboss.pnc.bacon.cli.App.run(App.java:156)
        at org.jboss.pnc.bacon.cli.App.main(App.java:73)

@mattirn
Copy link
Collaborator

mattirn commented Sep 16, 2020

Yes, you are right! There is a bug in version 3.15.0 which has been fixed in 3.16.0, see commits

  • fcac9694 Console example: fixed widgets enabling/disabling, step II
  • 1aa0bda2 Console example: fixed widgets enabling/disabling

I'm afraid picocli-shell-jline3 requires some minor changes to use JLine version 3.16.0, see #551

@rnc
Copy link
Author

rnc commented Sep 16, 2020

@mattirn Ah ha, I was cross-checking the released versions and that was going to be my next guess after you said it should work. I think the appropriate thing to do would be enter a ticket for picocli. Thanks for your help!

I'll look to see if I can manage the dependency manually and update the code - I will read your referenced ticket tomorrow.

@rnc
Copy link
Author

rnc commented Sep 16, 2020

I've just given it a go and added

<dependency>
 <groupId>org.jline</groupId>
 <artifactId>jline-console</artifactId>
</dependency>

as an extra dependency and it works. Thanks!

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

No branches or pull requests

2 participants