mirror of
https://github.com/kepler155c/opus
synced 2024-09-28 23:10:41 +00:00
51 lines
1.1 KiB
Lua
51 lines
1.1 KiB
Lua
|
local Config = require('config')
|
||
|
local UI = require('ui')
|
||
|
local Util = require('util')
|
||
|
|
||
|
local shell = _ENV.shell
|
||
|
|
||
|
local pathTab = UI.Window {
|
||
|
tabTitle = 'Path',
|
||
|
description = 'Set the shell path',
|
||
|
tabClose = true,
|
||
|
entry = UI.TextEntry {
|
||
|
x = 2, y = 2, ex = -2,
|
||
|
limit = 256,
|
||
|
value = shell.path(),
|
||
|
shadowText = 'enter system path',
|
||
|
accelerators = {
|
||
|
enter = 'update_path',
|
||
|
},
|
||
|
},
|
||
|
grid = UI.Grid {
|
||
|
y = 4,
|
||
|
disableHeader = true,
|
||
|
columns = { { key = 'value' } },
|
||
|
autospace = true,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
function pathTab.grid:draw()
|
||
|
self.values = { }
|
||
|
local env = Config.load('shell')
|
||
|
for _,v in ipairs(Util.split(env.path, '(.-):')) do
|
||
|
table.insert(self.values, { value = v })
|
||
|
end
|
||
|
self:update()
|
||
|
UI.Grid.draw(self)
|
||
|
end
|
||
|
|
||
|
function pathTab:eventHandler(event)
|
||
|
if event.type == 'update_path' then
|
||
|
local env = Config.load('shell')
|
||
|
env.path = self.entry.value
|
||
|
self.grid:setIndex(self.grid:getIndex())
|
||
|
self.grid:draw()
|
||
|
Config.update('shell', env)
|
||
|
self:emit({ type = 'success_message', message = 'reboot to take effect' })
|
||
|
return true
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return pathTab
|