I have a TreeCompleter
(Scala code) which works as expected:
val treeCompleter = new TreeCompleter(
node("bindkey"),
node("cls"),
node(
"custom",
node("Option1", node("Param1", "Param2")),
node("Option2"),
node("Option3")
),
node("help"),
node("set"),
node("sleep"),
node("testkey"),
node("tput")
)
However, if the user's first keypress is a tab I would like all of the top-level node values to be displayed, which should show them the available commands. How can this be done?
The github project that contains the above code is here: https://github.com/mslinn/jline-example/blob/master/src/main/scala/CliLoop.scala
I don't care if the answer is in Java or Scala, thanks!
You simply need to unset the INSERT_TAB
option:
reader.unsetOpt(LineReader.Option.INSERT_TAB)
This will do the trick and tab
will display completion instead of being inserted.