better fuzzy searching

This commit is contained in:
kepler155c@gmail.com
2020-05-19 17:06:30 -06:00
parent 3d5f665b59
commit 2c27787f27
11 changed files with 2331 additions and 46 deletions

9
collections/.package Normal file
View File

@@ -0,0 +1,9 @@
{
title = 'Collections',
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/collections',
description = [[Collections (rework)
See: https://github.com/imliam/Lua-Collections
Collections are like tables on steroids. They are designed to act as a fluent wrapper when working with structured data, offering the developer convenience for common tasks.]],
license = 'MIT',
}

1257
collections/apis/init.lua Normal file

File diff suppressed because it is too large Load Diff

1
collections/etc/fstab Normal file
View File

@@ -0,0 +1 @@
packages/collections/tests/tests.lua urlfs https://raw.githubusercontent.com/imliam/Lua-Collections/master/tests.lua

1030
collections/tests/tests.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -362,29 +362,21 @@ local page = UI.Page {
event = 'slide_hide', event = 'slide_hide',
}, },
apply_filter = function(self, filter) apply_filter = function(self, filter)
local t = { }
if filter then if filter then
filter = filter:lower() filter = filter:lower()
self.grid.sortColumn = 'score' self.grid.sortColumn = 'score'
self.grid.inverseSort = true
for _,v in pairs(self.listing) do for _,v in pairs(self.grid.values) do
v.score = fuzzy(v.lname, filter) v.score = -fuzzy(v.lname, filter)
if v.score then
_insert(t, v)
end
end end
else else
self.grid.sortColumn = 'lname' self.grid.sortColumn = 'lname'
self.grid.inverseSort = false
t = self.listing
end end
self.grid:setValues(t) self.grid:update()
self.grid:setIndex(1) self.grid:setIndex(1)
end, end,
show = function(self) show = function(self)
local listing = { }
local function recurse(dir) local function recurse(dir)
local files = fs.list(dir) local files = fs.list(dir)
for _,f in ipairs(files) do for _,f in ipairs(files) do
@@ -392,7 +384,7 @@ local page = UI.Page {
if fs.native.isDir(fullName) then -- skip virtual dirs if fs.native.isDir(fullName) then -- skip virtual dirs
if f ~= '.git' then recurse(fullName) end if f ~= '.git' then recurse(fullName) end
else else
_insert(listing, { _insert(self.grid.values, {
name = f, name = f,
dir = dir, dir = dir,
lname = f:lower(), lname = f:lower(),
@@ -402,7 +394,6 @@ local page = UI.Page {
end end
end end
recurse('') recurse('')
self.listing = listing
self:apply_filter() self:apply_filter()
self.filter_entry:reset() self.filter_entry:reset()
UI.SlideOut.show(self) UI.SlideOut.show(self)
@@ -1015,44 +1006,40 @@ actions = {
actions.error('open available with multishell') actions.error('open available with multishell')
return return
end end
local routine = {
focused = true,
title = fs.getName(fileInfo.path),
chainExit = function(_, result)
-- display results of process before closing window
if result then -- clean exit
-- any errors will be picked up by multishells
-- error handling
print('Press enter to exit')
while true do
local e, code = os.pullEventRaw('key')
if e == 'terminate' or e == 'key' and code == keys.enter then
break
end
end
end
end,
}
if undo.chain[#undo.chain] == lastSave then if undo.chain[#undo.chain] == lastSave then
local nTask = shell.openTab(fileInfo.path) routine.path = 'sys/apps/shell.lua'
if nTask then routine.args = { fileInfo.path }
shell.switchTab(nTask)
else
actions.error("error starting Task")
end
else else
local fn, msg = load(_concat(tLines, '\n'), fileInfo.path) local fn, msg = load(_concat(tLines, '\n'), fileInfo.path)
if fn then if not fn then
multishell.openTab(_ENV, {
fn = fn,
focused = true,
title = fs.getName(fileInfo.path),
chainExit = function(_, result)
-- display results of process before
-- closing window
if result then -- clean exit
-- any errors will be picked up by multishells
-- error handling
print('Press enter to exit')
while true do
local e, code = os.pullEventRaw('key')
if e == 'terminate' or e == 'key' and code == keys.enter then
break
end
end
end
end,
})
else
local ln = msg:match(':(%d+):') local ln = msg:match(':(%d+):')
if ln and tonumber(ln) then if ln and tonumber(ln) then
actions.go_to(1, tonumber(ln)) actions.go_to(1, tonumber(ln))
end end
actions.error(msg) actions.error(msg)
return
end end
routine.fn = fn
end end
multishell.openTab(_ENV, routine)
end, end,
status = function() status = function()

View File

@@ -3,4 +3,5 @@ packages/common/hexedit.lua urlfs https://pastebin.com/raw/Ds9ajsp4
packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ignore/colors.lua packages/common/colors.lua urlfs https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/ignore/colors.lua
packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw packages/common/cowsay.lua urlfs https://pastebin.com/raw/n00VQJsw
packages/common/calc.lua urlfs https://pastebin.com/raw/nAinUn1h packages/common/calc.lua urlfs https://pastebin.com/raw/nAinUn1h
packages/common/write.lua urlfs https://pastebin.com/raw/RSyhCjqv packages/common/write.lua urlfs https://pastebin.com/raw/RSyhCjqv
packages/common/apis/debugger.lua urlfs https://raw.githubusercontent.com/slembcke/debugger.lua/master/debugger.lua

View File

@@ -1 +1 @@
rom/modules/main/lfs.lua linkfs /packages/lfs/lfs.lua packages/lfs/tests/test.lua urlfs https://raw.githubusercontent.com/keplerproject/luafilesystem/master/tests/test.lua

View File

@@ -318,7 +318,7 @@ function page:applyFilter()
v.score = fuzzy(v.lname, filter) v.score = fuzzy(v.lname, filter)
if v.score then if v.score then
if v.count > 0 then if v.count > 0 then
v.score = v.score + 1 v.score = v.score + .2
end end
table.insert(r, v) table.insert(r, v)
end end

View File

@@ -390,7 +390,7 @@ function page:applyFilter()
v.score = fuzzy(v.lname, filter) v.score = fuzzy(v.lname, filter)
if v.score then if v.score then
if v.count > 0 then if v.count > 0 then
v.score = v.score + 1 v.score = v.score + .2
end end
table.insert(r, v) table.insert(r, v)
end end

View File

@@ -1 +1 @@
rom/modules/main/pl gitfs Tieske/Penlight/master/lua/pl #rom/modules/main/pl gitfs Tieske/Penlight/master/lua/pl