mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
simplify term hint text indexing and fix lua prompt hint handler
This commit is contained in:
parent
9e21c3d4f5
commit
c819466b04
@ -85,7 +85,9 @@ if #args == 0 or options.i then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function hint(line, index)
|
local function hint(line, index)
|
||||||
line = (line or ""):sub(1, index - 1)
|
line = (line or "")
|
||||||
|
local tail = line:sub(index)
|
||||||
|
line = line:sub(1, index - 1)
|
||||||
local path = string.match(line, "[a-zA-Z_][a-zA-Z0-9_.]*$")
|
local path = string.match(line, "[a-zA-Z_][a-zA-Z0-9_.]*$")
|
||||||
if not path then return nil end
|
if not path then return nil end
|
||||||
local suffix = string.match(path, "[^.]+$") or ""
|
local suffix = string.match(path, "[^.]+$") or ""
|
||||||
@ -95,7 +97,7 @@ if #args == 0 or options.i then
|
|||||||
local r1, r2 = {}, {}
|
local r1, r2 = {}, {}
|
||||||
findKeys(t, r1, string.sub(line, 1, #line - #suffix), suffix)
|
findKeys(t, r1, string.sub(line, 1, #line - #suffix), suffix)
|
||||||
for k in pairs(r1) do
|
for k in pairs(r1) do
|
||||||
table.insert(r2, k)
|
table.insert(r2, k .. tail)
|
||||||
end
|
end
|
||||||
table.sort(r2)
|
table.sort(r2)
|
||||||
if #r2 == 1 then
|
if #r2 == 1 then
|
||||||
@ -103,10 +105,11 @@ if #args == 0 or options.i then
|
|||||||
__index=function(tbl, key)
|
__index=function(tbl, key)
|
||||||
if key==2 then
|
if key==2 then
|
||||||
local prev=tbl[1]
|
local prev=tbl[1]
|
||||||
tbl[1]=nil
|
|
||||||
local next = hint(prev,#prev+1)
|
local next = hint(prev,#prev+1)
|
||||||
for i,v in ipairs(next) do
|
if next then
|
||||||
tbl[i] = v
|
for i,v in ipairs(next) do
|
||||||
|
tbl[i] = v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
setmetatable(tbl,getmetatable(next))
|
setmetatable(tbl,getmetatable(next))
|
||||||
return tbl[1]
|
return tbl[1]
|
||||||
|
@ -517,7 +517,7 @@ function --[[@delayloaded-start@]] term.internal.tab(input,hints)
|
|||||||
c.i=(c.i+change)%math.max(#c,1)
|
c.i=(c.i+change)%math.max(#c,1)
|
||||||
local next=c[c.i+1]
|
local next=c[c.i+1]
|
||||||
if next then
|
if next then
|
||||||
local tail = unicode.wlen(input.data) - input.index - 1
|
local tail = unicode.len(input.data) - input.index
|
||||||
input:clear()
|
input:clear()
|
||||||
input:update(next)
|
input:update(next)
|
||||||
input:move(-tail)
|
input:move(-tail)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user