1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-21 10:47:40 +00:00

fix lua path, mwm, cleanup injector

This commit is contained in:
kepler155c@gmail.com
2019-02-07 03:10:05 -05:00
parent 915085ac5f
commit 53e0fa3795
14 changed files with 342 additions and 145 deletions

View File

@@ -8,6 +8,10 @@ if not args[1] then
error('Syntax: cedit <filename>')
end
if not _G.http.websocket then
error('Requires CC: Tweaked')
end
if not _G.cloud_catcher then
print('Paste key: ')
local key = read()

View File

@@ -1,5 +1,9 @@
local read = _G.read
local shell = _ENV.shell
local read = _G.read
local shell = _ENV.shell
if not _G.http.websocket then
error('Requires CC: Tweaked')
end
if not _G.cloud_catcher then
print('Paste key: ')

View File

@@ -50,21 +50,13 @@ local function install(name, isUpdate)
name))
local packageDir = fs.combine('packages', name)
local method = args[2] or 'local'
if method == 'remote' then
Util.writeTable(packageDir .. '/.install', {
mount = string.format('%s gitfs %s', packageDir, manifest.repository),
})
Util.writeTable(fs.combine(packageDir, '.package'), manifest)
else
local list = Git.list(manifest.repository)
local showProgress = progress(Util.size(list))
for path, entry in pairs(list) do
Util.download(entry.url, fs.combine(packageDir, path))
showProgress()
end
local list = Git.list(manifest.repository)
local showProgress = progress(Util.size(list))
for path, entry in pairs(list) do
Util.download(entry.url, fs.combine(packageDir, path))
showProgress()
end
return
end
if action == 'list' then

View File

@@ -65,7 +65,7 @@ local function run(env, ...)
end
if isUrl then
tProgramStack[#tProgramStack + 1] = path:match("^https?://([^/:]+:?[0-9]*/?.*)$")
tProgramStack[#tProgramStack + 1] = path -- path:match("^https?://([^/:]+:?[0-9]*/?.*)$")
else
tProgramStack[#tProgramStack + 1] = path
end

View File

@@ -2,47 +2,102 @@ local Config = require('config')
local UI = require('ui')
local Util = require('util')
local pathTab = UI.Tab {
local tab = UI.Tab {
tabTitle = 'Path',
description = 'Set the shell path',
tabClose = true,
entry = UI.TextEntry {
x = 2, y = 2, ex = -2,
limit = 256,
value = Config.load('shell').path,
shadowText = 'enter system path',
shadowText = 'enter new path',
accelerators = {
enter = 'update_path',
},
help = 'add a new path',
},
grid = UI.Grid {
y = 4,
y = 4, ey = -3,
disableHeader = true,
columns = { { key = 'value' } },
autospace = true,
sort = 'index',
help = 'double-click to remove, shift-arrow to move',
accelerators = {
delete = 'remove',
},
},
statusBar = UI.StatusBar { },
accelerators = {
[ 'shift-up' ] = 'move_up',
[ 'shift-down' ] = 'move_down',
},
}
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)
function tab:updateList(path)
self.grid.values = { }
for k,v in ipairs(Util.split(path, '(.-):')) do
table.insert(self.grid.values, { index = k, value = v })
end
self.grid:update()
end
function pathTab:eventHandler(event)
if event.type == 'update_path' then
local env = Config.load('shell')
env.path = self.entry.value
Config.update('shell', env)
self.grid:setIndex(self.grid:getIndex())
self.grid:draw()
self:emit({ type = 'success_message', message = 'reboot to take effect' })
function tab:enable()
local env = Config.load('shell')
self:updateList(env.path)
UI.Tab.enable(self)
end
function tab:save()
local t = { }
for _, v in ipairs(self.grid.values) do
table.insert(t, v.value)
end
local env = Config.load('shell')
env.path = table.concat(t, ':')
self:updateList(env.path)
Config.update('shell', env)
end
function tab:eventHandler(event)
if event.type == 'update_path' then
table.insert(self.grid.values, {
value = self.entry.value,
})
self:save()
self.entry:reset()
self.entry:draw()
self.grid:draw()
return true
end
elseif event.type == 'grid_select' or event.type == 'remove' then
local selected = self.grid:getSelected()
if selected then
table.remove(self.grid.values, selected.index)
self:save()
self.grid:draw()
end
elseif event.type == 'focus_change' then
self.statusBar:setStatus(event.focused.help)
elseif event.type == 'move_up' then
local entry = self.grid:getSelected()
if entry.index > 1 then
table.insert(self.grid.values, entry.index - 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index - 1)
self:save()
self.grid:draw()
end
elseif event.type == 'move_down' then
local entry = self.grid:getSelected()
if entry.index < #self.grid.values then
table.insert(self.grid.values, entry.index + 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index + 1)
self:save()
self.grid:draw()
end
end
end
return pathTab
return tab

View File

@@ -0,0 +1,103 @@
local Config = require('config')
local UI = require('ui')
local Util = require('util')
local tab = UI.Tab {
tabTitle = 'Requires',
description = 'Require path',
tabClose = true,
entry = UI.TextEntry {
x = 2, y = 2, ex = -2,
limit = 256,
shadowText = 'Enter new require path',
accelerators = {
enter = 'update_path',
},
help = 'add a new path',
},
grid = UI.Grid {
y = 4, ey = -3,
disableHeader = true,
columns = { { key = 'value' } },
autospace = true,
sort = 'index',
help = 'double-click to remove, shift-arrow to move',
accelerators = {
delete = 'remove',
},
},
statusBar = UI.StatusBar { },
accelerators = {
[ 'shift-up' ] = 'move_up',
[ 'shift-down' ] = 'move_down',
},
}
function tab:updateList(lua_path)
self.grid.values = { }
for k,v in ipairs(Util.split(lua_path, '(.-);')) do
table.insert(self.grid.values, { index = k, value = v })
end
self.grid:update()
end
function tab:enable()
local env = Config.load('shell')
self:updateList(env.lua_path)
UI.Tab.enable(self)
end
function tab:save()
local t = { }
for _, v in ipairs(self.grid.values) do
table.insert(t, v.value)
end
local env = Config.load('shell')
env.lua_path = table.concat(t, ';')
self:updateList(env.lua_path)
Config.update('shell', env)
end
function tab:eventHandler(event)
if event.type == 'update_path' then
table.insert(self.grid.values, {
value = self.entry.value,
})
self:save()
self.entry:reset()
self.entry:draw()
self.grid:draw()
return true
elseif event.type == 'grid_select' or event.type == 'remove' then
local selected = self.grid:getSelected()
if selected then
table.remove(self.grid.values, selected.index)
self:save()
self.grid:draw()
end
elseif event.type == 'focus_change' then
self.statusBar:setStatus(event.focused.help)
elseif event.type == 'move_up' then
local entry = self.grid:getSelected()
if entry.index > 1 then
table.insert(self.grid.values, entry.index - 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index - 1)
self:save()
self.grid:draw()
end
elseif event.type == 'move_down' then
local entry = self.grid:getSelected()
if entry.index < #self.grid.values then
table.insert(self.grid.values, entry.index + 1, table.remove(self.grid.values, entry.index))
self.grid:setIndex(entry.index + 1)
self:save()
self.grid:draw()
end
end
end
return tab