v1.8.0 - Fixed a bug with shell not executing files in the working directory, added json library, changed all configs to json, added config auto-generation so they don't reset after an update.
This commit is contained in:
+10
-1
@@ -1,7 +1,7 @@
|
||||
local loadfile = ...
|
||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||
|
||||
_G._OSVERSION = "Halyde 1.7.2"
|
||||
_G._OSVERSION = "Halyde 1.8.0"
|
||||
_G._OSLOGO = ""
|
||||
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
||||
repeat
|
||||
@@ -84,5 +84,14 @@ preload("computer")
|
||||
--local handle = assert(filesystem.open("/bazinga.txt", "w"))
|
||||
--assert(handle:write("Bazinga!"))
|
||||
--handle:close()
|
||||
|
||||
local fs = import("filesystem")
|
||||
if not fs.exists("/halyde/config/shell.json") then
|
||||
fs.copy("/halyde/config/generate/shell.json", "/halyde/config/shell.json")
|
||||
end
|
||||
if not fs.exists("/halyde/config/startupapps.json") then
|
||||
fs.copy("/halyde/config/generate/startupapps.json", "/halyde/config/startupapps.json")
|
||||
end
|
||||
fs = nil
|
||||
|
||||
import("/halyde/core/cormgr.lua")
|
||||
|
||||
@@ -5,6 +5,7 @@ _G.cormgr.corList = {}
|
||||
|
||||
local component = import("component")
|
||||
local filesystem = import("filesystem")
|
||||
local json = import("json")
|
||||
local gpu = component.proxy(component.list("gpu")())
|
||||
|
||||
function _G.cormgr.loadCoroutine(path, ...)
|
||||
@@ -55,14 +56,13 @@ local function runCoroutines()
|
||||
end
|
||||
end
|
||||
|
||||
local handle = filesystem.open("/halyde/config/startupapps.cfg", "r")
|
||||
local data = ""
|
||||
local tmpdata
|
||||
local handle, data, tmpdata = filesystem.open("/halyde/config/startupapps.json", "r"), "", nil
|
||||
repeat
|
||||
tmpdata = handle:read(math.huge or math.maxinteger)
|
||||
data = data .. (tmpdata or "")
|
||||
until not tmpdata
|
||||
for line in data:gmatch("([^\n]*)\n?") do
|
||||
handle:close()
|
||||
for _, line in ipairs(json.decode(data)) do
|
||||
if line ~= "" then
|
||||
--[[ if _G.print then
|
||||
print(line)
|
||||
|
||||
@@ -12,13 +12,12 @@ keyboard.altDown = false
|
||||
while true do
|
||||
local args
|
||||
repeat
|
||||
args = {computer.pullSignal(0)}
|
||||
if args and args[1] then
|
||||
--ocelot.log("Sending signal "..args..","..computer.uptime())
|
||||
args = {computer.uptime(), computer.pullSignal(0)}
|
||||
if args and args[2] then
|
||||
table.insert(evmgr.eventQueue, args)
|
||||
if keyboard then
|
||||
if args[1] == "key_down" then
|
||||
local keycode = args[4]
|
||||
if args[2] == "key_down" then
|
||||
local keycode = args[5]
|
||||
local key = keyboard.keys[keycode]
|
||||
if key == "lcontrol" then
|
||||
keyboard.ctrlDown = true
|
||||
@@ -30,8 +29,8 @@ while true do
|
||||
end
|
||||
cormgr.corList[#cormgr.corList] = nil
|
||||
end
|
||||
elseif args[1] == "key_up" then
|
||||
local keycode = args[4]
|
||||
elseif args[2] == "key_up" then
|
||||
local keycode = args[5]
|
||||
local key = keyboard.keys[keycode]
|
||||
if key == "lcontrol" then
|
||||
keyboard.ctrlDown = false
|
||||
|
||||
+29
-25
@@ -1,7 +1,14 @@
|
||||
local shellcfg = import("/halyde/config/shell.cfg")
|
||||
local fs = import("filesystem")
|
||||
local json = import("json")
|
||||
local handle, data, tmpdata = fs.open("/halyde/config/shell.json", "r"), "", nil
|
||||
repeat
|
||||
tmpdata = handle:read(math.huge)
|
||||
data = data .. (tmpdata or "")
|
||||
until not tmpdata
|
||||
handle:close()
|
||||
local shellcfg = json.decode(data)
|
||||
import("/halyde/core/termlib.lua")
|
||||
local event = import("event")
|
||||
local filesystem = import("filesystem")
|
||||
local component = import("component")
|
||||
local gpu = component.proxy(component.list("gpu")())
|
||||
|
||||
@@ -51,39 +58,36 @@ function _G.shell.run(command)
|
||||
end
|
||||
end
|
||||
-- execute the program
|
||||
local foundfile = false
|
||||
local PATH = table.copy(shellcfg.path)
|
||||
table.insert(PATH, shell.workingDirectory)
|
||||
if not args[1] then
|
||||
return
|
||||
end
|
||||
if filesystem.exists(args[1]) and not filesystem.isDirectory(args[1]) then
|
||||
foundfile = true
|
||||
if fs.exists(args[1]) and not fs.isDirectory(args[1]) then
|
||||
local path = args[1]
|
||||
table.remove(args, 1)
|
||||
runAsCoroutine(path, table.unpack(args))
|
||||
else
|
||||
for _, item in pairs(shellcfg["path"]) do
|
||||
if filesystem.exists(item..args[1]) and not filesystem.isDirectory(item .. args[1]) then
|
||||
foundfile = true
|
||||
local path = item..args[1]
|
||||
table.remove(args, 1)
|
||||
runAsCoroutine(path, table.unpack(args))
|
||||
break
|
||||
else -- try to look for it without the file extension
|
||||
local files = filesystem.list(item)
|
||||
for _, file in pairs(files) do
|
||||
if args[1] == file:match("(.+)%.[^%.]+$") and not filesystem.isDirectory(item .. file) then
|
||||
foundfile = true
|
||||
table.remove(args, 1)
|
||||
runAsCoroutine(item .. file, table.unpack(args))
|
||||
break
|
||||
end
|
||||
return
|
||||
end
|
||||
for _, item in pairs(PATH) do
|
||||
if fs.exists(item..args[1]) and not fs.isDirectory(item .. args[1]) then
|
||||
local path = fs.concat(item, args[1])
|
||||
table.remove(args, 1)
|
||||
runAsCoroutine(path, table.unpack(args))
|
||||
return
|
||||
else -- try to look for it without the file extension
|
||||
local files = fs.list(item)
|
||||
for _, file in pairs(files) do
|
||||
-- previous pattern: (.+)%.[^%.]+$
|
||||
if args[1] == file:match("(.+)%.[^%.]+$") and not fs.isDirectory(item .. file) then
|
||||
table.remove(args, 1)
|
||||
runAsCoroutine(item .. file, table.unpack(args))
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not foundfile then
|
||||
print("No such file or command: "..args[1])
|
||||
end
|
||||
print("No such file or command: "..args[1])
|
||||
end
|
||||
|
||||
print(shellcfg["startupMessage"]:format(shellcfg.splashMessages[math.random(1, #shellcfg.splashMessages)]))
|
||||
|
||||
@@ -208,8 +208,8 @@ function _G.read(readHistoryType, prefix, defaultText)
|
||||
while true do
|
||||
--ocelot.log(curtext)
|
||||
termlib.cursorPosX = termlib.cursorPosX - 1
|
||||
local args = {event.pull("key_down", 0.5)}
|
||||
if args[4] then
|
||||
local args = {event.pull("key_down", "clipboard", 0.5)}
|
||||
if args[1] == "key_down" and args[4] then
|
||||
cursorWhite = true
|
||||
local keycode = args[4]
|
||||
local key = keyboard.keys[keycode]
|
||||
@@ -258,6 +258,8 @@ function _G.read(readHistoryType, prefix, defaultText)
|
||||
end
|
||||
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
|
||||
termlib.write(prefix .. curtext)
|
||||
elseif args[1] == "clipboard" then
|
||||
|
||||
else
|
||||
cursorWhite = not cursorWhite
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user