I read somewhere that linenoise can do multiline editing, which can be useful for lua programming as you can see the whole line instead of just a fraction of it.

So if I add these lines to 3rdparty/lua-linenoise/linenoise.c

(this comes from https://github.com/hoelzro/lua-linenoise/blob/master/linenoise.c )


Code

static int l_setmultiline(lua_State *L)
{
    int is_multi_line = lua_toboolean(L, 1);

    linenoiseSetMultiLine(is_multi_line);

    return handle_ln_ok(L);
}

...

luaL_Reg linenoise_funcs[] = {
    { "linenoise", l_linenoise },
    { "historyadd", l_historyadd },
    { "historysetmaxlen", l_historysetmaxlen },
    { "historysave", l_historysave },
    { "historyload", l_historyload },
    { "historyget", l_historyget },
    { "clearscreen", l_clearscreen },
    { "setcompletion", l_setcompletion},
    { "addcompletion", l_addcompletion },

    /* Aliases for more consistent function names */
    { "addhistory", l_historyadd },
    { "sethistorymaxlen", l_historysetmaxlen },
    { "savehistory", l_historysave },
    { "loadhistory", l_historyload },
    { "setmultiline", l_setmultiline },      // add this line

    { "line", l_linenoise },
    { "lines", l_lines },

    { NULL, NULL }
};



so then in plugins/console/init.lua

Code

function console.startplugin()
        local conth = emu.thread()
        local ln_started = false
        local started = false
        local stopped = false
        local ln = require("linenoise")
        globalln = ln  -- make ln accessible as global
        ln.setmultiline(1) -- enable multiline editing
        local preload = false

If you make a globalln, then you can see the history like this:

Code
...
353	printt(globalln.historyget())
354	function printt(t) for i,j in pairs(t) do print(i,j) end end
355	printt(globalln.historyget())
[MAME]> 



and if you do a lot of lua stuff, it's always good to bump up the historysetmaxlen to whatever you like


-- ln.historysetmaxlen(50)
ln.historysetmaxlen(500)