mirror of
https://github.com/kepler155c/opus
synced 2025-01-03 20:30:28 +00:00
resizing + injector fixes
This commit is contained in:
parent
72b3c7bac9
commit
8c1abb21ca
@ -103,17 +103,21 @@ return function(env)
|
|||||||
local sPath = string.gsub(pattern, "%?", fname)
|
local sPath = string.gsub(pattern, "%?", fname)
|
||||||
-- TODO: if there's no shell, we should not be checking relative paths below
|
-- TODO: if there's no shell, we should not be checking relative paths below
|
||||||
-- as they will resolve to root directory
|
-- as they will resolve to root directory
|
||||||
if env.shell and type(env.shell.getRunningProgram) == 'function' and sPath:sub(1, 1) ~= "/" then
|
if sPath:match("^(https?:)") then
|
||||||
sPath = fs.combine(fs.getDir(env.shell.getRunningProgram() or ''), sPath)
|
|
||||||
end
|
|
||||||
if fs.exists(sPath) and not fs.isDir(sPath) then
|
|
||||||
return loadfile(sPath, env)
|
|
||||||
elseif sPath:match("^(https?:)") then
|
|
||||||
print('loading ' .. sPath)
|
|
||||||
local c = loadUrl(sPath)
|
local c = loadUrl(sPath)
|
||||||
if c then
|
if c then
|
||||||
return load(c, modname, nil, env)
|
return load(c, modname, nil, env)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if env.shell and
|
||||||
|
type(env.shell.getRunningProgram) == 'function' and
|
||||||
|
sPath:sub(1, 1) ~= "/" then
|
||||||
|
|
||||||
|
sPath = fs.combine(fs.getDir(env.shell.getRunningProgram() or ''), sPath)
|
||||||
|
end
|
||||||
|
if fs.exists(sPath) and not fs.isDir(sPath) then
|
||||||
|
return loadfile(sPath, env)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -101,12 +101,17 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
|
|||||||
win.setTextColour = win.setTextColor
|
win.setTextColour = win.setTextColor
|
||||||
|
|
||||||
function win.getPaletteColor(n)
|
function win.getPaletteColor(n)
|
||||||
return parent.getPaletteColor(n)
|
if parent.getPaletteColor then
|
||||||
|
return parent.getPaletteColor(n)
|
||||||
|
end
|
||||||
|
return 0, 0, 0
|
||||||
end
|
end
|
||||||
win.getPaletteColour = win.getPaletteColor
|
win.getPaletteColour = win.getPaletteColor
|
||||||
|
|
||||||
function win.setPaletteColor(n, r, g, b)
|
function win.setPaletteColor(n, r, g, b)
|
||||||
return parent.setPaletteColor(n, r, g, b)
|
if parent.setPaletteColor then
|
||||||
|
return parent.setPaletteColor(n, r, g, b)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
win.setPaletteColour = win.setPaletteColor
|
win.setPaletteColour = win.setPaletteColor
|
||||||
|
|
||||||
|
@ -504,9 +504,7 @@ function UI.Window:layout()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- bad name... should be called something like postInit
|
-- Called when the window's parent has be assigned
|
||||||
-- normally used to determine sizes since the parent is
|
|
||||||
-- only known at this point
|
|
||||||
function UI.Window:setParent()
|
function UI.Window:setParent()
|
||||||
self.oh, self.ow = self.height, self.width
|
self.oh, self.ow = self.height, self.width
|
||||||
self.ox, self.oy = self.x, self.y
|
self.ox, self.oy = self.x, self.y
|
||||||
|
@ -66,6 +66,7 @@ function Canvas:resize(w, h)
|
|||||||
for i = 1, self.height do
|
for i = 1, self.height do
|
||||||
self.lines[i] = { dirty = true }
|
self.lines[i] = { dirty = true }
|
||||||
end
|
end
|
||||||
|
self:clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.ex = self.x + w - 1
|
self.ex = self.x + w - 1
|
||||||
@ -261,10 +262,20 @@ function Canvas:applyPalette(palette)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Canvas:render(device)
|
function Canvas:render(device)
|
||||||
|
local offset = { x = 0, y = 0 }
|
||||||
|
local parent = self.parent
|
||||||
|
while parent do
|
||||||
|
offset.x = offset.x + parent.x - 1
|
||||||
|
offset.y = offset.y + parent.y - 1
|
||||||
|
parent = parent.parent
|
||||||
|
end
|
||||||
if #self.layers > 0 then
|
if #self.layers > 0 then
|
||||||
self:__renderLayers(device, { x = 0, y = 0 })
|
self:__renderLayers(device, offset)
|
||||||
else
|
else
|
||||||
self:__blitRect(device)
|
self:__blitRect(device, nil, {
|
||||||
|
x = self.x + offset.x,
|
||||||
|
y = self.y + offset.y
|
||||||
|
})
|
||||||
self:clean()
|
self:clean()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -316,14 +327,10 @@ function Canvas:__renderLayers(device, offset)
|
|||||||
self.regions = nil
|
self.regions = nil
|
||||||
|
|
||||||
else
|
else
|
||||||
offset = { x = self.x, y = self.y }
|
self:__blitRect(device, nil, {
|
||||||
local parent = self.parent
|
x = self.x + offset.x,
|
||||||
while parent do
|
y = self.y + offset.y
|
||||||
offset.x = offset.x + parent.x - 1
|
})
|
||||||
offset.y = offset.y + parent.y - 1
|
|
||||||
parent = parent.parent
|
|
||||||
end
|
|
||||||
self:__blitRect(device, nil, offset)
|
|
||||||
self.regions = nil
|
self.regions = nil
|
||||||
end
|
end
|
||||||
self:clean()
|
self:clean()
|
||||||
|
@ -7,12 +7,13 @@ UI.SlideOut.defaults = {
|
|||||||
UIElement = 'SlideOut',
|
UIElement = 'SlideOut',
|
||||||
pageType = 'modal',
|
pageType = 'modal',
|
||||||
}
|
}
|
||||||
function UI.SlideOut:setParent()
|
function UI.SlideOut:layout()
|
||||||
-- TODO: size should be set at this point
|
UI.Window.layout(self)
|
||||||
self:layout()
|
if not self.canvas then
|
||||||
self.canvas = self:addLayer()
|
self.canvas = self:addLayer()
|
||||||
|
else
|
||||||
UI.Window.setParent(self)
|
self.canvas:resize(self.width, self.height)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.SlideOut:enable()
|
function UI.SlideOut:enable()
|
||||||
|
@ -19,9 +19,13 @@ UI.Viewport.defaults = {
|
|||||||
[ 'control-f' ] = 'scroll_pageDown',
|
[ 'control-f' ] = 'scroll_pageDown',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
function UI.Viewport:setParent()
|
function UI.Viewport:layout()
|
||||||
UI.Window.setParent(self)
|
UI.Window.layout(self)
|
||||||
self.canvas = self:addLayer()
|
if not self.canvas then
|
||||||
|
self.canvas = self:addLayer()
|
||||||
|
else
|
||||||
|
self.canvas:resize(self.width, self.height)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UI.Viewport:enable()
|
function UI.Viewport:enable()
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
_G.requireInjector(_ENV)
|
if not _G.requireInjector then
|
||||||
|
local BASE ='https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/apis'
|
||||||
|
_ENV.LUA_PATH=BASE .. '/?.lua'
|
||||||
|
load(_G.http.get(BASE .. '/injector.lua').readAll())()(_ENV)
|
||||||
|
end
|
||||||
|
|
||||||
local History = require('history')
|
local History = require('history')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
|
@ -100,10 +100,11 @@ local page = UI.Page {
|
|||||||
newApp = UI.Button {
|
newApp = UI.Button {
|
||||||
text = '+', event = 'new',
|
text = '+', event = 'new',
|
||||||
},
|
},
|
||||||
|
--[[
|
||||||
volume = UI.Button {
|
volume = UI.Button {
|
||||||
x = 3,
|
x = 3,
|
||||||
text = '\15', event = 'volume',
|
text = '\15', event = 'volume',
|
||||||
}
|
},]]
|
||||||
},
|
},
|
||||||
editor = UI.SlideOut {
|
editor = UI.SlideOut {
|
||||||
y = -12, height = 12,
|
y = -12, height = 12,
|
||||||
|
@ -57,6 +57,7 @@ local page = UI.Page {
|
|||||||
},
|
},
|
||||||
output = UI.Embedded {
|
output = UI.Embedded {
|
||||||
y = 5, ey = -2, x = 2, ex = -2,
|
y = 5, ey = -2, x = 2, ex = -2,
|
||||||
|
visible = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
statusBar = UI.StatusBar { },
|
statusBar = UI.StatusBar { },
|
||||||
|
@ -44,5 +44,6 @@ end
|
|||||||
shell.setPath(table.concat(path, ':'))
|
shell.setPath(table.concat(path, ':'))
|
||||||
|
|
||||||
_G.LUA_PATH = config.lua_path
|
_G.LUA_PATH = config.lua_path
|
||||||
|
_G.settings.set('require.path', config.lua_path)
|
||||||
|
|
||||||
fs.loadTab('usr/config/fstab')
|
fs.loadTab('usr/config/fstab')
|
||||||
|
Loading…
Reference in New Issue
Block a user