mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 02:12:42 -04:00
fix term ctrl key (regression), fix grep display
This commit is contained in:
parent
a4dc3e3517
commit
cfe97d8327
@ -152,13 +152,13 @@ if ignore_case then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getAllFiles(dir, file_list)
|
local function getAllFiles(dir, file_list)
|
||||||
local spath = shell.resolve(dir)
|
for node in fs.list(shell.resolve(dir)) do
|
||||||
for node in fs.list(spath) do
|
local rel_path = dir:gsub("/+$","") .. '/' .. node
|
||||||
local node_path = shell.resolve(spath ..'/'.. node)
|
local resolved_path = shell.resolve(rel_path)
|
||||||
if fs.isDirectory(node_path) then
|
if fs.isDirectory(resolved_path) then
|
||||||
getAllFiles(node_path, file_list)
|
getAllFiles(rel_path, file_list)
|
||||||
else
|
else
|
||||||
file_list[#file_list+1] = node_path
|
file_list[#file_list+1] = rel_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -248,36 +248,52 @@ end
|
|||||||
local ec = nil
|
local ec = nil
|
||||||
local any_hit_ec = 1
|
local any_hit_ec = 1
|
||||||
local function test(m,p)
|
local function test(m,p)
|
||||||
local match = {}
|
local empty_line = true
|
||||||
local i, j = m.line:find(p, 1, plain)
|
local last_index, slen = 1, #m.line
|
||||||
if i then
|
local needs_filename, needs_line_num = include_filename, print_line_num
|
||||||
match.word = not match_whole_word or not (m.line:sub(i-1,i-1)..m.line:sub(j+1,j+1)):find("[%a_]")
|
local hit_value = 1
|
||||||
match.line = not match_whole_line or i==1 and j==#m.line
|
while last_index <= slen and not m.close do
|
||||||
|
local i, j = m.line:find(p, last_index, plain)
|
||||||
|
local word_fail, line_fail =
|
||||||
|
match_whole_word and not (i and not (m.line:sub(i-1,i-1)..m.line:sub(j+1,j+1)):find("[%a_]")),
|
||||||
|
match_whole_line and not (i==1 and j==slen)
|
||||||
|
local matched = not ((m_only or last_index==1) and not i)
|
||||||
|
if (hit_value == 1 and word_fail) or line_fail then
|
||||||
|
matched,i,j = false
|
||||||
end
|
end
|
||||||
if invert_match == not not (i and match.word and match.line) then return end
|
if invert_match == matched then break end
|
||||||
if max_matches == 0 then os.exit(1) end
|
if max_matches == 0 then os.exit(1) end
|
||||||
any_hit_ec = 0
|
any_hit_ec = 0
|
||||||
m.hits = m.hits + 1
|
m.hits, hit_value = m.hits + hit_value, 0
|
||||||
if max_matches == m.hits or f_only or no_only then
|
if max_matches == m.hits or f_only or no_only then
|
||||||
m.close = true
|
m.close = true
|
||||||
end
|
end
|
||||||
if flush or quiet then return end
|
if flush or quiet then return end
|
||||||
if include_filename then
|
if needs_filename then
|
||||||
write(m.label, LABEL_COLOR)
|
write(m.label, LABEL_COLOR)
|
||||||
write(':', COLON_COLOR)
|
write(':', COLON_COLOR)
|
||||||
|
needs_filename = nil
|
||||||
end
|
end
|
||||||
if print_line_num then
|
if needs_line_num then
|
||||||
write(m.line_num, LINE_NUM_COLOR)
|
write(m.line_num, LINE_NUM_COLOR)
|
||||||
write(':', COLON_COLOR)
|
write(':', COLON_COLOR)
|
||||||
|
needs_line_num = nil
|
||||||
end
|
end
|
||||||
local p=m_only and '' or trim_front(i and m.line:sub(1,i-1) or m.line)
|
local p=m_only and '' or m.line:sub(last_index,(i or 0)-1)
|
||||||
local g=i and m.line:sub(i,j) or ''
|
local g=i and m.line:sub(i,j) or ''
|
||||||
local s=m_only and '' or trim_back(i and m.line:sub(j+1,-1) or '')
|
if i==1 then g=trim_front(g) elseif last_index==1 then p=trim_front(p) end
|
||||||
if p==''then g=trim_front(g) end
|
if j==slen then g=trim_back(g) elseif not i then p=trim_back(p) end
|
||||||
if s==''then g=trim_back(g) end
|
|
||||||
write(p)
|
write(p)
|
||||||
write(g, MATCH_COLOR)
|
write(g, MATCH_COLOR)
|
||||||
write(s..'\n')
|
empty_line = false
|
||||||
|
last_index = (j or slen)+1
|
||||||
|
if m_only or last_index>slen then
|
||||||
|
write("\n")
|
||||||
|
empty_line = true
|
||||||
|
needs_filename, needs_line_num = include_filename, print_line_num
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not empty_line then write("\n") end
|
||||||
end
|
end
|
||||||
for meta,status in readLines() do
|
for meta,status in readLines() do
|
||||||
if not meta then
|
if not meta then
|
||||||
|
@ -202,12 +202,13 @@ function term.readKeyboard(ops)
|
|||||||
end
|
end
|
||||||
while true do
|
while true do
|
||||||
local name, address, char, code = term.internal.pull(input)
|
local name, address, char, code = term.internal.pull(input)
|
||||||
local c, ctrl = nil, kb.isControlDown(address)
|
local c = nil
|
||||||
hints.cache=char==9 and hints.cache or nil
|
hints.cache=char==9 and hints.cache or nil
|
||||||
if name =="interrupted" then draw("^C\n",true) return ""
|
if name =="interrupted" then draw("^C\n",true) return ""
|
||||||
elseif name=="touch" or name=="drag" then term.internal.onTouch(input,char,code)
|
elseif name=="touch" or name=="drag" then term.internal.onTouch(input,char,code)
|
||||||
elseif name=="clipboard" then c=char
|
elseif name=="clipboard" then c=char
|
||||||
elseif name=="key_down" then
|
elseif name=="key_down" then
|
||||||
|
local ctrl = kb.isControlDown(address)
|
||||||
if ctrl and code == keys.d then return
|
if ctrl and code == keys.d then return
|
||||||
elseif char==9 then term.internal.tab(input,hints)
|
elseif char==9 then term.internal.tab(input,hints)
|
||||||
elseif char==13 and filter(input) then
|
elseif char==13 and filter(input) then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user