mirror of
https://github.com/kepler155c/opus
synced 2025-02-28 23:00:02 +00:00
process improvements + new icons
This commit is contained in:
parent
4a608e11a2
commit
5969b71dbe
@ -68,7 +68,7 @@ return function(args)
|
||||
end
|
||||
|
||||
function selectFile.grid:draw()
|
||||
local files = fs.list(self.dir, true)
|
||||
local files = fs.listEx(self.dir)
|
||||
if #self.dir > 0 then
|
||||
table.insert(files, {
|
||||
name = '..',
|
||||
|
@ -82,16 +82,6 @@ function Util.getVersion()
|
||||
return version or 1.7
|
||||
end
|
||||
|
||||
function Util.runFunction(env, fn, ...)
|
||||
setfenv(fn, env)
|
||||
setmetatable(env, { __index = _G })
|
||||
|
||||
local args = { ... }
|
||||
return pcall(function()
|
||||
return fn(table.unpack(args))
|
||||
end)
|
||||
end
|
||||
|
||||
-- http://lua-users.org/wiki/SimpleRound
|
||||
function Util.round(num, idp)
|
||||
local mult = 10^(idp or 0)
|
||||
@ -360,7 +350,7 @@ function Util.loadTable(fname)
|
||||
return s, m
|
||||
end
|
||||
|
||||
--[[ URL functions ]] --
|
||||
--[[ loading and running functions ]] --
|
||||
function Util.download(url, filename)
|
||||
local h = http.get(url)
|
||||
if not h then
|
||||
@ -410,6 +400,14 @@ function Util.run(env, path, ...)
|
||||
return fn, m
|
||||
end
|
||||
|
||||
function Util.runFunction(env, fn, ...)
|
||||
setfenv(fn, env)
|
||||
setmetatable(env, { __index = _G })
|
||||
|
||||
local args = { ... }
|
||||
return pcall(function() return fn(table.unpack(args)) end)
|
||||
end
|
||||
|
||||
--[[ String functions ]] --
|
||||
function Util.toBytes(n)
|
||||
if n >= 1000000 or n <= -1000000 then
|
||||
|
@ -269,12 +269,18 @@ function page.grid:eventHandler(event)
|
||||
end
|
||||
|
||||
function page:rawExecute(s)
|
||||
|
||||
local fn, m = loadstring("return (" .. s .. ')', 'lua')
|
||||
if not fn then
|
||||
fn, m = loadstring(s, 'lua')
|
||||
local fn, m = loadstring('return (' .. s .. ')', 'lua')
|
||||
if fn then
|
||||
setfenv(fn, sandboxEnv)
|
||||
m = { pcall(fn) }
|
||||
fn = table.remove(m, 1)
|
||||
if #m == 1 then
|
||||
m = m[1]
|
||||
end
|
||||
return fn, m
|
||||
end
|
||||
|
||||
fn, m = loadstring(s, 'lua')
|
||||
if fn then
|
||||
setfenv(fn, sandboxEnv)
|
||||
fn, m = pcall(fn)
|
||||
@ -291,8 +297,6 @@ function page:executeStatement(statement)
|
||||
|
||||
if s and m then
|
||||
self:setResult(m)
|
||||
elseif s and type(m) == 'boolean' then
|
||||
self:setResult(m)
|
||||
else
|
||||
self.grid:setValues({ })
|
||||
self.grid:draw()
|
||||
|
@ -1,14 +1,14 @@
|
||||
requireInjector(getfenv(1))
|
||||
|
||||
local class = require('class')
|
||||
local class = require('class')
|
||||
local Config = require('config')
|
||||
local Event = require('event')
|
||||
local Event = require('event')
|
||||
local FileUI = require('ui.fileui')
|
||||
local NFT = require('nft')
|
||||
local SHA1 = require('sha1')
|
||||
local Tween = require('ui.tween')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
local NFT = require('nft')
|
||||
local SHA1 = require('sha1')
|
||||
local Tween = require('ui.tween')
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
local REGISTRY_DIR = 'usr/.registry'
|
||||
local TEMPLATE = [[
|
||||
@ -71,16 +71,15 @@ local function loadApplications()
|
||||
end
|
||||
end
|
||||
|
||||
return Util.startsWidth(a.run, 'http') or shell.resolveProgram(a.run)
|
||||
return true -- Util.startsWidth(a.run, 'http') or shell.resolveProgram(a.run)
|
||||
end)
|
||||
end
|
||||
|
||||
loadApplications()
|
||||
|
||||
local defaultIcon = NFT.parse([[
|
||||
8071180
|
||||
8007180
|
||||
7180071]])
|
||||
local defaultIcon = NFT.parse("\03180\031711\03180\
|
||||
\031800\03171\03180\
|
||||
\03171\031800\03171")
|
||||
|
||||
local sx, sy = term.current().getSize()
|
||||
local maxRecent = math.ceil(sx * sy / 62)
|
||||
@ -123,12 +122,34 @@ local function parseIcon(iconText)
|
||||
return s, m
|
||||
end
|
||||
|
||||
UI.VerticalTabBar = class(UI.TabBar)
|
||||
function UI.VerticalTabBar:init(args)
|
||||
UI.TabBar.init(self, args)
|
||||
self.x = 1
|
||||
self.width = 8
|
||||
self.rey = -1
|
||||
for k,c in pairs(self.children) do
|
||||
c.x = 1
|
||||
c.y = k + 1
|
||||
c.width = 8
|
||||
end
|
||||
end
|
||||
|
||||
local cx = 9
|
||||
local cy = 1
|
||||
if sx < 30 then
|
||||
UI.VerticalTabBar = UI.TabBar
|
||||
cx = 1
|
||||
cy = 2
|
||||
end
|
||||
|
||||
local page = UI.Page {
|
||||
tabBar = UI.TabBar {
|
||||
tabBar = UI.VerticalTabBar {
|
||||
buttons = buttons,
|
||||
},
|
||||
container = UI.ViewportWindow {
|
||||
y = 2,
|
||||
x = cx,
|
||||
y = cy,
|
||||
},
|
||||
notification = UI.Notification(),
|
||||
accelerators = {
|
||||
@ -249,13 +270,13 @@ function page.container:setCategory(categoryName)
|
||||
|
||||
-- reposition all children
|
||||
for k,child in ipairs(self.children) do
|
||||
child.x = -10
|
||||
child.x = self.width
|
||||
child.y = math.floor(self.height)
|
||||
child.tween = Tween.new(6, child, { x = col, y = row }, 'outSine')
|
||||
|
||||
if k < count then
|
||||
col = col + child.width
|
||||
if col + self.children[k + 1].width + gutter - 2 > UI.term.width then
|
||||
if col + self.children[k + 1].width + gutter - 2 > self.width then
|
||||
col = gutter
|
||||
row = row + 5
|
||||
end
|
||||
|
@ -193,12 +193,12 @@ local function launchProcess(tab)
|
||||
if tab.fn then
|
||||
result, err = Util.runFunction(tab.env, tab.fn, table.unpack(tab.args or { } ))
|
||||
elseif tab.path then
|
||||
result, err = os.run(tab.env, tab.path, table.unpack(tab.args or { } ))
|
||||
result, err = Util.run(tab.env, tab.path, table.unpack(tab.args or { } ))
|
||||
else
|
||||
err = 'multishell: invalid tab'
|
||||
end
|
||||
|
||||
if not result and err ~= 'Terminated' then
|
||||
if not result and err and err ~= 'Terminated' then
|
||||
if err then
|
||||
printError(tostring(err))
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
local parentShell = shell
|
||||
|
||||
local shell = { }
|
||||
local multishell = multishell or { }
|
||||
shell = { }
|
||||
multishell = multishell or { }
|
||||
|
||||
local sandboxEnv = setmetatable({ }, { __index = _G })
|
||||
for k,v in pairs(getfenv(1)) do
|
||||
@ -231,13 +231,31 @@ end
|
||||
|
||||
local tArgs = { ... }
|
||||
if #tArgs > 0 then
|
||||
-- "shell x y z"
|
||||
-- Run the program specified in this new shell
|
||||
local s, m = shell.run( ... )
|
||||
if not s and m and m ~= 'Terminated' then
|
||||
error(m)
|
||||
|
||||
local path, args = parseCommandLine(...)
|
||||
|
||||
if not path then
|
||||
error('No such program')
|
||||
end
|
||||
return s, m
|
||||
|
||||
local isUrl = not not path:match("^(https?:)//(([^/:]+):?([0-9]*))(/?.*)$")
|
||||
if not isUrl then
|
||||
path = shell.resolveProgram(path)
|
||||
end
|
||||
|
||||
local fn, err
|
||||
|
||||
if isUrl then
|
||||
fn, err = Util.loadUrl(path, getfenv(1))
|
||||
else
|
||||
fn, err = loadfile(path, getfenv(1))
|
||||
end
|
||||
|
||||
if not fn then
|
||||
error(err)
|
||||
end
|
||||
tProgramStack[#tProgramStack + 1] = path
|
||||
return fn(table.unpack(args))
|
||||
end
|
||||
|
||||
local Config = require('config')
|
||||
|
@ -63,6 +63,8 @@ local function runUrl(file, ...)
|
||||
error('Failed to download ' .. url)
|
||||
end
|
||||
|
||||
_G.debug = function() end
|
||||
|
||||
-- Install require shim
|
||||
if fs.exists('sys/apis/injector.lua') then
|
||||
_G.requireInjector = run('sys/apis/injector.lua')
|
||||
|
@ -228,17 +228,43 @@
|
||||
[ "53a5d150062b1e03206b9e15854b81060e3c7552" ] = {
|
||||
title = "Minesweeper",
|
||||
category = "Games",
|
||||
icon = "\030f\031f \03131\0308\031f \030f\031d2\
|
||||
\030f\031f \031d2\03131\0308\031f \030f\03131\
|
||||
\030f\03131\0308\031f \030f\03131\031e3",
|
||||
run = "http://pastebin.com/raw/nsKrHTbN",
|
||||
},
|
||||
[ "8d59207c8a84153b3e9f035cc3b6ec7a23671323" ] = {
|
||||
title = "Micropaint",
|
||||
category = "Apps",
|
||||
icon = "\030 \031f \030f \
|
||||
\030 \031f^ \0300 \030f \
|
||||
\030 \031fv \0300 \030 ",
|
||||
run = "http://pastebin.com/raw/tMRzJXx2",
|
||||
requires = "advancedComputer",
|
||||
},
|
||||
[ "d78f28759f255a0db76604ee560b87c4715a0da5" ] = {
|
||||
title = "Sketch",
|
||||
category = "Apps",
|
||||
icon = " \031bskch\
|
||||
\0303\031f \030d \
|
||||
\030d\031f ",
|
||||
run = "http://pastebin.com/raw/Mm5hd97E",
|
||||
},
|
||||
[ "58ec8d6e36e346d9f42eb43935652e3e58e2c829" ] = {
|
||||
category = "Apps",
|
||||
icon = "\030f\031f \0304 \
|
||||
\030f\031dshell]\0304\0314 \
|
||||
\0304\031f ",
|
||||
title = "Mwm",
|
||||
run = "wmw.lua usr/config/mwm",
|
||||
},
|
||||
[ "8d1b0a73bedc0dc492377c2f6ab880940b97ec6e" ] = {
|
||||
icon = "\030 \031f \0305 \030 \030d \030 \
|
||||
\0305\031f \030d \030 \030d \0305 \030d \
|
||||
\030 \031f \030c \030 \0304 \030 \030c \030 ",
|
||||
category = "Apps",
|
||||
title = "Treefarm",
|
||||
run = "treefarm.lua",
|
||||
requires = "turtle",
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user