1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-20 18:27:40 +00:00

process improvements + new icons

This commit is contained in:
kepler155c@gmail.com
2017-09-27 15:42:40 -04:00
parent 4a608e11a2
commit 5969b71dbe
8 changed files with 113 additions and 44 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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')