Merge branch 'Pre-Alpha-3.0.0' of https://github.com/Team-Cerulean-Blue/Halyde into Pre-Alpha-3.0.0
This commit is contained in:
+13
-13
@@ -1,6 +1,6 @@
|
|||||||
local packages = {...}
|
local packages = {...}
|
||||||
local command = packages[1]
|
local command = table.remove(packages,1)
|
||||||
table.remove(packages, 1)
|
local shell = require("shell")
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
local agReg = require("/argentum/registry.cfg")
|
local agReg = require("/argentum/registry.cfg")
|
||||||
@@ -107,7 +107,7 @@ local function doChecks(package)
|
|||||||
if agcfg[package].dependencies then
|
if agcfg[package].dependencies then
|
||||||
for _, dependency in ipairs(agcfg[package].dependencies) do
|
for _, dependency in ipairs(agcfg[package].dependencies) do
|
||||||
if not agReg[dependency] and not agcfg[dependency] then
|
if not agReg[dependency] and not agcfg[dependency] then
|
||||||
local response = read(nil, "\27[91mPackage " .. package .. " requires dependency " .. dependency .. " that does not exist.\n[A - Abort/s - Skip]")
|
local response = terminal.read(nil, "\27[91mPackage " .. package .. " requires dependency " .. dependency .. " that does not exist.\n[A - Abort/s - Skip]")
|
||||||
if response:lower() ~= "s" then
|
if response:lower() ~= "s" then
|
||||||
fs.remove("/argentum/store/" .. package)
|
fs.remove("/argentum/store/" .. package)
|
||||||
return false
|
return false
|
||||||
@@ -166,7 +166,7 @@ local function installPackage(package, overwriteFlag)
|
|||||||
if agcfg[package].dependencies then
|
if agcfg[package].dependencies then
|
||||||
for _, dependency in ipairs(agcfg[package].dependencies) do
|
for _, dependency in ipairs(agcfg[package].dependencies) do
|
||||||
if not agReg[dependency] and not agcfg[dependency] then
|
if not agReg[dependency] and not agcfg[dependency] then
|
||||||
local response = read(nil, "\27[91mPackage " .. package .. " requires dependency " .. dependency .. " that does not exist.\n[A - Abort/s - Skip]")
|
local response = terminal.read(nil, "\27[91mPackage " .. package .. " requires dependency " .. dependency .. " that does not exist.\n[A - Abort/s - Skip]")
|
||||||
if response:lower() ~= "s" then
|
if response:lower() ~= "s" then
|
||||||
fs.remove("/argentum/store/" .. package)
|
fs.remove("/argentum/store/" .. package)
|
||||||
return false
|
return false
|
||||||
@@ -199,7 +199,7 @@ local function installPackage(package, overwriteFlag)
|
|||||||
local data, errorMessage = getFile(source .. agcfg[package].maindir .. file)
|
local data, errorMessage = getFile(source .. agcfg[package].maindir .. file)
|
||||||
if not data then
|
if not data then
|
||||||
clearProgress()
|
clearProgress()
|
||||||
local response = read(nil, "\27[91mCould not fetch " .. file .. ": " .. errorMessage .. "\n\27[0m[a - Abort/R - Retry/s - Skip]")
|
local response = terminal.read(nil, "\27[91mCould not fetch " .. file .. ": " .. errorMessage .. "\n\27[0m[a - Abort/R - Retry/s - Skip]")
|
||||||
if response:lower() == "a" then
|
if response:lower() == "a" then
|
||||||
fs.remove("/argentum/store/" .. package)
|
fs.remove("/argentum/store/" .. package)
|
||||||
return false
|
return false
|
||||||
@@ -258,7 +258,7 @@ local function removePackage(package)
|
|||||||
local result, errorMessage = fs.remove(line:sub(2))
|
local result, errorMessage = fs.remove(line:sub(2))
|
||||||
if not result then
|
if not result then
|
||||||
clearProgress()
|
clearProgress()
|
||||||
local response = read(nil, "\27[91mFailed to remove " .. line:sub(2) .. ": " .. errorMessage .. "\n\27[0m[a - Abort/r - Retry/S - Skip]")
|
local response = terminal.read(nil, "\27[91mFailed to remove " .. line:sub(2) .. ": " .. errorMessage .. "\n\27[0m[a - Abort/r - Retry/S - Skip]")
|
||||||
if response:lower() == "a" then
|
if response:lower() == "a" then
|
||||||
return false
|
return false
|
||||||
elseif response:lower() == "r" then
|
elseif response:lower() == "r" then
|
||||||
@@ -274,7 +274,7 @@ local function removePackage(package)
|
|||||||
local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/files/" .. line:sub(2), "r"), "", nil
|
local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/files/" .. line:sub(2), "r"), "", nil
|
||||||
if not handle then
|
if not handle then
|
||||||
clearProgress()
|
clearProgress()
|
||||||
local response = read(nil, "\27[91mFailed to revert " .. line:sub(2) .. ": " .. data .. "\n\27[0m[a - Abort/R - Retry/s - Skip]") -- this is pretty stupid but i think the error message would get pushed to data
|
local response = terminal.read(nil, "\27[91mFailed to revert " .. line:sub(2) .. ": " .. data .. "\n\27[0m[a - Abort/R - Retry/s - Skip]") -- this is pretty stupid but i think the error message would get pushed to data
|
||||||
if response:lower() == "a" then
|
if response:lower() == "a" then
|
||||||
return false
|
return false
|
||||||
elseif response:lower() == "s" then
|
elseif response:lower() == "s" then
|
||||||
@@ -360,7 +360,7 @@ if command == "install" then
|
|||||||
local answer
|
local answer
|
||||||
if #fails == 0 then
|
if #fails == 0 then
|
||||||
print("Packages that will be installed: " .. table.concat(packageList, ", "))
|
print("Packages that will be installed: " .. table.concat(packageList, ", "))
|
||||||
if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
if terminal.read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif #packageList == 0 then
|
elseif #packageList == 0 then
|
||||||
@@ -370,7 +370,7 @@ if command == "install" then
|
|||||||
print("Some packages cannot be installed.")
|
print("Some packages cannot be installed.")
|
||||||
print("Packages that will be installed: " .. table.concat(packageList, ", "))
|
print("Packages that will be installed: " .. table.concat(packageList, ", "))
|
||||||
print("Packages that cannot be installed: " .. table.concat(fails, ", "))
|
print("Packages that cannot be installed: " .. table.concat(fails, ", "))
|
||||||
if read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
if terminal.read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -452,7 +452,7 @@ elseif command == "remove" then
|
|||||||
local answer
|
local answer
|
||||||
if #fails == 0 then
|
if #fails == 0 then
|
||||||
print("Packages that will be removed: " .. table.concat(packageList, ", "))
|
print("Packages that will be removed: " .. table.concat(packageList, ", "))
|
||||||
if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
if terminal.read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif #packageList == 0 then
|
elseif #packageList == 0 then
|
||||||
@@ -462,7 +462,7 @@ elseif command == "remove" then
|
|||||||
print("Some packages cannot be removed.")
|
print("Some packages cannot be removed.")
|
||||||
print("Packages that will be removed: " .. table.concat(packageList, ", "))
|
print("Packages that will be removed: " .. table.concat(packageList, ", "))
|
||||||
print("Packages that cannot be removed: " .. table.concat(fails, ", "))
|
print("Packages that cannot be removed: " .. table.concat(fails, ", "))
|
||||||
if read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
if terminal.read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -560,14 +560,14 @@ elseif command == "update" then
|
|||||||
end
|
end
|
||||||
elseif #fails == 0 then
|
elseif #fails == 0 then
|
||||||
print("Packages that will be updated: " .. table.concat(packageList, ", "))
|
print("Packages that will be updated: " .. table.concat(packageList, ", "))
|
||||||
if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
if terminal.read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("Some packages cannot be updated.")
|
print("Some packages cannot be updated.")
|
||||||
print("Packages that will be updated: " .. table.concat(packageList, ", "))
|
print("Packages that will be updated: " .. table.concat(packageList, ", "))
|
||||||
print("Packages that cannot be updated: " .. table.concat(fails, ", "))
|
print("Packages that cannot be updated: " .. table.concat(fails, ", "))
|
||||||
if read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
if terminal.read(nil, "Would you like to proceed? [y/N] "):lower() ~= "y" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ if type(args[1])=="string" then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not force then
|
if not force then
|
||||||
if componentlib.additions[compID] then
|
if component.virtual.check(compID) then
|
||||||
return print("\x1b[91mThis component is virtual and cannot be booted from directly.\nID: "..compID)
|
return print("\x1b[91mThis component is virtual and cannot be booted from directly.\nID: "..compID)
|
||||||
end
|
end
|
||||||
local type = component.type(compID)
|
local type = component.type(compID)
|
||||||
@@ -56,5 +56,5 @@ if type(args[1])=="string" then
|
|||||||
end
|
end
|
||||||
computer.shutdown(true)
|
computer.shutdown(true)
|
||||||
else
|
else
|
||||||
shell.run("help boot")
|
require("shell").run("help boot")
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
local files = {...}
|
local files = {...}
|
||||||
|
local shell = require("shell")
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
if not files or not files[1] then
|
if not files or not files[1] then
|
||||||
shell.run("help cat")
|
shell.run("help cat")
|
||||||
@@ -6,7 +7,7 @@ if not files or not files[1] then
|
|||||||
end
|
end
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
if file:sub(1, 1) ~= "/" then
|
if file:sub(1, 1) ~= "/" then
|
||||||
file = fs.concat(shell.workingDirectory, file)
|
file = fs.concat(shell.getWorkingDirectory(), file)
|
||||||
end
|
end
|
||||||
if not fs.exists(file) then
|
if not fs.exists(file) then
|
||||||
print("\27[91mFile does not exist.")
|
print("\27[91mFile does not exist.")
|
||||||
@@ -15,6 +16,6 @@ for _, file in ipairs(files) do
|
|||||||
local data
|
local data
|
||||||
repeat
|
repeat
|
||||||
data = handle:read(math.huge or math.maxinteger)
|
data = handle:read(math.huge or math.maxinteger)
|
||||||
termlib.write(data)
|
terminal.write(data)
|
||||||
until not data
|
until not data
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-2
@@ -1,14 +1,15 @@
|
|||||||
local directory = ...
|
local directory = ...
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
|
local shell = require("shell")
|
||||||
|
|
||||||
if not directory then
|
if not directory then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if directory:sub(1, 1) ~= "/" then
|
if directory:sub(1, 1) ~= "/" then
|
||||||
directory = fs.concat(shell.workingDirectory, directory)
|
directory = fs.concat(shell.getWorkingDirectory(), directory)
|
||||||
end
|
end
|
||||||
if fs.exists(directory) and fs.isDirectory(directory) then
|
if fs.exists(directory) and fs.isDirectory(directory) then
|
||||||
shell.workingDirectory = fs.canonical(directory)
|
shell.setWorkingDirectory(fs.canonical(directory))
|
||||||
else
|
else
|
||||||
print("\27[91mNo such directory.")
|
print("\27[91mNo such directory.")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
clear()
|
terminal.clear()
|
||||||
-- truly so much going on here
|
-- truly so much going on here
|
||||||
|
|||||||
+3
-2
@@ -1,15 +1,16 @@
|
|||||||
local fromFile, toFile = ...
|
local fromFile, toFile = ...
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
|
local shell = require("shell")
|
||||||
|
|
||||||
if not fromFile or not toFile then
|
if not fromFile or not toFile then
|
||||||
shell.run("help cp")
|
shell.run("help cp")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fromFile:sub(1, 1) ~= "/" then
|
if fromFile:sub(1, 1) ~= "/" then
|
||||||
fromFile = fs.concat(shell.workingDirectory, fromFile)
|
fromFile = fs.concat(shell.getWorkingDirectory(), fromFile)
|
||||||
end
|
end
|
||||||
if toFile:sub(1, 1) ~= "/" then
|
if toFile:sub(1, 1) ~= "/" then
|
||||||
toFile = fs.concat(shell.workingDirectory, toFile)
|
toFile = fs.concat(shell.getWorkingDirectory(), toFile)
|
||||||
end
|
end
|
||||||
if fromFile == toFile then
|
if fromFile == toFile then
|
||||||
print("\27[91mSource and destination are the same.")
|
print("\27[91mSource and destination are the same.")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ end
|
|||||||
|
|
||||||
if not url then
|
if not url then
|
||||||
print("Please enter a URL to download from.")
|
print("Please enter a URL to download from.")
|
||||||
shell.run("help download")
|
require("shell").run("help download")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ until not tmpdata
|
|||||||
local saveLocation
|
local saveLocation
|
||||||
local saveLocationOK = false
|
local saveLocationOK = false
|
||||||
repeat
|
repeat
|
||||||
saveLocation = read(nil, "File save location: ", fs.concat(shell.workingDirectory, url:match("/([^/]+)$")))
|
saveLocation = terminal.read(nil, "File save location: ", fs.concat(require("shell").getWorkingDirectory(), url:match("/([^/]+)$")))
|
||||||
if fs.isDirectory(saveLocation) then
|
if fs.isDirectory(saveLocation) then
|
||||||
print("\27[91mThe specified location is a directory.")
|
print("\27[91mThe specified location is a directory.")
|
||||||
elseif fs.exists(saveLocation) then
|
elseif fs.exists(saveLocation) then
|
||||||
|
|||||||
+13
-15
@@ -3,6 +3,7 @@ local fs = require("filesystem")
|
|||||||
local event = require("event")
|
local event = require("event")
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
local unicode = require("unicode")
|
local unicode = require("unicode")
|
||||||
|
local workingDirectory = require("shell").getWorkingDirectory()
|
||||||
local gpu = component.gpu
|
local gpu = component.gpu
|
||||||
local width, height = gpu.getResolution()
|
local width, height = gpu.getResolution()
|
||||||
local scrollPosX, scrollPosY = 1, 1
|
local scrollPosX, scrollPosY = 1, 1
|
||||||
@@ -15,9 +16,8 @@ local tab = " "
|
|||||||
--local ocelot = component.ocelot
|
--local ocelot = component.ocelot
|
||||||
|
|
||||||
local function rawset(x, y, text)
|
local function rawset(x, y, text)
|
||||||
termlib.cursorPosX = x
|
terminal.setCursorPos(x,y)
|
||||||
termlib.cursorPosY = y
|
terminal.write(text, false)
|
||||||
termlib.write(text, false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local filestring, filepath, handle, data, tmpdata
|
local filestring, filepath, handle, data, tmpdata
|
||||||
@@ -25,7 +25,7 @@ if file then
|
|||||||
if file:sub(1, 1) == "/" then
|
if file:sub(1, 1) == "/" then
|
||||||
filepath = file
|
filepath = file
|
||||||
else
|
else
|
||||||
filepath = shell.workingDirectory .. file
|
filepath = workingDirectory .. file
|
||||||
end
|
end
|
||||||
handle, data, tmpdata = fs.open(filepath, "r"), "", nil
|
handle, data, tmpdata = fs.open(filepath, "r"), "", nil
|
||||||
if fs.exists(filepath) then
|
if fs.exists(filepath) then
|
||||||
@@ -44,7 +44,7 @@ if file then
|
|||||||
tmpdata = {data}
|
tmpdata = {data}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
filepath = shell.workingDirectory .. file
|
filepath = workingDirectory .. file
|
||||||
filestring = "[NEW FILE]"
|
filestring = "[NEW FILE]"
|
||||||
tmpdata = {""}
|
tmpdata = {""}
|
||||||
end
|
end
|
||||||
@@ -55,7 +55,7 @@ else
|
|||||||
end
|
end
|
||||||
local function render()
|
local function render()
|
||||||
gpu.setActiveBuffer(renderBuffer)
|
gpu.setActiveBuffer(renderBuffer)
|
||||||
clear()
|
terminal.clear()
|
||||||
--ocelot.log(tostring(scrollPosY))
|
--ocelot.log(tostring(scrollPosY))
|
||||||
local realCursorX = math.min(cursorPosX, unicode.wlen(tmpdata[cursorPosY + scrollPosY - 1]) - scrollPosX + 2)
|
local realCursorX = math.min(cursorPosX, unicode.wlen(tmpdata[cursorPosY + scrollPosY - 1]) - scrollPosX + 2)
|
||||||
if realCursorX < 1 then
|
if realCursorX < 1 then
|
||||||
@@ -152,7 +152,7 @@ local function processEvent(args)
|
|||||||
if args[1] == "key_down" then
|
if args[1] == "key_down" then
|
||||||
local keycode = args[4]
|
local keycode = args[4]
|
||||||
local key = keyboard.keys[keycode]
|
local key = keyboard.keys[keycode]
|
||||||
if keyboard.ctrlDown then
|
if keyboard.getCtrlDown() then
|
||||||
return false, false, key
|
return false, false, key
|
||||||
end
|
end
|
||||||
if key == "down" and cursorPosY < #tmpdata then
|
if key == "down" and cursorPosY < #tmpdata then
|
||||||
@@ -261,14 +261,13 @@ local function save()
|
|||||||
gpu.setBackground(0xFFFFFF)
|
gpu.setBackground(0xFFFFFF)
|
||||||
gpu.setForeground(0)
|
gpu.setForeground(0)
|
||||||
gpu.set(1, height - 1, string.rep(" ", width))
|
gpu.set(1, height - 1, string.rep(" ", width))
|
||||||
termlib.cursorPosX = 1
|
terminal.setCursorPos(1, height - 1)
|
||||||
termlib.cursorPosY = height - 1
|
local savepath = terminal.read(nil, "\27[107m\27[30mSave location: ", filepath)
|
||||||
local savepath = read(nil, "\27[107m\27[30mSave location: ", filepath)
|
|
||||||
gpu.setBackground(0xFFFFFF)
|
gpu.setBackground(0xFFFFFF)
|
||||||
gpu.setForeground(0)
|
gpu.setForeground(0)
|
||||||
if fs.exists(savepath) then
|
if fs.exists(savepath) then
|
||||||
gpu.set(1, height - 1, string.rep(" ", width))
|
gpu.set(1, height - 1, string.rep(" ", width))
|
||||||
local answer = read(nil, "\27[107m\27[30mFile already exists. Overwrite it? [Y/n] ")
|
local answer = terminal.read(nil, "\27[107m\27[30mFile already exists. Overwrite it? [Y/n] ")
|
||||||
if answer:lower() == "n" then
|
if answer:lower() == "n" then
|
||||||
gpu.setBackground(0xFFFFFF)
|
gpu.setBackground(0xFFFFFF)
|
||||||
gpu.setForeground(0)
|
gpu.setForeground(0)
|
||||||
@@ -301,15 +300,14 @@ while true do
|
|||||||
renderFlag, cursorRenderFlag, specialKey = processEvent(args)
|
renderFlag, cursorRenderFlag, specialKey = processEvent(args)
|
||||||
if specialKey == "x" then
|
if specialKey == "x" then
|
||||||
if changesMade then
|
if changesMade then
|
||||||
termlib.cursorPosX = 1
|
terminal.setCursorPos(1, height - 1)
|
||||||
termlib.cursorPosY = height - 1
|
local response = terminal.read(nil, "\27[107m\27[30mWould you like to save changes? [Y/n] ")
|
||||||
local response = read(nil, "\27[107m\27[30mWould you like to save changes? [Y/n] ")
|
|
||||||
if response:lower() ~= "n" then
|
if response:lower() ~= "n" then
|
||||||
save()
|
save()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
gpu.freeAllBuffers()
|
gpu.freeAllBuffers()
|
||||||
clear()
|
terminal.clear()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if specialKey == "s" then
|
if specialKey == "s" then
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ local component = require("component")
|
|||||||
local computer = require("computer")
|
local computer = require("computer")
|
||||||
|
|
||||||
local function printstat(text)
|
local function printstat(text)
|
||||||
terminal.cursorPosX = 35
|
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
||||||
|
terminal.setCursorPos(35, cursorPosY)
|
||||||
terminal.write(text .. "\n", false)
|
terminal.write(text .. "\n", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
terminal.write(_OSLOGO, false)
|
terminal.write(_OSLOGO, false)
|
||||||
terminal.cursorPosY = terminal.cursorPosY - 17
|
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
||||||
|
terminal.setCursorPos(cursorPosX, cursorPosY - 17)
|
||||||
printstat("\27[92mOS\27[0m: ".._OSVERSION)
|
printstat("\27[92mOS\27[0m: ".._OSVERSION)
|
||||||
printstat("\27[92mArchitecture\27[0m: ".._VERSION)
|
printstat("\27[92mArchitecture\27[0m: ".._VERSION)
|
||||||
local componentCounter = 0
|
local componentCounter = 0
|
||||||
@@ -67,4 +69,5 @@ local width, height = component.invoke(component.list("gpu")(), "getResolution")
|
|||||||
printstat("\27[92mResolution\27[0m: "..tostring(width).."x"..tostring(height).."\n")
|
printstat("\27[92mResolution\27[0m: "..tostring(width).."x"..tostring(height).."\n")
|
||||||
printstat("\27[40m \27[41m \27[42m \27[43m \27[44m \27[45m \27[46m \27[47m ")
|
printstat("\27[40m \27[41m \27[42m \27[43m \27[44m \27[45m \27[46m \27[47m ")
|
||||||
printstat("\27[100m \27[101m \27[102m \27[103m \27[104m \27[105m \27[106m \27[107m ")
|
printstat("\27[100m \27[101m \27[102m \27[103m \27[104m \27[105m \27[106m \27[107m ")
|
||||||
terminal.cursorPosY = terminal.cursorPosY + 5
|
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
||||||
|
terminal.setCursorPos(cursorPosX, cursorPosY + 5)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local computer = require("computer")
|
|||||||
local args = {...}
|
local args = {...}
|
||||||
if not args then return print("\x1b[91mCannot get arguments.") end
|
if not args then return print("\x1b[91mCannot get arguments.") end
|
||||||
if not args[1] then
|
if not args[1] then
|
||||||
return shell.run("help label")
|
return require("shell").run("help label")
|
||||||
end
|
end
|
||||||
local inputID = args[1]
|
local inputID = args[1]
|
||||||
local comp
|
local comp
|
||||||
@@ -33,7 +33,7 @@ elseif #inputID>=3 then
|
|||||||
comp = component.proxy(fullID)
|
comp = component.proxy(fullID)
|
||||||
else
|
else
|
||||||
print("\x1b[91mAddress must have atleast 3 characters")
|
print("\x1b[91mAddress must have atleast 3 characters")
|
||||||
return shell.run("help label")
|
return require("shell").run("help label")
|
||||||
end
|
end
|
||||||
if not comp then
|
if not comp then
|
||||||
return print("\x1b[91mCould not find component from \""..inputID.."\".")
|
return print("\x1b[91mCould not find component from \""..inputID.."\".")
|
||||||
|
|||||||
+3
-2
@@ -7,13 +7,14 @@ local maxLength = 0
|
|||||||
local margin = 2 -- minimum space between filename and size
|
local margin = 2 -- minimum space between filename and size
|
||||||
local dirTable = {}
|
local dirTable = {}
|
||||||
local fileTable = {}
|
local fileTable = {}
|
||||||
|
local workingDirectory = require("shell").getWorkingDirectory()
|
||||||
|
|
||||||
if target then
|
if target then
|
||||||
if target:sub(1, 1) ~= "/" then
|
if target:sub(1, 1) ~= "/" then
|
||||||
target = fs.concat(shell.workingDirectory, target)
|
target = fs.concat(workingDirectory, target)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
target = shell.workingDirectory
|
target = workingDirectory
|
||||||
end
|
end
|
||||||
|
|
||||||
local files = fs.list(target)
|
local files = fs.list(target)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
print("\27[93m"..tostring(#cormgr.corList).."\27[0m coroutines active")
|
local tasks = tsched.getTasks()
|
||||||
for i=1, #cormgr.corList do
|
print("\27[93m"..tostring(#tasks).."\27[0m coroutines active")
|
||||||
if i==#cormgr.corList then
|
for i=1, #tasks do
|
||||||
print("\27[93m└ "..i.."\27[0m - "..cormgr.labelList[i].." \27[0m")
|
local pipeChar = "├ "
|
||||||
else
|
if i==#tasks then pipeChar = "└ " end
|
||||||
print("\27[93m├ "..i.."\27[0m - "..cormgr.labelList[i].." \27[0m")
|
local task = tasks[i]
|
||||||
end
|
print("\27[93m"..pipeChar..(task.id or i).."\27[0m - "..task.name.."\27[37m "..table.concat(task.args or {}," ").." \27[0m")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+20
-7
@@ -106,7 +106,7 @@ local function formatSize(mem)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function fileExists(proxy,path)
|
local function fileExists(proxy,path)
|
||||||
return proxy.exists(path) and not proxy.isDirectory(path)
|
return proxy.exists and proxy.isDirectory and proxy.exists(path) and not proxy.isDirectory(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getBootCode(proxy)
|
local function getBootCode(proxy)
|
||||||
@@ -140,24 +140,37 @@ local function handleComponent(id,type)
|
|||||||
-- for i=1,#tableOut do table.insert(out,"unknown") end
|
-- for i=1,#tableOut do table.insert(out,"unknown") end
|
||||||
local slot,capacity,managed,readOnly,mount,bootable,label
|
local slot,capacity,managed,readOnly,mount,bootable,label
|
||||||
|
|
||||||
|
local virtual,vproc = component.virtual.check(id)
|
||||||
local cslot = component.slot(id)
|
local cslot = component.slot(id)
|
||||||
if cslot==-1 then
|
if virtual then
|
||||||
slot="Virtual"
|
if vproc and vproc.name then
|
||||||
|
slot="Virtual ("..vproc.name..")"
|
||||||
|
else
|
||||||
|
slot="Virtual (unknown)"
|
||||||
|
end
|
||||||
|
elseif cslot==-1 then
|
||||||
|
slot="External"
|
||||||
elseif cslot==9 then
|
elseif cslot==9 then
|
||||||
slot="EEPROM"
|
slot="EEPROM"
|
||||||
|
elseif cslot==5 or cslot==6 then
|
||||||
|
slot="HDD #"..(cslot-4)
|
||||||
|
elseif cslot==7 then
|
||||||
|
slot="Floppy"
|
||||||
else
|
else
|
||||||
slot="#"..(cslot+2)
|
slot="#"..(cslot+2)
|
||||||
end
|
end
|
||||||
|
|
||||||
managed="Yes"
|
managed="No"
|
||||||
readOnly="No"
|
readOnly="No"
|
||||||
if type=="drive" then
|
if type=="drive" then
|
||||||
managed="No"
|
|
||||||
capacity=formatSize(proxy.getCapacity())
|
capacity=formatSize(proxy.getCapacity())
|
||||||
mount="/special/drive/"..id:sub(1,3)
|
mount="/special/drive/"..id:sub(1,3)
|
||||||
elseif type=="filesystem" then
|
elseif type=="filesystem" then
|
||||||
capacity=formatSize(proxy.spaceTotal())
|
managed="Yes"
|
||||||
if proxy.isReadOnly() then
|
if proxy.spaceTotal then
|
||||||
|
capacity=formatSize(proxy.spaceTotal())
|
||||||
|
end
|
||||||
|
if not proxy.isReadOnly or proxy.isReadOnly() then
|
||||||
readOnly="Yes"
|
readOnly="Yes"
|
||||||
end
|
end
|
||||||
mount="/mnt/"..id:sub(1,3)
|
mount="/mnt/"..id:sub(1,3)
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ local directory = ...
|
|||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
|
|
||||||
if not directory then
|
if not directory then
|
||||||
shell.run("help mkdir")
|
require("shell").run("help mkdir")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if directory:sub(1, 1) ~= "/" then
|
if directory:sub(1, 1) ~= "/" then
|
||||||
directory = fs.concat(shell.workingDirectory, directory)
|
directory = fs.concat(require("shell").getWorkingDirectory(), directory)
|
||||||
end
|
end
|
||||||
if fs.exists(directory) then
|
if fs.exists(directory) then
|
||||||
print("\27[91mAn object already exists at the specified path.")
|
print("\27[91mAn object already exists at the specified path.")
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
local fromFile, toFile = ...
|
local fromFile, toFile = ...
|
||||||
|
local shell = require("shell")
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
|
|
||||||
if not fromFile or not toFile then
|
if not fromFile or not toFile then
|
||||||
@@ -6,10 +7,10 @@ if not fromFile or not toFile then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fromFile:sub(1, 1) ~= "/" then
|
if fromFile:sub(1, 1) ~= "/" then
|
||||||
fromFile = fs.concat(shell.workingDirectory, fromFile)
|
fromFile = fs.concat(shell.getWorkingDirectory(), fromFile)
|
||||||
end
|
end
|
||||||
if toFile:sub(1, 1) ~= "/" then
|
if toFile:sub(1, 1) ~= "/" then
|
||||||
toFile = fs.concat(shell.workingDirectory, toFile)
|
toFile = fs.concat(shell.getWorkingDirectory(), toFile)
|
||||||
end
|
end
|
||||||
if fromFile == toFile then
|
if fromFile == toFile then
|
||||||
print("\27[91mSource and destination are the same.")
|
print("\27[91mSource and destination are the same.")
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
local file = ...
|
local file = ...
|
||||||
|
local shell = require("shell")
|
||||||
local fs = require("filesystem")
|
local fs = require("filesystem")
|
||||||
|
|
||||||
if not file then
|
if not file then
|
||||||
@@ -6,7 +7,7 @@ if not file then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if file:sub(1, 1) ~= "/" then
|
if file:sub(1, 1) ~= "/" then
|
||||||
file = fs.concat(shell.workingDirectory, file)
|
file = fs.concat(shell.getWorkingDirectory(), file)
|
||||||
end
|
end
|
||||||
if not fs.exists(file) then
|
if not fs.exists(file) then
|
||||||
print("\27[91mFile does not exist.")
|
print("\27[91mFile does not exist.")
|
||||||
|
|||||||
@@ -88,4 +88,4 @@ end
|
|||||||
end ]]
|
end ]]
|
||||||
|
|
||||||
raster.free()
|
raster.free()
|
||||||
termlib.cursorPosY=1
|
terminal.setCursorPos(1,1)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ function module.init()
|
|||||||
"print",
|
"print",
|
||||||
"_VERSION",
|
"_VERSION",
|
||||||
"_OSVERSION",
|
"_OSVERSION",
|
||||||
|
"_OSLOGO",
|
||||||
"assert",
|
"assert",
|
||||||
"error",
|
"error",
|
||||||
"getmetatable",
|
"getmetatable",
|
||||||
|
|||||||
+15
-1
@@ -19,7 +19,11 @@ function compLib.virtual.add(address, componentType, proxy)
|
|||||||
checkArg(2, componentType, "string")
|
checkArg(2, componentType, "string")
|
||||||
checkArg(3, proxy, "table")
|
checkArg(3, proxy, "table")
|
||||||
proxy["address"] = address
|
proxy["address"] = address
|
||||||
componentlib.additions[address] = {["componentType"] = componentType, ["proxy"] = proxy}
|
local proc
|
||||||
|
if _PUBLIC.tsched then
|
||||||
|
proc = _PUBLIC.tsched.getCurrentTask()
|
||||||
|
end
|
||||||
|
componentlib.additions[address] = {["componentType"] = componentType, ["proxy"] = proxy, ["proc"] = proc}
|
||||||
if componentlib.removals[address] then
|
if componentlib.removals[address] then
|
||||||
componentlib.removals[address] = nil
|
componentlib.removals[address] = nil
|
||||||
end
|
end
|
||||||
@@ -34,6 +38,15 @@ function compLib.virtual.remove(address)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function compLib.virtual.check(address)
|
||||||
|
checkArg(1, address, "string")
|
||||||
|
if _G.componentlib.additions[address] then
|
||||||
|
return true, _G.componentlib.additions[address].proc
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function compLib.list(componentType)
|
function compLib.list(componentType)
|
||||||
checkArg(1, componentType, "string", "nil")
|
checkArg(1, componentType, "string", "nil")
|
||||||
local componentList = table.copy(LLcomponent.list(componentType))
|
local componentList = table.copy(LLcomponent.list(componentType))
|
||||||
@@ -66,6 +79,7 @@ function compLib.invoke(address, funcName, ...)
|
|||||||
--ocelot.log("Invoking " .. funcName .. " from " .. address)
|
--ocelot.log("Invoking " .. funcName .. " from " .. address)
|
||||||
if componentlib.additions[address] then
|
if componentlib.additions[address] then
|
||||||
--ocelot.log("vcomponent")
|
--ocelot.log("vcomponent")
|
||||||
|
if not componentlib.additions[address].proxy[funcName] then error("no such method") end
|
||||||
return componentlib.additions[address].proxy[funcName](...)
|
return componentlib.additions[address].proxy[funcName](...)
|
||||||
else
|
else
|
||||||
return LLcomponent.invoke(address, funcName, ...)
|
return LLcomponent.invoke(address, funcName, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user