Request for new features in jline2 (or maybe jline3)

58 views
Skip to first unread message

Andreas Wegmann

unread,
May 2, 2016, 2:38:10 PM5/2/16
to jline-dev
Hi.

I developed a kind of UI elements library based on the features of jline2 and jansi. It is inspired by InquirerJS which - in my eyes - has a very nice user interface for simple console interactions. Because I didn't find anything in the java world comparable to InquirerJS, I wrote a that library for my projects. 

To get an idea what it looks like, you can find a screen recording at YouTube. The project can be found on https://github.com/awegmann/consoleui. Console UI itself is also a wrapper around jline2 and supports the use of completers within its InputPrompt class.

At the moment I'm stuck at implementing some features I would like to have. And maybe someone can help me - preferably by giving me some hints or adding the necessary method calls to jline2.

The first feature I want to add is a pre-filled input line. This would be used to present a default value to the user to edited. I didn't find out how to fill the input buffer of jline2 and (!) place the cursor at the end of the input buffer. Another benefit from this feature would be, that this enables me to provide validators for my InputPromt class which can be used to verify if the user entered a correct email address, IP address, URL or whatever the developer wanted the user to ask (with verification and error message).

The second feature I would like to have is an "official" API method to get one character from jline2 or a key press for a "special character" like cursor up, cursor down, enter, ESC, and so on. My class ConsoleReaderImpl provides such a functionality, but it was implemented by copying some code form the readLine method. I think this is definitely the wrong way. Is there such a API an I only didn't find it?

Best Regards
 Andreas

 


Guillaume Nodet

unread,
May 3, 2016, 2:49:23 AM5/3/16
to jlin...@googlegroups.com
If you want to look at a better api, you should look at jline3.
The main reason is that the terminal stuff has been extracted in its own api, the readline stuff being on top of it.
You can thus have access to the underlying stream more easily and you can indeed read chars one by one, or get easy mapping between the stream to decoded actions.
You can find such a sample application at: 

Let me know if this api suits you better.

--
You received this message because you are subscribed to the Google Groups "jline-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages