2012-12-03 07:12:14 +01:00
|
|
|
Add support of linenoise (replace readline)
|
|
|
|
|
|
|
|
see discussion, http://lua-users.org/lists/lua-l/2010-03/msg00879.html
|
|
|
|
|
|
|
|
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
|
|
|
|
|
2014-01-17 18:47:35 +01:00
|
|
|
Index: b/src/lua.c
|
2012-12-03 07:12:14 +01:00
|
|
|
===================================================================
|
2014-01-17 18:47:35 +01:00
|
|
|
--- a/src/lua.c
|
|
|
|
+++ b/src/lua.c
|
|
|
|
@@ -72,6 +72,15 @@
|
|
|
|
add_history(lua_tostring(L, idx)); /* add it to history */
|
2012-12-03 07:12:14 +01:00
|
|
|
#define lua_freeline(L,b) ((void)L, free(b))
|
2014-01-17 18:47:35 +01:00
|
|
|
|
2012-12-03 07:12:14 +01:00
|
|
|
+#elif defined(LUA_USE_LINENOISE)
|
2014-01-17 18:47:35 +01:00
|
|
|
+
|
2012-12-03 07:12:14 +01:00
|
|
|
+#include <linenoise.h>
|
|
|
|
+#define lua_readline(L,b,p) ((void)L, ((b)=linenoise(p)) != NULL)
|
|
|
|
+#define lua_saveline(L,idx) \
|
2014-01-17 18:47:35 +01:00
|
|
|
+ if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \
|
2012-12-03 07:12:14 +01:00
|
|
|
+ linenoiseHistoryAdd(lua_tostring(L, idx)); /* add it to history */
|
|
|
|
+#define lua_freeline(L,b) ((void)L, free(b))
|
2014-01-17 18:47:35 +01:00
|
|
|
+
|
|
|
|
#elif !defined(lua_readline)
|
|
|
|
|
|
|
|
#define lua_readline(L,b,p) \
|