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
Allow a default buffer value in the buffer with readLine() #177
Comments
Thanks @gnodet ! |
@gnodet I got a chance to test this out today and I'm afraid it's not quite working for me. The buffer text is appended to the buffer, but it's not flushed to the screen so you can't actually see it. Furthermore, if i hit the backspace key, it just erases that many characters out of my prompt. |
It's 2016 and JLine still doesn't support default value in input buffer? For shame. |
@mvmn I'm not sure what release that fix made it into, but I can confirm it works in the |
Looks like they've released 2.14.2 on 31-st of May. 6 days after my comment. It was supposed to be in 2.14.2 already. |
In CommandBox, our Jline2-based CLI and package manager tool for CFML, we will often have the need to ask the user for additional input when running a "installer wizard" style command.
CommandBox > addSite Enter webroot path: _
We'd like to be able to pre-populate the buffer with default text the user can edit if they wish, or just hit enter to submit it as is:
readLine()
lets me set the prompt, but not anything else. There is putString() but it's a catch 22 because you can't call putString() before readLine() because it will get output before the prompt and you can't call it after because readLine blocks until it receives your input.For what it's worth I'm able to trick it by threading the readline() call, waiting 100ms, then outputting the default value and flushing the buffer, then joining back to the thread to await your input. Of course, this is pretty hacky so it would be nice to see this be core. Here's an example of my hack described above (in CFML):
That outputs the following, with everything after the ">" as editable:
The text was updated successfully, but these errors were encountered: