arrow keys compatibility?
d9k opened this issue · comments
arrow keys doesn't work in ubuntu 16.04 + gnome-terminal for me
for example, when I run rep.lua
and press up arrow
it becomes ^[[A
.
rlwrap lua rep.lua
is a temporary but not cool solution
Hi @d9k,
If you install lua-linenoise
, you'll get line editing turned on by default.
By the way, is this your first time using lua-repl? Did it work on previous versions of Ubuntu for you?
@hoelzro, linenoise
solved an issue, thx!
I was never able to get arrow keys working without this library.
I'm glad that worked for you! linenoise
is required for the arrow keys to work, since Lua doesn't natively have readline-like abilities. I'm a little confused about rlwrap, though; lua-repl is supposed to detect it and automatically invoke it if linenoise
failed to load. But all's well that ends well, I suppose!
For some reason this doesn't allow <alt+f>/<alt+right arrow> to do a forward word (and same for backward word). It works with the rlwrap plugin, but not with the linenoise plugin. Loading both at the same time doesn't seem to work.
Hi @rien333,
Linenoise supports only a small set of keybindings, and the use of the linenoise plugin is mutually exclusive with the rlwrap plugin. If you need keybindings like alt+f
, I suggest sticking with the rlwrap plugin.
Found a better way. Use linenoise.c
from this linenoise fork to build an .so/shared library with readline alt key support within your lua-linenoise bindings.
@rien333 I'm glad that worked for you! Please be aware that linenoiselib.c
has other tweaks made to it so that things like errors within completion callbacks work, though.
Another alternative would be to write a plugin that integrates directly with readline or libedit, which are going to do a better job at handling readline-based keybindings - linenoise isn't really meant to be a full readline implementation, after all!