[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Quick and dirty libreadline binding with completion support
- From: Nagaev Boris <bnagaev@...>
- Date: Tue, 9 Jun 2015 16:26:03 +0000
Hello, Dmitriy
On Tue, Jun 9, 2015 at 4:05 PM, Dmitriy Kryuk <kryukdmitriy@rambler.ru> wrote:
> I have written a quick and dirty Lua binding for libreadline with limited
> line completion support. It's provided as a FreeBSD port, but it should be
> easy to figure out how to build it as a standalone library.
>
> Download at: http://rghost.ru/7wZ2xgrbT
> Mirror: ftp://motoprogger.ru/distrib/lua/readline/lua-readline.tar.xz
Looks good!
Could you import it to Github, please? RGhost uploads are removed
eventually and FTP is becoming more and more historical protocol...
> It provides two ways of completion management:
> 1) A table of strings
> 2) A generator function
> A table of strings is considered unsorted and is searched for strings
> beginning with the already typed-in prefix. A generator function gets the
> typed-in prefix and must return an iterator of matching strings. The strings
> are displayed in the iterator order and are not obligated to begin with the
> provided prefix.
>
> It's called like:
>
> local readline = require "readline"
> result = readline.readline("Prompt: ", {"Completion1", "Completion2", "Other
> completions"})
> -- or
> result = readline.readline("Prompt: ", generator_function)
>
> The generator function can be like:
>
> function generator(prefix)
> local suffixes = {"a", "e", "i", "o", "u", "y"}
> local i = 0
> return function()
> i = i + 1
> return prefix..suffixes[i]
> end
> end
>
> The library's current limitations are:
> 1) It doesn't save or restore libreadline state. In particular it interferes
> with the interactive Lua shell.
> 2) It doesn't support libreadline key binding or functions
> 3) It supports only one completion generator or array and allows to type in
> more than one word of the same set.
> Probably I shall provide some usage examples in a while. I would be glad to
> see it converted to a more appropriate distribution form, provided with
> documentation and developed further.
>
>
>
Similar software:
1. luaprompt. An embeddable Lua command prompt as well as a
stand-alone interpreter with pretty-printing and autocompletion. It
can save history and has many configuration options. [1]
2. readline.lua, a simple interface to the readline and history libraries [2]
[1] https://github.com/dpapavas/luaprompt
[2] http://www.pjb.com.au/comp/lua/readline.html
--
Best regards,
Boris Nagaev