mirror of
https://github.com/holub/mame
synced 2025-07-03 17:08:39 +03:00
lua-linenoise: add preload (nw)
This commit is contained in:
parent
68ff36882c
commit
a6aaa59d19
9
3rdparty/lua-linenoise/linenoise.c
vendored
9
3rdparty/lua-linenoise/linenoise.c
vendored
@ -101,6 +101,14 @@ static int l_historyadd(lua_State *L)
|
|||||||
return handle_ln_ok(L);
|
return handle_ln_ok(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_preloadbuffer(lua_State *L)
|
||||||
|
{
|
||||||
|
const char *line = luaL_checkstring(L, 1);
|
||||||
|
linenoisePreloadBuffer(line);
|
||||||
|
|
||||||
|
return handle_ln_ok(L);
|
||||||
|
}
|
||||||
|
|
||||||
static int l_historysetmaxlen(lua_State *L)
|
static int l_historysetmaxlen(lua_State *L)
|
||||||
{
|
{
|
||||||
int len = luaL_checkinteger(L, 1);
|
int len = luaL_checkinteger(L, 1);
|
||||||
@ -168,6 +176,7 @@ luaL_Reg linenoise_funcs[] = {
|
|||||||
{ "clearscreen", l_clearscreen },
|
{ "clearscreen", l_clearscreen },
|
||||||
{ "setcompletion", l_setcompletion},
|
{ "setcompletion", l_setcompletion},
|
||||||
{ "addcompletion", l_addcompletion },
|
{ "addcompletion", l_addcompletion },
|
||||||
|
{ "preload", l_preloadbuffer },
|
||||||
|
|
||||||
/* Aliases for more consistent function names */
|
/* Aliases for more consistent function names */
|
||||||
{ "addhistory", l_historyadd },
|
{ "addhistory", l_historyadd },
|
||||||
|
@ -13,6 +13,7 @@ function console.startplugin()
|
|||||||
local conth = emu.thread()
|
local conth = emu.thread()
|
||||||
local started = false
|
local started = false
|
||||||
local ln = require("linenoise")
|
local ln = require("linenoise")
|
||||||
|
local preload = false
|
||||||
print(" _/ _/ _/_/ _/ _/ _/_/_/_/");
|
print(" _/ _/ _/_/ _/ _/ _/_/_/_/");
|
||||||
print(" _/_/ _/_/ _/ _/ _/_/ _/_/ _/ ");
|
print(" _/_/ _/_/ _/ _/ _/_/ _/_/ _/ ");
|
||||||
print(" _/ _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ ");
|
print(" _/ _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ ");
|
||||||
@ -76,14 +77,25 @@ function console.startplugin()
|
|||||||
ln.historyadd(cmd)
|
ln.historyadd(cmd)
|
||||||
local func, err = load(cmd)
|
local func, err = load(cmd)
|
||||||
if not func then
|
if not func then
|
||||||
print("error: ", err)
|
if err:match("<eof>") then
|
||||||
|
print("incomplete command")
|
||||||
|
ln.preload(cmd)
|
||||||
|
preload = true
|
||||||
|
else
|
||||||
|
print("error: ", err)
|
||||||
|
preload = false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
preload = false
|
||||||
local status
|
local status
|
||||||
status, err = pcall(func)
|
status, err = pcall(func)
|
||||||
if not status then
|
if not status then
|
||||||
print("error: ", err)
|
print("error: ", err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not preload then
|
||||||
|
ln.historyadd(cmd)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
conth:start(scr)
|
conth:start(scr)
|
||||||
started = true
|
started = true
|
||||||
|
Loading…
Reference in New Issue
Block a user