better fuzzy matching + vfs type flag in Files
This commit is contained in:
@@ -77,8 +77,8 @@ local Browser = UI.Page {
|
||||
grid = UI.ScrollingGrid {
|
||||
columns = {
|
||||
{ heading = 'Name', key = 'name' },
|
||||
{ key = 'flags', width = 2 },
|
||||
{ heading = 'Size', key = 'fsize', width = 5 },
|
||||
{ key = 'flags', width = 3, textColor = 'lightGray' },
|
||||
{ heading = 'Size', key = 'fsize', width = 5, textColor = 'yellow' },
|
||||
},
|
||||
sortColumn = 'name',
|
||||
y = 2, ey = -2,
|
||||
@@ -211,7 +211,7 @@ function Browser:enable()
|
||||
self:setFocus(self.grid)
|
||||
end
|
||||
|
||||
function Browser.menuBar:getActive(menuItem)
|
||||
function Browser.menuBar.getActive(_, menuItem)
|
||||
local file = Browser.grid:getSelected()
|
||||
if menuItem.flags == FILE then
|
||||
return file and not file.isDir
|
||||
@@ -223,7 +223,7 @@ function Browser:setStatus(status, ...)
|
||||
self.notification:info(string.format(status, ...))
|
||||
end
|
||||
|
||||
function Browser:unmarkAll()
|
||||
function Browser.unmarkAll()
|
||||
for _,m in pairs(marked) do
|
||||
m.marked = false
|
||||
end
|
||||
@@ -263,10 +263,11 @@ function Browser:updateDirectory(dir)
|
||||
dir.size = #files
|
||||
for _, file in pairs(files) do
|
||||
file.fullName = fs.combine(dir.name, file.name)
|
||||
file.flags = ''
|
||||
file.flags = file.fstype or ' '
|
||||
if not file.isDir then
|
||||
dir.totalSize = dir.totalSize + file.size
|
||||
file.fsize = formatSize(file.size)
|
||||
file.flags = file.flags .. ' '
|
||||
else
|
||||
if config.showDirSizes then
|
||||
file.size = fs.getSize(file.fullName, true)
|
||||
@@ -274,11 +275,9 @@ function Browser:updateDirectory(dir)
|
||||
dir.totalSize = dir.totalSize + file.size
|
||||
file.fsize = formatSize(file.size)
|
||||
end
|
||||
file.flags = 'D'
|
||||
end
|
||||
if file.isReadOnly then
|
||||
file.flags = file.flags .. 'R'
|
||||
file.flags = file.flags .. 'D'
|
||||
end
|
||||
file.flags = file.flags .. (file.isReadOnly and 'R' or ' ')
|
||||
if config.showHidden or file.name:sub(1, 1) ~= '.' then
|
||||
dir.files[file.fullName] = file
|
||||
end
|
||||
@@ -467,7 +466,7 @@ function Browser:eventHandler(event)
|
||||
|
||||
elseif event.type == 'paste' then
|
||||
for _,m in pairs(copied) do
|
||||
local s, m = pcall(function()
|
||||
pcall(function()
|
||||
if cutMode then
|
||||
fs.move(m.fullName, fs.combine(self.dir.name, m.name))
|
||||
else
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
local fuzzy = require('opus.fuzzy')
|
||||
local UI = require('opus.ui')
|
||||
local Util = require('opus.util')
|
||||
|
||||
@@ -42,13 +43,13 @@ UI:addPage('main', UI.Page {
|
||||
|
||||
elseif event.type == 'text_change' then
|
||||
if not event.text then
|
||||
self.grid.values = topics
|
||||
self.grid.sortColumn = 'lname'
|
||||
else
|
||||
self.grid.values = { }
|
||||
for _,f in pairs(topics) do
|
||||
if string.find(f.lname, event.text:lower()) then
|
||||
table.insert(self.grid.values, f)
|
||||
end
|
||||
self.grid.sortColumn = 'score'
|
||||
self.grid.inverseSort = false
|
||||
local pattern = event.text:lower()
|
||||
for _,v in pairs(self.grid.values) do
|
||||
v.score = -fuzzy(v.lname, pattern)
|
||||
end
|
||||
end
|
||||
self.grid:update()
|
||||
|
||||
@@ -41,7 +41,7 @@ local page = UI.Page {
|
||||
},
|
||||
description = UI.TextArea {
|
||||
x = 16, y = 3, ey = -5,
|
||||
marginRight = 0, marginLeft = 0,
|
||||
marginRight = 2, marginLeft = 0,
|
||||
},
|
||||
action = UI.SlideOut {
|
||||
titleBar = UI.TitleBar {
|
||||
@@ -140,9 +140,9 @@ function page:eventHandler(event)
|
||||
elseif event.type == 'grid_focus_row' then
|
||||
local manifest = event.selected.manifest
|
||||
|
||||
self.description.value = string.format('%s%s\n\n%s%s',
|
||||
self.description:setValue(string.format('%s%s\n\n%s%s',
|
||||
Ansi.yellow, manifest.title,
|
||||
Ansi.white, manifest.description)
|
||||
Ansi.white, manifest.description))
|
||||
self.description:draw()
|
||||
self:updateSelection(event.selected)
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ local function run(...)
|
||||
loadFn = loadfile
|
||||
end
|
||||
|
||||
local funkshun, err = loadFn(path, env)
|
||||
if not funkshun then
|
||||
local O_v_O, err = loadFn(path, env)
|
||||
if not O_v_O then
|
||||
error(err, -1)
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ local function run(...)
|
||||
}
|
||||
|
||||
env[ "arg" ] = { [0] = path, table.unpack(args) }
|
||||
local r = { funkshun(table.unpack(args)) }
|
||||
local r = { O_v_O(table.unpack(args)) }
|
||||
|
||||
tProgramStack[#tProgramStack] = nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user