From 2266cd9873eba0f400f9cc8c3e6bc164df0b99e0 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Sat, 20 May 2017 19:05:00 -0400 Subject: [PATCH] major directory reorganize --- sys/apis/ui.lua | 2 +- sys/apps/Files.lua | 6 +++--- sys/apps/Network.lua | 4 ++-- sys/apps/Turtles.lua | 33 ++++++++++++++++++++++-------- sys/apps/shell | 1 - sys/{apps => etc}/scripts/abort | 0 sys/{apps => etc}/scripts/follow | 0 sys/{apps => etc}/scripts/goHome | 0 sys/{apps => etc}/scripts/moveTo | 0 sys/{apps => etc}/scripts/obsidian | 0 sys/{apps => etc}/scripts/reboot | 0 sys/{apps => etc}/scripts/setHome | 0 sys/{apps => etc}/scripts/shutdown | 0 sys/{apps => etc}/scripts/summon | 0 sys/{apps => etc}/scripts/update | 0 sys/network/telnet.lua | 2 +- 16 files changed, 32 insertions(+), 16 deletions(-) rename sys/{apps => etc}/scripts/abort (100%) rename sys/{apps => etc}/scripts/follow (100%) rename sys/{apps => etc}/scripts/goHome (100%) rename sys/{apps => etc}/scripts/moveTo (100%) rename sys/{apps => etc}/scripts/obsidian (100%) rename sys/{apps => etc}/scripts/reboot (100%) rename sys/{apps => etc}/scripts/setHome (100%) rename sys/{apps => etc}/scripts/shutdown (100%) rename sys/{apps => etc}/scripts/summon (100%) rename sys/{apps => etc}/scripts/update (100%) diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index d47501c..4322592 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -119,7 +119,7 @@ function Manager:init(args) if button == 1 and shift and control then -- hack local event = self:pointToChild(self.target, x, y) - multishell.openTab({ path = 'apps/Lua.lua', args = { event.element }, focused = true }) + multishell.openTab({ path = 'sys/apps/Lua.lua', args = { event.element }, focused = true }) elseif self.currentPage then if not self.currentPage.parent.device.side then diff --git a/sys/apps/Files.lua b/sys/apps/Files.lua index 2cf4dcf..dec14e4 100644 --- a/sys/apps/Files.lua +++ b/sys/apps/Files.lua @@ -287,10 +287,10 @@ function Browser:eventHandler(event) Event.exitPullEvents() elseif event.type == 'edit' and file then - self:run('/apps/shell', 'edit', file.name) + self:run('sys/apps/shell', 'edit', file.name) elseif event.type == 'shell' then - self:run('/apps/shell') + self:run('sys/apps/shell') elseif event.type == 'refresh' then self:updateDirectory(self.dir) @@ -339,7 +339,7 @@ function Browser:eventHandler(event) if file.isDir then self:setDir(file.fullName) else - self:run('/apps/shell', file.name) + self:run('sys/apps/shell', file.name) end end diff --git a/sys/apps/Network.lua b/sys/apps/Network.lua index 197f3cd..fa34c71 100644 --- a/sys/apps/Network.lua +++ b/sys/apps/Network.lua @@ -65,14 +65,14 @@ function page:eventHandler(event) if t then if event.type == 'telnet' or event.type == 'grid_select' then multishell.openTab({ - path = '/apps/telnet.lua', + path = 'sys/apps/telnet.lua', focused = true, args = { t.id }, title = t.label, }) elseif event.type == 'vnc' then multishell.openTab({ - path = '/apps/vnc.lua', + path = 'sys/apps/vnc.lua', focused = true, args = { t.id }, title = t.label, diff --git a/sys/apps/Turtles.lua b/sys/apps/Turtles.lua index 1b08018..b99e5d9 100644 --- a/sys/apps/Turtles.lua +++ b/sys/apps/Turtles.lua @@ -17,7 +17,8 @@ local options = { desc = 'Displays the options' }, } -local SCRIPTS_PATH = '/apps/scripts' +local USR_SCRIPTS_PATH = 'usr/scripts' +local SYS_SCRIPTS_PATH = 'sys/etc/scripts' local nullTerm = Terminal.getNullTerm(term.current()) local turtles = { } @@ -153,10 +154,12 @@ function page:runFunction(script, nowrap) end function page:runScript(scriptName) - local cmd = string.format('Script %d %s', self.turtle.id, scriptName) - local ot = term.redirect(nullTerm) - pcall(function() shell.run(cmd) end) - term.redirect(ot) + if self.turtle then + local cmd = string.format('Script %d %s', self.turtle.id, scriptName) + local ot = term.redirect(nullTerm) + pcall(function() shell.run(cmd) end) + term.redirect(ot) + end end function page.coords:draw() @@ -214,10 +217,24 @@ function page.tabs.inventory:eventHandler(event) end function page.tabs.scripts:draw() + + local function combineDirs(...) + local list = { } + for _,path in pairs({...}) do + if fs.exists(path) then + local files = fs.list(path) + for _,f in pairs(files) do + list[f] = fs.combine(path, f) + end + end + end + return list + end + Util.clear(self.values) - local files = fs.list(SCRIPTS_PATH) - for _,f in pairs(files) do - table.insert(self.values, { label = f, path = fs.combine(SCRIPTS_PATH, f) }) + local files = combineDirs(SYS_SCRIPTS_PATH, USR_SCRIPTS_PATH) + for f,path in pairs(files) do + table.insert(self.values, { label = f, path = path }) end self:update() UI.Grid.draw(self) diff --git a/sys/apps/shell b/sys/apps/shell index ac996ba..9cdd65f 100644 --- a/sys/apps/shell +++ b/sys/apps/shell @@ -300,7 +300,6 @@ local function autocompleteFile(results, words) if fs.isDir(startDir) then local files = fs.list(startDir) -debug({ rawPath, startDir }) for _,f in pairs(files) do local path = fs.combine(rawPath, f) if fs.isDir(fs.combine(startDir, f)) then diff --git a/sys/apps/scripts/abort b/sys/etc/scripts/abort similarity index 100% rename from sys/apps/scripts/abort rename to sys/etc/scripts/abort diff --git a/sys/apps/scripts/follow b/sys/etc/scripts/follow similarity index 100% rename from sys/apps/scripts/follow rename to sys/etc/scripts/follow diff --git a/sys/apps/scripts/goHome b/sys/etc/scripts/goHome similarity index 100% rename from sys/apps/scripts/goHome rename to sys/etc/scripts/goHome diff --git a/sys/apps/scripts/moveTo b/sys/etc/scripts/moveTo similarity index 100% rename from sys/apps/scripts/moveTo rename to sys/etc/scripts/moveTo diff --git a/sys/apps/scripts/obsidian b/sys/etc/scripts/obsidian similarity index 100% rename from sys/apps/scripts/obsidian rename to sys/etc/scripts/obsidian diff --git a/sys/apps/scripts/reboot b/sys/etc/scripts/reboot similarity index 100% rename from sys/apps/scripts/reboot rename to sys/etc/scripts/reboot diff --git a/sys/apps/scripts/setHome b/sys/etc/scripts/setHome similarity index 100% rename from sys/apps/scripts/setHome rename to sys/etc/scripts/setHome diff --git a/sys/apps/scripts/shutdown b/sys/etc/scripts/shutdown similarity index 100% rename from sys/apps/scripts/shutdown rename to sys/etc/scripts/shutdown diff --git a/sys/apps/scripts/summon b/sys/etc/scripts/summon similarity index 100% rename from sys/apps/scripts/summon rename to sys/etc/scripts/summon diff --git a/sys/apps/scripts/update b/sys/etc/scripts/update similarity index 100% rename from sys/apps/scripts/update rename to sys/etc/scripts/update diff --git a/sys/network/telnet.lua b/sys/network/telnet.lua index 859bbf3..8c1e045 100644 --- a/sys/network/telnet.lua +++ b/sys/network/telnet.lua @@ -36,7 +36,7 @@ local function telnetHost(socket, termInfo) wrapTerm(socket, termInfo) local shellThread = process:newThread('shell_wrapper', function() - os.run(getfenv(1), '/apps/shell') + os.run(getfenv(1), 'sys/apps/shell') socket:close() end)