From b1a24235ea1895c1c66a5d5cff49ffd4405ff554 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sat, 9 Nov 2019 21:17:07 -0700 Subject: [PATCH] package manager wip --- common/Events.lua | 34 +++++++++++++++++++++------------- lzwfs/.package | 13 +++++++++++++ lzwfs/autorun/install.lua | 6 +++--- minify/minifyDir.lua | 2 +- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/common/Events.lua b/common/Events.lua index 0dcd164..6a0dd2c 100644 --- a/common/Events.lua +++ b/common/Events.lua @@ -113,8 +113,28 @@ function page.grid:draw() end local updated = false +local timerId = os.startTimer(1) + +Event.addRoutine(function() + while true do + local _, id = os.pullEvent('timer') + if id == timerId then + if updated then + while #page.grid.values > 100 do -- page.grid.height do + table.remove(page.grid.values, 100) -- #page.grid.values) + end + updated = false + page.grid:update() + page.grid:draw() + page:sync() + end + timerId = os.startTimer(1) + end + end +end) + local hookFunction = function(event, e) - if not page.filtered[event] and not page.paused then + if not page.filtered[event] and not page.paused and not (event == 'timer' and e[1] == timerId) then updated = true table.insert(page.grid.values, 1, { event = event, @@ -129,18 +149,6 @@ end kernel.hook('*', hookFunction) -Event.onInterval(1, function() - if updated then - while #page.grid.values > 100 do -- page.grid.height do - table.remove(page.grid.values, 100) -- #page.grid.values) - end - updated = false - page.grid:update() - page.grid:draw() - page:sync() - end -end) - UI:setPage(page) UI:pullEvents() diff --git a/lzwfs/.package b/lzwfs/.package index 3df8991..830cedf 100644 --- a/lzwfs/.package +++ b/lzwfs/.package @@ -3,4 +3,17 @@ repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/lzwfs', description = [[ Disk compression ]], license = 'MIT', + install = [[ + local Util = require('opus.util') + local boot = Util.readTable('.startup.boot') + table.insert(boot.preload, 1, '/packages/lzwfs/startup.lua') + Util.writeTable('.startup.boot', boot) + ]], + uninstall = [[ + local Array = require('opus.array') + local Util = require('opus.util') + local boot = Util.readTable('.startup.boot') + Array.removeByValue(boot.preload or { }, '/packages/lzwfs/startup.lua') + Util.writeTable('.startup.boot', boot) + ]] } diff --git a/lzwfs/autorun/install.lua b/lzwfs/autorun/install.lua index b251e24..04d79ec 100644 --- a/lzwfs/autorun/install.lua +++ b/lzwfs/autorun/install.lua @@ -15,13 +15,13 @@ if not config.installed then -- insert lzwfs into boot startup local boot = Util.readTable('.startup.boot') table.insert(boot.preload, 1, '/packages/lzwfs/startup.lua') - Util.writeTable('.startup.boot', boot) + --Util.writeTable('.startup.boot', boot) -- update config config.installed = true - Config.update('lzwfs', config) + --Config.update('lzwfs', config) print('Installing lzwfs - rebooting in 3 seconds') os.sleep(3) - os.reboot() + --os.reboot() end diff --git a/minify/minifyDir.lua b/minify/minifyDir.lua index dd9cdd2..8aa6932 100644 --- a/minify/minifyDir.lua +++ b/minify/minifyDir.lua @@ -10,7 +10,7 @@ local function recurse(path) end elseif path:match('%.lua$') and not fs.isReadOnly(path) then local sz = fs.getSize(path) - shell.run('packages/minify/minify.lua minify ' .. path) + shell.run('minify.lua minify ' .. path) print(string.format('%s : %.2f%%', path, (sz - fs.getSize(path)) / sz * 100)) end end