1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-14 01:16:52 +00:00
opus/sys/apps/system/path.lua

49 lines
1.0 KiB
Lua
Raw Normal View History

2018-12-23 03:11:16 +00:00
local Config = require('config')
local UI = require('ui')
local Util = require('util')
2019-01-30 20:11:41 +00:00
local pathTab = UI.Tab {
2018-12-23 03:11:16 +00:00
tabTitle = 'Path',
description = 'Set the shell path',
tabClose = true,
entry = UI.TextEntry {
x = 2, y = 2, ex = -2,
limit = 256,
2018-12-27 08:05:12 +00:00
value = Config.load('shell').path,
2018-12-23 03:11:16 +00:00
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
2018-12-27 08:05:12 +00:00
Config.update('shell', env)
2018-12-23 03:11:16 +00:00
self.grid:setIndex(self.grid:getIndex())
self.grid:draw()
self:emit({ type = 'success_message', message = 'reboot to take effect' })
return true
end
end
return pathTab