diff --git a/apps/Peripherals.lua b/apps/Peripherals.lua index bdab0a3..0a59df2 100644 --- a/apps/Peripherals.lua +++ b/apps/Peripherals.lua @@ -86,7 +86,15 @@ function methodsPage:enable(p) self.peripheral = p or self.peripheral 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 = { } for name,f in pairs(p) do table.insert(self.grid.values, { @@ -134,6 +142,12 @@ function methodsPage.viewportConsole:draw() return 2 end + if method.doc then + c:print(method.doc, nil, colors.yellow) + c.ymax = c.cursorY + 1 + return + end + if method.description then c:print(method.description) end diff --git a/apps/Script.lua b/apps/Script.lua index 4b5cd1b..2c534b9 100644 --- a/apps/Script.lua +++ b/apps/Script.lua @@ -338,28 +338,32 @@ end local function nameDialog(f) local dialog = UI.Dialog({ - x = (UI.term.width - 28) / 2, - width = 28, - textEntry = UI.TextEntry({ x = 4, y = 3, width = 20, limit = 20 }) +-- x = (UI.term.width - 28) / 2, + width = 22, + 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) - if event.type == 'accept' then - local name = self.textEntry.value + if event.type == 'form_complete' then + local name = self.form.textEntry.value if name then f(name) else self.statusBar:timedStatus('Invalid Name', 3) end return true + elseif event.type == 'form_cancel' or event.type == 'cancel' then + UI:setPreviousPage() + else + return UI.Dialog.eventHandler(self, event) end - - return UI.Dialog.eventHandler(self, event) end - dialog:setFocus(dialog.textEntry) + dialog:setFocus(dialog.form.textEntry) UI:setPage(dialog) end diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 5a0cf54..8b5ab9f 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -3164,10 +3164,10 @@ UI.Dialog.defaults = { function UI.Dialog:init(args) local defaults = UI:getDefaults(UI.Dialog, args) - UI.setProperties(defaults, { - width = UI.term.width-11, - titleBar = UI.TitleBar({ previousPage = true, title = defaults.title }), - }) + if not defaults.width then + defaults.width = UI.term.width-11 + end + defaults.titleBar = UI.TitleBar({ previousPage = true, title = defaults.title }) --UI.setProperties(defaults, args) UI.Page.init(self, defaults)