mirror of https://github.com/kepler155c/opus
scrolling windows
This commit is contained in:
parent
48f16ce2c7
commit
e25f4f9319
|
@ -261,6 +261,13 @@ function page:eventHandler(event)
|
||||||
event.focused.parent:scrollIntoView()
|
event.focused.parent:scrollIntoView()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif event.type == 'tab_change' then
|
||||||
|
if event.current > event.last then
|
||||||
|
self.container:setTransition('left')
|
||||||
|
else
|
||||||
|
self.container:setTransition('right')
|
||||||
|
end
|
||||||
|
|
||||||
elseif event.type == 'refresh' then
|
elseif event.type == 'refresh' then
|
||||||
applications = { }
|
applications = { }
|
||||||
Config.load('apps', applications)
|
Config.load('apps', applications)
|
||||||
|
|
|
@ -6,23 +6,23 @@ local UI = require('ui')
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Devices')
|
multishell.setTitle(multishell.getCurrent(), 'Devices')
|
||||||
|
|
||||||
--[[ -- PeripheralsPage -- ]] --
|
--[[ -- PeripheralsPage -- ]] --
|
||||||
local peripheralsPage = UI.Page({
|
local peripheralsPage = UI.Page {
|
||||||
grid = UI.ScrollingGrid({
|
grid = UI.ScrollingGrid {
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Type', key = 'type' },
|
{ heading = 'Type', key = 'type' },
|
||||||
{ heading = 'Side', key = 'side' }
|
{ heading = 'Side', key = 'side' },
|
||||||
},
|
},
|
||||||
sortColumn = 'type',
|
sortColumn = 'type',
|
||||||
height = UI.term.height - 1,
|
height = UI.term.height - 1,
|
||||||
autospace = true,
|
autospace = true,
|
||||||
}),
|
},
|
||||||
statusBar = UI.StatusBar({
|
statusBar = UI.StatusBar {
|
||||||
status = 'Select peripheral'
|
status = 'Select peripheral'
|
||||||
}),
|
},
|
||||||
accelerators = {
|
accelerators = {
|
||||||
q = 'quit',
|
q = 'quit',
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
function peripheralsPage.grid:draw()
|
function peripheralsPage.grid:draw()
|
||||||
local sides = peripheral.getNames()
|
local sides = peripheral.getNames()
|
||||||
|
@ -40,7 +40,6 @@ function peripheralsPage.grid:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function peripheralsPage:updatePeripherals()
|
function peripheralsPage:updatePeripherals()
|
||||||
|
|
||||||
if UI:getCurrentPage() == self then
|
if UI:getCurrentPage() == self then
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
self:sync()
|
self:sync()
|
||||||
|
@ -59,29 +58,27 @@ function peripheralsPage:eventHandler(event)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ -- MethodsPage -- ]] --
|
--[[ -- MethodsPage -- ]] --
|
||||||
local methodsPage = UI.Page({
|
local methodsPage = UI.Page {
|
||||||
grid = UI.ScrollingGrid({
|
grid = UI.ScrollingGrid {
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'name', width = UI.term.width }
|
{ heading = 'Name', key = 'name', width = UI.term.width }
|
||||||
},
|
},
|
||||||
sortColumn = 'name',
|
sortColumn = 'name',
|
||||||
height = 7,
|
height = 7,
|
||||||
}),
|
},
|
||||||
container = UI.Window({
|
viewportConsole = UI.ViewportWindow {
|
||||||
y = 8,
|
y = 8,
|
||||||
height = UI.term.height-8,
|
height = UI.term.height - 8,
|
||||||
viewportConsole = UI.ViewportWindow({
|
backgroundColor = colors.brown,
|
||||||
backgroundColor = colors.brown
|
},
|
||||||
}),
|
statusBar = UI.StatusBar {
|
||||||
}),
|
|
||||||
statusBar = UI.StatusBar({
|
|
||||||
status = 'q to return',
|
status = 'q to return',
|
||||||
}),
|
},
|
||||||
accelerators = {
|
accelerators = {
|
||||||
q = 'back',
|
q = 'back',
|
||||||
backspace = 'back',
|
backspace = 'back',
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
function methodsPage:enable(p)
|
function methodsPage:enable(p)
|
||||||
|
|
||||||
|
@ -103,6 +100,8 @@ function methodsPage:enable(p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.viewportConsole.offy = 0
|
||||||
|
|
||||||
self.grid:update()
|
self.grid:update()
|
||||||
self.grid:setIndex(1)
|
self.grid:setIndex(1)
|
||||||
|
|
||||||
|
@ -110,31 +109,26 @@ function methodsPage:enable(p)
|
||||||
UI.Page.enable(self)
|
UI.Page.enable(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function methodsPage.container.viewportConsole:draw()
|
|
||||||
if methodsPage.grid:getSelected() then
|
|
||||||
methodsPage:drawMethodInfo(self, methodsPage.grid:getSelected())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function methodsPage:eventHandler(event)
|
function methodsPage:eventHandler(event)
|
||||||
if event.type == 'back' then
|
if event.type == 'back' then
|
||||||
UI:setPage(peripheralsPage)
|
UI:setPage(peripheralsPage)
|
||||||
return true
|
return true
|
||||||
elseif event.type == 'grid_focus_row' then
|
elseif event.type == 'grid_focus_row' then
|
||||||
self.container.viewportConsole.height = 1
|
self.viewportConsole.offy = 0
|
||||||
self.container.viewportConsole.offset = 0
|
self.viewportConsole:draw()
|
||||||
self.container.viewportConsole.y = 1
|
|
||||||
self:drawMethodInfo(self.container.viewportConsole, event.selected)
|
|
||||||
end
|
end
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|
||||||
function methodsPage:drawMethodInfo(c, method)
|
function methodsPage.viewportConsole:draw()
|
||||||
|
local c = self
|
||||||
|
local method = methodsPage.grid:getSelected()
|
||||||
|
|
||||||
c:clear()
|
c:clear()
|
||||||
c:setCursorPos(1, 1)
|
c:setCursorPos(1, 1)
|
||||||
|
|
||||||
if method.noext then
|
if method.noext then
|
||||||
|
c.cursorY = 2
|
||||||
c:print('No extended Information')
|
c:print('No extended Information')
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
|
@ -189,10 +183,7 @@ function methodsPage:drawMethodInfo(c, method)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
c.height = c.cursorY + 1
|
c.ymax = c.cursorY + 1
|
||||||
|
|
||||||
term.setBackgroundColor(colors.black)
|
|
||||||
return y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.addHandler('peripheral', function()
|
Event.addHandler('peripheral', function()
|
||||||
|
|
|
@ -11,73 +11,79 @@ local env = {
|
||||||
aliases = shell.aliases(),
|
aliases = shell.aliases(),
|
||||||
lua_path = LUA_PATH,
|
lua_path = LUA_PATH,
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.load('multishell', env)
|
Config.load('multishell', env)
|
||||||
|
|
||||||
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
UI.TextEntry.defaults.backgroundFocusColor = colors.black
|
||||||
|
|
||||||
local systemPage = UI.Page({
|
local systemPage = UI.Page {
|
||||||
backgroundColor = colors.blue,
|
backgroundColor = colors.blue,
|
||||||
tabs = UI.Tabs({
|
tabs = UI.Tabs {
|
||||||
pathTab = UI.Window({
|
pathTab = UI.Window {
|
||||||
tabTitle = 'Path',
|
tabTitle = 'Path',
|
||||||
entry = UI.TextEntry({
|
entry = UI.TextEntry {
|
||||||
y = 2, x = 2, limit = 256,
|
x = 2, y = 2, rex = -2,
|
||||||
width = UI.term.width - 2,
|
limit = 256,
|
||||||
value = shell.path(),
|
value = shell.path(),
|
||||||
shadowText = 'enter system path',
|
shadowText = 'enter system path',
|
||||||
accelerators = {
|
accelerators = {
|
||||||
enter = 'update_path',
|
enter = 'update_path',
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
grid = UI.Grid({
|
grid = UI.Grid {
|
||||||
y = 4,
|
y = 4,
|
||||||
values = paths,
|
values = paths,
|
||||||
disableHeader = true,
|
disableHeader = true,
|
||||||
columns = { { key = 'value' } },
|
columns = { { key = 'value' } },
|
||||||
autospace = true,
|
autospace = true,
|
||||||
}),
|
},
|
||||||
}),
|
},
|
||||||
|
|
||||||
aliasTab = UI.Window({
|
aliasTab = UI.Window {
|
||||||
tabTitle = 'Aliases',
|
tabTitle = 'Aliases',
|
||||||
alias = UI.TextEntry({
|
alias = UI.TextEntry {
|
||||||
y = 2, x = 2, width = UI.term.width - 2,
|
x = 2, y = 2, rex = -2,
|
||||||
limit = 32,
|
limit = 32,
|
||||||
shadowText = 'Alias',
|
shadowText = 'Alias',
|
||||||
}),
|
},
|
||||||
path = UI.TextEntry({
|
path = UI.TextEntry {
|
||||||
y = 3, x = 2, width = UI.term.width - 2, limit = 256,
|
y = 3, x = 2, rex = -2,
|
||||||
|
limit = 256,
|
||||||
shadowText = 'Program path',
|
shadowText = 'Program path',
|
||||||
accelerators = {
|
accelerators = {
|
||||||
enter = 'new_alias',
|
enter = 'new_alias',
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
grid = UI.Grid({
|
grid = UI.Grid {
|
||||||
y = 5, values = aliases, autospace = true,
|
y = 5,
|
||||||
|
values = aliases,
|
||||||
|
autospace = true,
|
||||||
|
sortColumn = 'alias',
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Alias', key = 'alias' },
|
{ heading = 'Alias', key = 'alias' },
|
||||||
{ heading = 'Program', key = 'path' },
|
{ heading = 'Program', key = 'path' },
|
||||||
},
|
},
|
||||||
sortColumn = 'alias',
|
|
||||||
accelerators = {
|
accelerators = {
|
||||||
delete = 'delete_alias',
|
delete = 'delete_alias',
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
}),
|
},
|
||||||
|
|
||||||
infoTab = UI.Window({
|
infoTab = UI.Window {
|
||||||
tabTitle = 'Info',
|
tabTitle = 'Info',
|
||||||
labelText = UI.Text({ y = 2, x = 3, value = 'Label' }),
|
labelText = UI.Text {
|
||||||
label = UI.TextEntry({
|
x = 3, y = 2,
|
||||||
y = 2, x = 9, width = UI.term.width - 12,
|
value = 'Label'
|
||||||
limit = 32, value = os.getComputerLabel(),
|
},
|
||||||
|
label = UI.TextEntry {
|
||||||
|
x = 9, y = 2, rex = -12,
|
||||||
|
limit = 32,
|
||||||
|
value = os.getComputerLabel(),
|
||||||
backgroundFocusColor = colors.black,
|
backgroundFocusColor = colors.black,
|
||||||
accelerators = {
|
accelerators = {
|
||||||
enter = 'update_label',
|
enter = 'update_label',
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
grid = UI.ScrollingGrid({
|
grid = UI.ScrollingGrid {
|
||||||
y = 4,
|
y = 4,
|
||||||
values = {
|
values = {
|
||||||
{ name = 'CC version', value = os.version() },
|
{ name = 'CC version', value = os.version() },
|
||||||
|
@ -93,15 +99,14 @@ local systemPage = UI.Page({
|
||||||
{ key = 'name', width = 12 },
|
{ key = 'name', width = 12 },
|
||||||
{ key = 'value', width = UI.term.width - 15 },
|
{ key = 'value', width = UI.term.width - 15 },
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
}),
|
},
|
||||||
}),
|
},
|
||||||
-- statusBar = UI.StatusBar(),
|
|
||||||
notification = UI.Notification(),
|
notification = UI.Notification(),
|
||||||
accelerators = {
|
accelerators = {
|
||||||
q = 'quit',
|
q = 'quit',
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
function systemPage.tabs.pathTab.grid:draw()
|
function systemPage.tabs.pathTab.grid:draw()
|
||||||
self.values = { }
|
self.values = { }
|
||||||
|
@ -120,10 +125,8 @@ function systemPage.tabs.pathTab:eventHandler(event)
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
Config.update('multishell', env)
|
Config.update('multishell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
else
|
return true
|
||||||
return UI.Window.eventHandler(self, event)
|
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function systemPage.tabs.aliasTab.grid:draw()
|
function systemPage.tabs.aliasTab.grid:draw()
|
||||||
|
@ -144,6 +147,7 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||||
self.grid:draw()
|
self.grid:draw()
|
||||||
Config.update('multishell', env)
|
Config.update('multishell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
|
return true
|
||||||
|
|
||||||
elseif event.type == 'new_alias' then
|
elseif event.type == 'new_alias' then
|
||||||
env.aliases[self.alias.value] = self.path.value
|
env.aliases[self.alias.value] = self.path.value
|
||||||
|
@ -153,10 +157,8 @@ function systemPage.tabs.aliasTab:eventHandler(event)
|
||||||
self:setFocus(self.alias)
|
self:setFocus(self.alias)
|
||||||
Config.update('multishell', env)
|
Config.update('multishell', env)
|
||||||
systemPage.notification:success('reboot to take effect')
|
systemPage.notification:success('reboot to take effect')
|
||||||
else
|
return true
|
||||||
return UI.Window.eventHandler(self, event)
|
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function systemPage.tabs.infoTab:eventHandler(event)
|
function systemPage.tabs.infoTab:eventHandler(event)
|
||||||
|
@ -164,21 +166,15 @@ function systemPage.tabs.infoTab:eventHandler(event)
|
||||||
os.setComputerLabel(self.label.value)
|
os.setComputerLabel(self.label.value)
|
||||||
systemPage.notification:success('Label updated')
|
systemPage.notification:success('Label updated')
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
return UI.Window.eventHandler(self, event)
|
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function systemPage:eventHandler(event)
|
function systemPage:eventHandler(event)
|
||||||
|
|
||||||
if event.type == 'quit' then
|
if event.type == 'quit' then
|
||||||
Event.exitPullEvents()
|
Event.exitPullEvents()
|
||||||
|
|
||||||
elseif event.type == 'tab_activate' then
|
elseif event.type == 'tab_activate' then
|
||||||
event.activated:focusFirst()
|
event.activated:focusFirst()
|
||||||
--self.statusBar:setValue('')
|
|
||||||
--self.statusBar:draw()
|
|
||||||
else
|
else
|
||||||
return UI.Page.eventHandler(self, event)
|
return UI.Page.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
|
|
@ -811,6 +811,8 @@ local __actions = {
|
||||||
local nx = nextWord(tLines[y], x)
|
local nx = nextWord(tLines[y], x)
|
||||||
if nx then
|
if nx then
|
||||||
x = nx
|
x = nx
|
||||||
|
elseif x < #tLines[y] + 1 then
|
||||||
|
x = #tLines[y] + 1
|
||||||
elseif y < #tLines then
|
elseif y < #tLines then
|
||||||
x = 1
|
x = 1
|
||||||
y = y + 1
|
y = y + 1
|
||||||
|
|
|
@ -455,7 +455,7 @@ end)
|
||||||
local function startup()
|
local function startup()
|
||||||
local hasError
|
local hasError
|
||||||
|
|
||||||
local function runDir(directory, open)
|
local function runDir(directory, desc, open)
|
||||||
if not fs.exists(directory) then
|
if not fs.exists(directory) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -464,8 +464,8 @@ local function startup()
|
||||||
table.sort(files)
|
table.sort(files)
|
||||||
|
|
||||||
for _,file in ipairs(files) do
|
for _,file in ipairs(files) do
|
||||||
print('Autorunning: ' .. file)
|
print(desc .. file)
|
||||||
|
os.sleep(0)
|
||||||
local result, err = open(directory .. '/' .. file)
|
local result, err = open(directory .. '/' .. file)
|
||||||
if not result then
|
if not result then
|
||||||
printError(err)
|
printError(err)
|
||||||
|
@ -474,7 +474,7 @@ local function startup()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
runDir('/sys/extensions', shell.run)
|
runDir('/sys/extensions', '[ ext ] ', shell.run)
|
||||||
|
|
||||||
local overviewId = multishell.openTab({
|
local overviewId = multishell.openTab({
|
||||||
path = '/apps/Overview.lua',
|
path = '/apps/Overview.lua',
|
||||||
|
@ -484,8 +484,8 @@ local function startup()
|
||||||
})
|
})
|
||||||
overviewTab = tabs[overviewId]
|
overviewTab = tabs[overviewId]
|
||||||
|
|
||||||
runDir('/sys/services', shell.openHiddenTab)
|
runDir('/sys/services', '[ svc ] ', shell.openHiddenTab)
|
||||||
runDir('/autorun', shell.run)
|
runDir('/autorun', '[ aut ] ', shell.run)
|
||||||
|
|
||||||
if hasError then
|
if hasError then
|
||||||
error('An autorun program has errored')
|
error('An autorun program has errored')
|
||||||
|
|
|
@ -14,7 +14,7 @@ local version = "Version 1.1.6"
|
||||||
-- Original code by Bomb Bloke
|
-- Original code by Bomb Bloke
|
||||||
-- Modified to integrate with opus os
|
-- Modified to integrate with opus os
|
||||||
|
|
||||||
local calls, recTerm, oldTerm, arg, showInput, skipLast, lastDelay, curInput, callCount, callListCount = {{["delay"] = 0}}, {}, term.current(), {...}, false, false, 2, "", 1, 2
|
local calls, recTerm, oldTerm, arg, showInput, skipLast, lastDelay, curInput, callCount, callListCount = {{["delay"] = 0}}, {}, Util.shallowCopy(multishell.term), {...}, false, false, 2, "", 1, 2
|
||||||
local curBlink, oldBlink, curCalls, tTerm, buffer, colourNum, xPos, yPos, oldXPos, oldYPos, tCol, bCol, xSize, ySize = false, false, calls[1], {}, {}, {}, 1, 1, 1, 1, colours.white, colours.black, term.getSize()
|
local curBlink, oldBlink, curCalls, tTerm, buffer, colourNum, xPos, yPos, oldXPos, oldYPos, tCol, bCol, xSize, ySize = false, false, calls[1], {}, {}, {}, 1, 1, 1, 1, colours.white, colours.black, term.getSize()
|
||||||
local greys, buttons = {["0"] = true, ["7"] = true, ["8"] = true, ["f"] = true}, {"l", "r", "m"}
|
local greys, buttons = {["0"] = true, ["7"] = true, ["8"] = true, ["f"] = true}, {"l", "r", "m"}
|
||||||
local charW, charH, chars, resp
|
local charW, charH, chars, resp
|
||||||
|
@ -84,8 +84,6 @@ end
|
||||||
package = loadAPI('.recGif/package', getfenv(1))
|
package = loadAPI('.recGif/package', getfenv(1))
|
||||||
GIF = loadAPI('.recGif/GIF', getfenv(1))
|
GIF = loadAPI('.recGif/GIF', getfenv(1))
|
||||||
|
|
||||||
oldTerm = Util.shallowCopy(multishell.term)
|
|
||||||
|
|
||||||
local oldDir = shell.dir()
|
local oldDir = shell.dir()
|
||||||
shell.setDir('.recGif')
|
shell.setDir('.recGif')
|
||||||
shell.run("package get Y0eLUPtr")
|
shell.run("package get Y0eLUPtr")
|
||||||
|
|
|
@ -1,6 +1,2 @@
|
||||||
local args = { ... }
|
local options = table.concat({ ... }, ' ')
|
||||||
local options = ''
|
shell.run('pastebin run sj4VMVJj ' .. options)
|
||||||
for _,v in pairs(args) do
|
|
||||||
options = options .. ' ' .. v
|
|
||||||
end
|
|
||||||
shell.run('pastebin run sj4VMVJj' .. options)
|
|
||||||
|
|
Loading…
Reference in New Issue