v1.7.0 - Fixed up some more stuff, changed how print() works, added to automatically load all libraries in lua shell.

This commit is contained in:
TheWahlolly
2025-05-23 18:25:23 +03:00
parent 91d9ebecb1
commit b3f1431bda
8 changed files with 43 additions and 28 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
local agcfg = { local agcfg = {
["halyde"] = { ["halyde"] = {
["maindir"] = "", ["maindir"] = "",
["version"] = "1.6.0", ["version"] = "1.7.0",
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.", ["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
["directories"] = { ["directories"] = {
"halyde/apps", "halyde/apps",
+1 -1
View File
@@ -4,7 +4,7 @@ Ahalyde/core/
Ahalyde/config/ Ahalyde/config/
Ahalyde/apps/helpdb/ Ahalyde/apps/helpdb/
Ahalyde/apps/ Ahalyde/apps/
V1.6.0 V1.7.0
Ainit.lua Ainit.lua
Ahalyde/apps/helpdb/cat.txt Ahalyde/apps/helpdb/cat.txt
Ahalyde/apps/helpdb/cd.txt Ahalyde/apps/helpdb/cd.txt
+3 -4
View File
@@ -1,8 +1,7 @@
local args = {...} local file = ...
local file = args[1]
args = nil
local fs = import("filesystem") local fs = import("filesystem")
local event = import("event") local event = import("event")
local component = import("component")
local gpu = component.proxy(component.list("gpu")()) local gpu = component.proxy(component.list("gpu")())
local width, height = gpu.getResolution() local width, height = gpu.getResolution()
local scrollPosX, scrollPosY = 1, 1 local scrollPosX, scrollPosY = 1, 1
@@ -16,7 +15,7 @@ local scrollSpeed = 5
local function rawset(x, y, text) local function rawset(x, y, text)
termlib.cursorPosX = x termlib.cursorPosX = x
termlib.cursorPosY = y termlib.cursorPosY = y
print(text, false, false) termlib.write(text, false)
end end
local filestring, filepath, handle, data, tmpdata local filestring, filepath, handle, data, tmpdata
+3 -3
View File
@@ -3,11 +3,11 @@ local computer = import("computer")
local function printstat(text) local function printstat(text)
termlib.cursorPosX = 35 termlib.cursorPosX = 35
print(text, true, false) termlib.write(text .. "\n", false)
end end
print(_OSLOGO, true, false) termlib.write(_OSLOGO, false)
termlib.cursorPosY = termlib.cursorPosY - 18 termlib.cursorPosY = termlib.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
+12 -3
View File
@@ -1,14 +1,23 @@
print("\27[44m".._VERSION.."\27[0m shell") print("\27[44m".._VERSION.."\27[0m shell")
print('Type "exit" to exit.') print('Type "exit" to exit.')
termlib.readHistory["lua"] = {""} termlib.readHistory["lua"] = {""}
local fs = import("filesystem")
local loadedLibraries = ""
local libList = fs.list("halyde/lib")
for _, lib in pairs(libList) do
if lib:match("(.+)%.lua") then
loadedLibraries = loadedLibraries .. "local " .. lib:match("(.+)%.lua") .. ' = import("' .. lib:match("(.+)%.lua") .. '")\n'
end
end
while true do while true do
print("\27[44mlua>\27[0m ", false) local command = read("lua", "\27[44mlua>\27[0m ")
local command = read("lua")
if command == "exit" then if command == "exit" then
return return
else else
local function runCommand() local function runCommand()
assert(load(command))() assert(load(loadedLibraries .. command))()
end end
local result, reason = xpcall(runCommand, function(errMsg) local result, reason = xpcall(runCommand, function(errMsg)
return errMsg .. "\n\n" .. debug.traceback() return errMsg .. "\n\n" .. debug.traceback()
+1 -1
View File
@@ -1,7 +1,7 @@
local loadfile = ... local loadfile = ...
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
_G._OSVERSION = "Halyde 1.6.0" _G._OSVERSION = "Halyde 1.7.0"
_G._OSLOGO = "" _G._OSLOGO = ""
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
repeat repeat
+21 -15
View File
@@ -3,6 +3,7 @@ local event = import("event")
--local ocelot = component.proxy(component.list("ocelot")()) --local ocelot = component.proxy(component.list("ocelot")())
local component = import("component") local component = import("component")
local computer = import("computer")
local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented
_G.termlib = {} _G.termlib = {}
termlib.cursorPosX = 1 termlib.cursorPosX = 1
@@ -70,14 +71,11 @@ local function parseCodeNumbers(code)
return o return o
end end
function _G.print(text, endNewLine, textWrap) function termlib.write(text, textWrap)
width, height = gpu.getResolution() width, height = gpu.getResolution()
-- you don't know how tiring this was just for ANSI escape code support -- you don't know how tiring this was just for ANSI escape code support
if endNewLine == nil then
endNewLine = true
end
if textWrap == nil then if textWrap == nil then
textWrap = true textWrap = true
end end
@@ -168,9 +166,17 @@ function _G.print(text, endNewLine, textWrap)
::continue:: ::continue::
end end
printSection() printSection()
if endNewLine then
newLine()
end end
function _G.print(...)
local args = {...}
local stringArgs = {}
for _, arg in pairs(args) do
if tostring(arg) then
table.insert(stringArgs, tostring(arg))
end
end
termlib.write(table.concat(stringArgs, " ") .. "\n")
end end
function _G.clear() function _G.clear()
@@ -197,7 +203,7 @@ function _G.read(readHistoryType, prefix, defaultText)
RHIndex = #termlib.readHistory[readHistoryType] -- read history index RHIndex = #termlib.readHistory[readHistoryType] -- read history index
end end
local cursorPosX, cursorPosY = termlib.cursorPosX, termlib.cursorPosY local cursorPosX, cursorPosY = termlib.cursorPosX, termlib.cursorPosY
print(prefix .. curtext .. "\27[107m ", false) termlib.write(prefix .. curtext .. "\27[107m ")
local cursorWhite = true local cursorWhite = true
while true do while true do
--ocelot.log(curtext) --ocelot.log(curtext)
@@ -209,30 +215,30 @@ function _G.read(readHistoryType, prefix, defaultText)
local key = keyboard.keys[keycode] local key = keyboard.keys[keycode]
if key == "up" and readHistoryType then if key == "up" and readHistoryType then
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. curtext .. " ", false) termlib.write(prefix .. curtext .. " ")
RHIndex = RHIndex - 1 RHIndex = RHIndex - 1
if RHIndex <= 0 then if RHIndex <= 0 then
RHIndex = 1 RHIndex = 1
end end
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. termlib.readHistory[readHistoryType][RHIndex] .. string.rep(" ", unicode.wlen(curtext) - unicode.wlen(termlib.readHistory[readHistoryType][RHIndex])), false) termlib.write(prefix .. termlib.readHistory[readHistoryType][RHIndex] .. string.rep(" ", unicode.wlen(curtext) - unicode.wlen(termlib.readHistory[readHistoryType][RHIndex])))
curtext = termlib.readHistory[readHistoryType][RHIndex] curtext = termlib.readHistory[readHistoryType][RHIndex]
end end
if key == "down" and readHistoryType then if key == "down" and readHistoryType then
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. curtext .. " ", false) termlib.write(prefix .. curtext .. " ")
RHIndex = RHIndex + 1 RHIndex = RHIndex + 1
if RHIndex > #termlib.readHistory[readHistoryType] then if RHIndex > #termlib.readHistory[readHistoryType] then
RHIndex = #termlib.readHistory[readHistoryType] RHIndex = #termlib.readHistory[readHistoryType]
end end
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. termlib.readHistory[readHistoryType][RHIndex] .. string.rep(" ", unicode.wlen(curtext) - unicode.wlen(termlib.readHistory[readHistoryType][RHIndex])), false) termlib.write(prefix .. termlib.readHistory[readHistoryType][RHIndex] .. string.rep(" ", unicode.wlen(curtext) - unicode.wlen(termlib.readHistory[readHistoryType][RHIndex])))
curtext = termlib.readHistory[readHistoryType][RHIndex] curtext = termlib.readHistory[readHistoryType][RHIndex]
end end
if key == "back" then if key == "back" then
curtext = curtext:sub(1, #curtext-1) curtext = curtext:sub(1, #curtext-1)
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. curtext.." ", false) termlib.write(prefix .. curtext.." ")
end end
if key == "enter" then if key == "enter" then
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
@@ -251,14 +257,14 @@ function _G.read(readHistoryType, prefix, defaultText)
end end
end end
termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY termlib.cursorPosX, termlib.cursorPosY = cursorPosX, cursorPosY
print(prefix .. curtext, false) termlib.write(prefix .. curtext)
else else
cursorWhite = not cursorWhite cursorWhite = not cursorWhite
end end
if cursorWhite then if cursorWhite then
print("\27[107m ", false) termlib.write("\27[107m ")
else else
print(" ", false) termlib.write(" ")
end end
end end
end end
+1
View File
@@ -8,6 +8,7 @@ local raster = {
["charHeight"]=0 ["charHeight"]=0
} }
local component = import("component")
-- local ocelot = component.proxy(component.list("ocelot")()) -- local ocelot = component.proxy(component.list("ocelot")())
local gpu = component.proxy(component.list("gpu")()) local gpu = component.proxy(component.list("gpu")())