lua-users home
lua-l archive

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


> 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.