support open os command line programs
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
local UI = require('ui')
|
||||
local Util = require('util')
|
||||
|
||||
local colors = _G.colors
|
||||
local help = _G.help
|
||||
local colors = _G.colors
|
||||
local help = _G.help
|
||||
|
||||
UI:configure('Help', ...)
|
||||
|
||||
@@ -40,7 +40,7 @@ local topicPage = UI.Page {
|
||||
backgroundColor = colors.black,
|
||||
titleBar = UI.TitleBar {
|
||||
title = 'text',
|
||||
previousPage = true,
|
||||
event = 'back',
|
||||
},
|
||||
helpText = UI.TextArea {
|
||||
backgroundColor = colors.black,
|
||||
@@ -52,9 +52,18 @@ local topicPage = UI.Page {
|
||||
},
|
||||
}
|
||||
|
||||
function topicPage:enable(name)
|
||||
local f = help.lookup(name)
|
||||
|
||||
self.titleBar.title = name
|
||||
self.helpText:setText(f and Util.readFile(f) or 'No help available for ' .. name)
|
||||
|
||||
return UI.Page.enable(self)
|
||||
end
|
||||
|
||||
function topicPage:eventHandler(event)
|
||||
if event.type == 'back' then
|
||||
UI:setPreviousPage()
|
||||
UI:setPage(page)
|
||||
end
|
||||
return UI.Page.eventHandler(self, event)
|
||||
end
|
||||
@@ -66,12 +75,8 @@ function page:eventHandler(event)
|
||||
elseif event.type == 'grid_select' then
|
||||
if self.grid:getSelected() then
|
||||
local name = self.grid:getSelected().name
|
||||
local f = help.lookup(name)
|
||||
|
||||
topicPage.titleBar.title = name
|
||||
topicPage.helpText:setText(Util.readFile(f))
|
||||
|
||||
UI:setPage(topicPage)
|
||||
UI:setPage(topicPage, name)
|
||||
end
|
||||
|
||||
elseif event.type == 'text_change' then
|
||||
@@ -93,5 +98,6 @@ function page:eventHandler(event)
|
||||
end
|
||||
end
|
||||
|
||||
UI:setPage(page)
|
||||
local args = { ... }
|
||||
UI:setPage(#args[1] and topicPage or page, args[1])
|
||||
UI:pullEvents()
|
||||
|
||||
@@ -55,7 +55,7 @@ runDir('usr/autorun')
|
||||
|
||||
if not success then
|
||||
if multishell then
|
||||
--multishell.setFocus(multishell.getCurrent())
|
||||
multishell.setFocus(multishell.getCurrent())
|
||||
end
|
||||
_G.printError('A startup program has errored')
|
||||
print('Press enter to continue')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local Config = require('config')
|
||||
local UI = require('ui')
|
||||
|
||||
local kernel = _G.kernel
|
||||
|
||||
local aliasTab = UI.Tab {
|
||||
tabTitle = 'Aliases',
|
||||
description = 'Shell aliases',
|
||||
@@ -33,8 +35,12 @@ local aliasTab = UI.Tab {
|
||||
function aliasTab.grid:draw()
|
||||
self.values = { }
|
||||
local env = Config.load('shell')
|
||||
for k in pairs(kernel.getShell().aliases()) do
|
||||
kernel.getShell().clearAlias(k)
|
||||
end
|
||||
for k,v in pairs(env.aliases) do
|
||||
table.insert(self.values, { alias = k, path = v })
|
||||
kernel.getShell().setAlias(k, v)
|
||||
end
|
||||
self:update()
|
||||
UI.Grid.draw(self)
|
||||
@@ -42,23 +48,23 @@ end
|
||||
|
||||
function aliasTab:eventHandler(event)
|
||||
if event.type == 'delete_alias' then
|
||||
local env = Config.load('shell')
|
||||
local env = Config.load('shell', { aliases = { } })
|
||||
env.aliases[self.grid:getSelected().alias] = nil
|
||||
Config.update('shell', env)
|
||||
self.grid:setIndex(self.grid:getIndex())
|
||||
self.grid:draw()
|
||||
Config.update('shell', env)
|
||||
self:emit({ type = 'success_message', message = 'reboot to take effect' })
|
||||
self:emit({ type = 'success_message', message = 'Aliases updated' })
|
||||
return true
|
||||
|
||||
elseif event.type == 'new_alias' then
|
||||
local env = Config.load('shell')
|
||||
local env = Config.load('shell', { aliases = { } })
|
||||
env.aliases[self.alias.value] = self.path.value
|
||||
Config.update('shell', env)
|
||||
self.alias:reset()
|
||||
self.path:reset()
|
||||
self:draw()
|
||||
self:setFocus(self.alias)
|
||||
Config.update('shell', env)
|
||||
self:emit({ type = 'success_message', message = 'reboot to take effect' })
|
||||
self:emit({ type = 'success_message', message = 'Aliases updated' })
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user