mirror of
https://github.com/holub/mame
synced 2025-06-30 16:00:01 +03:00
plugins/console: better completions (nw)
This commit is contained in:
parent
2de04414ed
commit
fad9a96cb0
@ -37,11 +37,12 @@ function console.startplugin()
|
|||||||
return type(t) == 'table' or (mt and mt.__pairs)
|
return type(t) == 'table' or (mt and mt.__pairs)
|
||||||
end
|
end
|
||||||
local comps = ","
|
local comps = ","
|
||||||
local table, last = str:match("([(]?[%w.:()]-)[:.]?([%w]*)$")
|
local table = str:match("([(]?[%w.:()]-)[:.]?[%w_]*$")
|
||||||
if last == "" then
|
local rest, last = str:match("(.-[:.]?)([%w_]*)$")
|
||||||
return comps
|
|
||||||
end
|
|
||||||
local err
|
local err
|
||||||
|
if table == "" then
|
||||||
|
table = "_G"
|
||||||
|
end
|
||||||
err, tablef = pcall(load("return " .. table))
|
err, tablef = pcall(load("return " .. table))
|
||||||
if (not err) or (not tablef) then
|
if (not err) or (not tablef) then
|
||||||
return comps
|
return comps
|
||||||
@ -49,7 +50,15 @@ function console.startplugin()
|
|||||||
if is_pair_iterable(tablef) then
|
if is_pair_iterable(tablef) then
|
||||||
for k, v in pairs(tablef) do
|
for k, v in pairs(tablef) do
|
||||||
if k:match("^" .. last) then
|
if k:match("^" .. last) then
|
||||||
comps = comps .. "," .. table
|
comps = comps .. "," .. rest .. k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local tablef = getmetatable(tablef)
|
||||||
|
if is_pair_iterable(tablef) then
|
||||||
|
for k, v in pairs(tablef) do
|
||||||
|
if k:match("^" .. last) then
|
||||||
|
comps = comps .. "," .. rest .. k
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user