diff --git a/sys/apis/crypto.lua b/sys/apis/crypto.lua index f01f587..4de464a 100644 --- a/sys/apis/crypto.lua +++ b/sys/apis/crypto.lua @@ -55,15 +55,14 @@ local function unserialize( s ) end end -local function sure(N,n) - if (l2-n)<1 then N="0" end - return N -end - local function splitnum(S) local Out="" for l1=1,#S,2 do local l2=(#S-l1)+1 + local function sure(N,n) + if (l2-n)<1 then N="0" end + return N + end local CNum=tonumber("0x"..sure(string.sub(S,l2-1,l2-1),1) .. sure(string.sub(S,l2,l2),0)) Out=string.char(CNum)..Out end diff --git a/sys/apps/Events.lua b/sys/apps/Events.lua index 5bf6804..9e6c534 100644 --- a/sys/apps/Events.lua +++ b/sys/apps/Events.lua @@ -50,6 +50,9 @@ function page:eventHandler(event) end self.menuBar:draw() + elseif event.type == 'grid_select' then + multishell.openTab({ path = 'sys/apps/Lua.lua', args = { event.selected }, focused = true }) + elseif event.type == 'reset' then self.filtered = { } self.grid:setValues({ }) @@ -78,12 +81,8 @@ function page:eventHandler(event) return true end -function page.grid:draw() - self:adjustWidth() - UI.Grid.draw(self) -end - -function eventLoop() +function page.grid:getDisplayValues(row) + row = Util.shallowCopy(row) local function tovalue(s) if type(s) == 'table' then @@ -92,16 +91,30 @@ function eventLoop() return s end + for k,v in pairs(row) do + row[k] = tovalue(v) + end + + return row +end + +function page.grid:draw() + self:adjustWidth() + UI.Grid.draw(self) +end + +function eventLoop() + while true do local e = { os.pullEvent() } if not page.paused and not page.filtered[e[1]] then table.insert(page.grid.values, 1, { event = e[1], - p1 = tovalue(e[2]), - p2 = tovalue(e[3]), - p3 = tovalue(e[4]), - p4 = tovalue(e[5]), - p5 = tovalue(e[6]), + p1 = e[2], + p2 = e[3], + p3 = e[4], + p4 = e[5], + p5 = e[6], }) if #page.grid.values > page.grid.height - 1 then table.remove(page.grid.values, #page.grid.values) diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index 117f635..4bc754a 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -35,6 +35,9 @@ local function loadApplications() end end end + + Util.each(applications, function(v, k) v.key = k end) + applications = Util.filter(applications, function(_, a) return not a.disabled end) end loadApplications() @@ -318,8 +321,11 @@ function page:eventHandler(event) elseif event.type == 'delete' then local focused = page:getFocused() + debug(focused.app) if focused.app then - fs.delete(focused.app.filename) + focused.app.disabled = true + local filename = focused.app.filename or fs.combine(REGISTRY_DIR, focused.app.key) + Util.writeTable(filename, focused.app) loadApplications() page:refresh() page:draw() @@ -401,10 +407,11 @@ function editor.form.image:draw() end function editor:updateApplications(app) - if not app.filename then - app.filename = 'sys/apps/.overview/' .. app.title + if not app.key then + app.key = SHA1.sha1(app.title) end - Util.writeTable(app.filename, app) + local filename = app.filename or fs.combine(REGISTRY_DIR, app.key) + Util.writeTable(filename, app) loadApplications() end