lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


THanks for the info about linenoise. I have been using in
my current project and it work well. Its solves the problem
of porting to small machines.

DB

On 26/3/2010 3:05 PM, Luiz Henrique de Figueiredo wrote:
Would it make sense to eventually use linenoise instead of readline in Lua?

luaconf already has macros for this.
To use linenoise, I expect these should work:

#if defined(LUA_USE_LINENOISE)
#include "linenoise.h"
#define lua_readline(L,b,p)	((void)L, ((b)=linenoise(p)) != NULL)
#define lua_saveline(L,idx) \
	if (lua_strlen(L,idx)>  0)  /* non-empty line? */ \
	  linenoiseHistoryAdd(lua_tostring(L, idx));  /* add it to history */
#define lua_freeline(L,b)	((void)L, free(b))
#endif

Or you can just use this emulation of readline:

#define readline	linenoise
#define add_history	linenoiseHistoryAdd

Of course, you need to add linenoise.o to your project.