Highline and Bottomline …
In rbcurse, we could dialog boxes for entry of text, or getting confirmations (just as in the links editor). However, for those of us who like the vim-ish, bottom of the screen input of text from user, we had an entry routine in io.rb (rbgetstr).
It was certainly not rubyesque. Then i came across the Highline gem and wished our rbgetstr() method was like highline’s ask. I’ve got permission from James Gray to copy his code and fit in ncurses input and output. So now we can almost exactly use highline ask code and get occasional data at the bottom of the screen. Some changes …
- we don’t use readline, since we always are in ncurses character mode,
- if you provide default, then you can edit that value,
- a completion_proc can be passed which is used when pressing TAB
- ANSI color codes can’t be used, thus one can set a color_pair which is used by say
- helptext may be provided. If user presses M-h, this is displayed for 5 seconds (as in alpine. I might pop up a small window at a later stage instead)
- Various keys may be used such as C-a, C-e, C-k (delete till end), C-g (abort) as well as arrow keys, backspace and delete
I’ll be giving it a good trial in an upcoming demo of a gmail client (now that a gmail gem has been released).
At some stage, I could replace the internals with a Label and Field. That would allow users to map keys to procs.
A 1.2.0 release of rbcurse is coming up soon. I am thinking once I have the gmail demo ready, i’ll release 1.2.0. Oh, by the way, I’ve provisionally named the class Bottomline, partly due to Highline, and the fact that the editing line traditionally comes at the bottom of the screen.