I would like to build a (golang) library that offers a number of options for user choice. My idea is to print the names of the options and highlight one as "active". Upon arrow keys (left and right or up and down) being pressed I would like to update the "selected" answer internally and visibly.
I know about termbox
and tcell
and I also have checked projects like peco
and rat
. All of them seem to build on the basic concept of a screen of some kind. Ideally I would like to keep the control in just the line the user is editing in his terminal without creating a fullscreen interaction. Is there any way to achieve this?
Answering my own question: This neat library called climenu practically does what I asked for. All the technical trickery needed is part of this code. Kudos to Paul Rademacher! I surely can adapt this to suit my needs.
ncurses is one popular library for terminal control in Linux, and it has Go bindings (also supports OSX and Windows). I have never used them, so I cannot vouch for them, but this is one way to accomplish what you want.