mirror of
https://github.com/kepler155c/opus
synced 2025-01-25 22:56:53 +00:00
dialogs
This commit is contained in:
parent
72bd16502b
commit
6754eb98d3
@ -86,7 +86,15 @@ function methodsPage:enable(p)
|
|||||||
self.peripheral = p or self.peripheral
|
self.peripheral = p or self.peripheral
|
||||||
|
|
||||||
local p = peripheral.wrap(self.peripheral.side)
|
local p = peripheral.wrap(self.peripheral.side)
|
||||||
if not p.getAdvancedMethodsData then
|
if p.getDocs then
|
||||||
|
self.grid.values = { }
|
||||||
|
for k,v in pairs(p.getDocs()) do
|
||||||
|
table.insert(self.grid.values, {
|
||||||
|
name = k,
|
||||||
|
doc = v,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
elseif not p.getAdvancedMethodsData then
|
||||||
self.grid.values = { }
|
self.grid.values = { }
|
||||||
for name,f in pairs(p) do
|
for name,f in pairs(p) do
|
||||||
table.insert(self.grid.values, {
|
table.insert(self.grid.values, {
|
||||||
@ -134,6 +142,12 @@ function methodsPage.viewportConsole:draw()
|
|||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if method.doc then
|
||||||
|
c:print(method.doc, nil, colors.yellow)
|
||||||
|
c.ymax = c.cursorY + 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if method.description then
|
if method.description then
|
||||||
c:print(method.description)
|
c:print(method.description)
|
||||||
end
|
end
|
||||||
|
@ -338,28 +338,32 @@ end
|
|||||||
|
|
||||||
local function nameDialog(f)
|
local function nameDialog(f)
|
||||||
local dialog = UI.Dialog({
|
local dialog = UI.Dialog({
|
||||||
x = (UI.term.width - 28) / 2,
|
-- x = (UI.term.width - 28) / 2,
|
||||||
width = 28,
|
width = 22,
|
||||||
textEntry = UI.TextEntry({ x = 4, y = 3, width = 20, limit = 20 })
|
title = 'Enter Name',
|
||||||
|
form = UI.Form {
|
||||||
|
x = 2, rex = -2, y = 2,
|
||||||
|
textEntry = UI.TextEntry({ y = 3, width = 20, limit = 20 })
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
dialog.titleBar.title = 'Enter Name'
|
|
||||||
|
|
||||||
dialog.eventHandler = function(self, event)
|
dialog.eventHandler = function(self, event)
|
||||||
if event.type == 'accept' then
|
if event.type == 'form_complete' then
|
||||||
local name = self.textEntry.value
|
local name = self.form.textEntry.value
|
||||||
if name then
|
if name then
|
||||||
f(name)
|
f(name)
|
||||||
else
|
else
|
||||||
self.statusBar:timedStatus('Invalid Name', 3)
|
self.statusBar:timedStatus('Invalid Name', 3)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
elseif event.type == 'form_cancel' or event.type == 'cancel' then
|
||||||
|
UI:setPreviousPage()
|
||||||
|
else
|
||||||
return UI.Dialog.eventHandler(self, event)
|
return UI.Dialog.eventHandler(self, event)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
dialog:setFocus(dialog.textEntry)
|
dialog:setFocus(dialog.form.textEntry)
|
||||||
UI:setPage(dialog)
|
UI:setPage(dialog)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3164,10 +3164,10 @@ UI.Dialog.defaults = {
|
|||||||
function UI.Dialog:init(args)
|
function UI.Dialog:init(args)
|
||||||
local defaults = UI:getDefaults(UI.Dialog, args)
|
local defaults = UI:getDefaults(UI.Dialog, args)
|
||||||
|
|
||||||
UI.setProperties(defaults, {
|
if not defaults.width then
|
||||||
width = UI.term.width-11,
|
defaults.width = UI.term.width-11
|
||||||
titleBar = UI.TitleBar({ previousPage = true, title = defaults.title }),
|
end
|
||||||
})
|
defaults.titleBar = UI.TitleBar({ previousPage = true, title = defaults.title })
|
||||||
|
|
||||||
--UI.setProperties(defaults, args)
|
--UI.setProperties(defaults, args)
|
||||||
UI.Page.init(self, defaults)
|
UI.Page.init(self, defaults)
|
||||||
|
Loading…
Reference in New Issue
Block a user