made unified colors and stuff

This commit is contained in:
2026-03-19 08:33:47 -04:00
parent 4f9eebade2
commit 9b338328f0
40 changed files with 1218 additions and 1145 deletions

View File

@@ -261,16 +261,16 @@ local function render()
syscall.write(1, "\n")
end
end
syscall.devctl(1, "sfgc", 16)
syscall.devctl(1, "sbgc", 13)
syscall.devctl(1, "sfgc", 0x000000)
syscall.devctl(1, "sbgc", 0xDBDBDB)
local pct = math.floor(math.min(100, (scroll + pageSize) / totalLines * 100))
local status = string.format(" help -- line %d/%d (%d%%) [up/down: scroll q: quit] ",
scroll + 1, totalLines, pct)
if #status > screenW then status = status:sub(1, screenW) end
syscall.devctl(1, "spos", 1, screenH)
syscall.write(1, status .. string.rep(" ", screenW - #status))
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sbgc", 16)
syscall.devctl(1, "sfgc", 0xFFFFFF)
syscall.devctl(1, "sbgc", 0x000000)
dirty = false
end
@@ -281,7 +281,7 @@ if totalLines <= pageSize then
syscall.devctl(1, "sfgc", line[2])
syscall.write(1, line[1] .. "\n")
end
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end
@@ -305,5 +305,5 @@ end
syscall.devctl(1, "clear")
syscall.devctl(1, "spos", 1, 1)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sbgc", 16)
syscall.devctl(1, "sfgc", 0xFFFFFF)
syscall.devctl(1, "sbgc", 0x000000)

View File

@@ -3,11 +3,11 @@
-- 1=white, 2=red, 3=green, 4=blue, 5=cyan, 6=magenta, 7=yellow
-- 8=orange, 9=lime, 10=lightcyan, 11=brown, 12=darkgrey, 13=lightgrey, 14=purple, 15=chartreuse, 16=black
local C_LOGO = 5 -- cyan
local C_WHITE = 1 -- white
local C_LABEL = 13 -- light grey (key names)
local C_SEP = 12 -- dark grey (---- separator)
local C_USER = 3 -- green (user@host)
local C_LOGO = 0x00FFFF -- cyan
local C_WHITE = 0xFFFFFF -- white
local C_LABEL = 0xDBDBDB -- light grey (key names)
local C_SEP = 0x6D6D6D -- dark grey (---- separator)
local C_USER = 0x00FF00 -- green (user@host)
local function c(col) syscall.devctl(1, "sfgc", col) end

View File

@@ -8,7 +8,7 @@ local success, errorMsg = xpcall(function()
local fs = require("fs")
syscall.devctl(1,"clear")
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
syscall.devctl(1,"spos",1,1)
print("HyperionOS hysh Shell")
@@ -26,8 +26,27 @@ else
end
local oldWD = ""
local colors = {
0xFFFFFF,
0xFF0000,
0x00FF00,
0x0000FF,
0x00FFFF,
0xFF00FF,
0xFFFF00,
0xFF6D00,
0x6DFF55,
0x24FFFF,
0x924900,
0x6D6D55,
0xDBDBAA,
0x6D00FF,
0xB6FF00,
0x000000
}
for i = 1, 16 do
syscall.devctl(1,"sbgc",i); printInline(" ")
syscall.devctl(1,"sbgc",colors[i]); printInline(" ")
end
print("\n")
@@ -221,7 +240,7 @@ end
builtinCmds.clear = function()
syscall.devctl(1,"clear")
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
syscall.devctl(1,"spos",1,1)
end
@@ -429,7 +448,7 @@ builtinCmds.head = function(...)
local multi = #files > 1
local function dohead(text, label)
if multi then
syscall.devctl(1,"sfgc",4); print("==> "..label.." <=="); syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0x0000FF); print("==> "..label.." <=="); syscall.devctl(1,"sfgc",0xFFFFFF)
end
local count = 0
for line in (text.."\n"):gmatch("([^\n]*)\n") do
@@ -468,7 +487,7 @@ builtinCmds.tail = function(...)
local multi = #files > 1
local function dotail(text, label)
if multi then
syscall.devctl(1,"sfgc",4); print("==> "..label.." <=="); syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0x0000FF); print("==> "..label.." <=="); syscall.devctl(1,"sfgc",0xFFFFFF)
end
local lines = splitlines(text)
local start = math.max(1, #lines - n + 1)
@@ -963,13 +982,13 @@ local function doTabComplete(input, cursorPos)
end
local function getUserInput()
syscall.devctl(1,"sfgc",3)
syscall.devctl(1,"sfgc",0x00FF00)
syscall.write(1, userhost)
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
syscall.write(1, ":")
syscall.devctl(1,"sfgc",10)
syscall.devctl(1,"sfgc",0x24FFFF)
syscall.write(1, syscall.getcwd())
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
syscall.write(1, "$ ")
local curOffsetStr = syscall.devctl(1, "gpos")
local curOffsetX = tonumber(curOffsetStr:sub(1, curOffsetStr:find(";")-1))
@@ -1020,21 +1039,21 @@ local function getUserInput()
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
syscall.write(1, string.sub(input, 1, cursorPos-1))
if blinkState then
syscall.devctl(1,"sfgc",16); syscall.devctl(1,"sbgc",1)
syscall.devctl(1,"sfgc",0x000000); syscall.devctl(1,"sbgc",0xFFFFFF)
end
if cursorPos > #input then
syscall.write(1, " ")
else
syscall.write(1, string.sub(input, cursorPos, cursorPos))
end
syscall.devctl(1,"sfgc",1); syscall.devctl(1,"sbgc",16)
syscall.devctl(1,"sfgc",0xFFFFFF); syscall.devctl(1,"sbgc",0x000000)
local after = string.sub(input, cursorPos+1)
syscall.write(1, after)
local ghost = getGhostSuffix()
if #ghost > 0 then
syscall.devctl(1,"sfgc",14)
syscall.devctl(1,"sfgc",0x6D00FF)
syscall.write(1, ghost)
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
syscall.write(1, " ")
else
syscall.write(1, " ")
@@ -1082,10 +1101,10 @@ local function getUserInput()
syscall.write(1, string.rep(" ", tw))
syscall.devctl(1,"spos",1,py)
end
syscall.devctl(1,"sfgc",3); syscall.write(1, userhost)
syscall.devctl(1,"sfgc",1); syscall.write(1, ":")
syscall.devctl(1,"sfgc",10); syscall.write(1, syscall.getcwd())
syscall.devctl(1,"sfgc",1); syscall.write(1, "$ ")
syscall.devctl(1,"sfgc",0x00FF00); syscall.write(1, userhost)
syscall.devctl(1,"sfgc",0xFFFFFF); syscall.write(1, ":")
syscall.devctl(1,"sfgc",0x00FFFF); syscall.write(1, syscall.getcwd())
syscall.devctl(1,"sfgc",0xFFFFFF); syscall.write(1, "$ ")
posStr = syscall.devctl(1, "gpos")
sep = posStr:find(";")
curOffsetX = tonumber(posStr:sub(1, sep-1))
@@ -1098,7 +1117,7 @@ local function getUserInput()
cursorPos=cursorPos-1;dirty=true
end
elseif key=="\n" then
syscall.devctl(1,"sfgc",1);syscall.devctl(1,"sbgc",16)
syscall.devctl(1,"sfgc",0xFFFFFF);syscall.devctl(1,"sbgc",0x000000)
syscall.devctl(1,"spos",curOffsetX,curOffsetY)
syscall.write(1, input.." \n")
return input
@@ -1114,7 +1133,7 @@ local function getUserInput()
end
local function printError(progName, msg)
syscall.devctl(1,"sfgc",2)
syscall.devctl(1,"sfgc",0xFF0000)
local s = tostring(msg)
local line, rest = s:match("%]:(%d+): (.+)$")
if not line then line, rest = s:match(":(%d+): (.+)$") end
@@ -1123,7 +1142,7 @@ local function printError(progName, msg)
else
print(progName..": "..s)
end
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
end
local function runCommand(command)
@@ -1171,7 +1190,7 @@ local function runCommand(command)
local xok, xerr = pcall(syscall.access, cmdPath, "x")
if not xok then
syscall.devctl(1,"sfgc",2); print(progName..": Permission denied"); syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFF0000); print(progName..": Permission denied"); syscall.devctl(1,"sfgc",0xFFFFFF)
return
end
@@ -1195,8 +1214,8 @@ local function runCommand(command)
if terminate then
local ok2 = syscall.kill(proc)
if ok2 then
syscall.devctl(1,"sbgc",16); syscall.devctl(1,"sfgc",2)
print("\nProgram Terminated."); syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sbgc",16); syscall.devctl(1,"sfgc",0xFF0000)
print("\nProgram Terminated."); syscall.devctl(1,"sfgc",0xFFFFFF)
end
terminate = false; break
end
@@ -1218,8 +1237,8 @@ end, debug.traceback)
if not success then
syscall.log("Error running shell: "..errorMsg, "ERROR")
syscall.devctl(1,"sfgc",2)
syscall.devctl(1,"sbgc",16)
syscall.devctl(1,"sfgc",0xFF0000)
syscall.devctl(1,"sbgc",0x000000)
print()
print("Error running shell: ")
print(errorMsg)

View File

@@ -37,9 +37,9 @@ local function firstBoot()
syscall.devctl(1, "clear")
syscall.devctl(1, "spos", 1, 1)
syscall.devctl(1, "sfgc", 3)
syscall.devctl(1, "sfgc", 0x00FF00)
syscall.write(1, "HyperionOS First Boot Setup\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
syscall.write(1, "No root password is set. Please create one now.\n\n")
while true do
@@ -49,25 +49,25 @@ local function firstBoot()
local pw2 = readLine("*")
if pw1 ~= pw2 then
syscall.devctl(1, "sfgc", 2)
syscall.devctl(1, "sfgc", 0xFF0000)
syscall.write(1, "Passwords do not match. Try again.\n\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
elseif #pw1 < 6 then
syscall.devctl(1, "sfgc", 2)
syscall.devctl(1, "sfgc", 0xFF0000)
syscall.write(1, "Password too short (minimum 6 characters).\n\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
else
local ok, err = syscall.setpassword(0, pw1)
if ok then
syscall.devctl(1, "sfgc", 3)
syscall.devctl(1, "sfgc", 0x00FF00)
syscall.write(1, "Root password set.\n\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
sleep(0.5)
break
else
syscall.devctl(1, "sfgc", 2)
syscall.devctl(1, "sfgc", 0xFF0000)
syscall.write(1, "Error: " .. tostring(err) .. "\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
end
end
@@ -112,8 +112,8 @@ end
local function doLogin()
syscall.devctl(1, "clear")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sbgc", 16)
syscall.devctl(1, "sfgc", 0xFFFFFF)
syscall.devctl(1, "sbgc", 0x000000)
syscall.devctl(1, "spos", 1, 1)
local hostname = syscall.getHostname() or "hyperion"
@@ -122,7 +122,7 @@ local function doLogin()
local attempts = 0
while attempts < MAX_ATTEMPTS do
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
syscall.write(1, "Username: ")
local username = readLine(nil)
@@ -140,9 +140,9 @@ local function doLogin()
local shell = (pwent and pwent.shell) or "/bin/hysh"
local homedir = (pwent and pwent.homedir) or "/"
syscall.devctl(1, "sfgc", 3)
syscall.devctl(1, "sfgc", 0x00FF00)
syscall.write(1, "\nWelcome, " .. username .. "!\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
sleep(0.3)
spawnShell(username, uid, shell, homedir)
@@ -150,16 +150,16 @@ local function doLogin()
else
attempts = attempts + 1
sleep(1)
syscall.devctl(1, "sfgc", 2)
syscall.devctl(1, "sfgc", 0xFF0000)
syscall.write(1, "Login incorrect.\n\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
end
end
syscall.devctl(1, "sfgc", 2)
syscall.devctl(1, "sfgc", 0xFF0000)
syscall.write(1, "Maximum login attempts exceeded.\n")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
sleep(5)
end

View File

@@ -110,9 +110,9 @@ if opts.x then
pcall(syscall.umount, tmpMnt)
pcall(syscall.lodetach, loopId)
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": extracted "..count.." file(s) to "..destPath)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end
@@ -150,8 +150,8 @@ local lineCount = 0
for _ in imgStr:gmatch("\n") do lineCount = lineCount + 1 end
local byteCount = #imgStr
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": image written to "..imgPath)
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0x6D00FF)
print(string.format(" %d records, %d bytes", lineCount - 1, byteCount))
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)

View File

@@ -60,18 +60,18 @@ if opts.l then
local info = devs[id]
local mode = (type(info) == "table" and info.mode) or "bind"
local path = (type(info) == "table" and info.path) or tostring(info)
local colour = mode == "image" and 5 or 4
syscall.devctl(1, "sfgc", 3)
local colour = mode == "image" and 0x00FFFF or 0x0000FF
syscall.devctl(1, "sfgc", 0x00FF00)
printInline(string.format("%-10s", id))
syscall.devctl(1, "sfgc", colour)
printInline(string.format("%-7s", "["..mode.."]"))
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
print(" "..path)
end
if not any then
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0x6D00FF)
print(name..": no loop devices attached")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
return
end
@@ -92,9 +92,9 @@ if opts.d then
end
print(name..": "..msg); syscall.exit(1); return
end
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": detached "..id)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end

View File

@@ -136,26 +136,26 @@ if cloptions.l then
printInline(tostring(mtime) .. " ")
if isSym then
syscall.devctl(1, "sfgc", 6)
syscall.devctl(1, "sfgc", 0xFF00FF)
printInline(v)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
local ok, target = pcall(syscall.readlink, fullPath)
if ok then
printInline(" -> ")
local targetExists = pcall(syscall.stat, fullPath)
syscall.devctl(1, "sfgc", targetExists and 6 or 2)
syscall.devctl(1, "sfgc", targetExists and 0xFF00FF or 0xFF0000)
printInline(target)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
elseif isDir then
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0x6D00FF)
printInline(v)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
else
local isExec = stat and stat.perms and (math.floor(stat.perms / (2^9)) % 2 == 1)
syscall.devctl(1, "sfgc", isExec and 3 or 1)
syscall.devctl(1, "sfgc", isExec and 0x00FF00 or 0xFFFFFF)
printInline(v)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
print("")
end
@@ -175,16 +175,16 @@ for i, v in ipairs(list) do
local isSym = stat and stat.etype == 0x01
if isSym then
syscall.devctl(1, "sfgc", 6)
syscall.devctl(1, "sfgc", 0xFF00FF)
elseif isDir then
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0x6D00FF)
else
local isExec = stat and stat.perms and (math.floor(stat.perms / (2^9)) % 2 == 1)
syscall.devctl(1, "sfgc", isExec and 3 or 1)
syscall.devctl(1, "sfgc", isExec and 0x00FF00 or 0xFFFFFF)
end
printInline(v)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
printInline((" "):rep(colWidth - #v))
if i % numCols == 0 then print("") end

View File

@@ -5,15 +5,15 @@ if not users or #users == 0 then
return
end
syscall.devctl(1,"sfgc",13)
syscall.devctl(1,"sfgc",0xDBDBDB)
print(string.format("%-6s %-6s %-16s %-20s %s", "UID", "GID", "Username", "Home", "Shell"))
print(string.rep("-", 65))
syscall.devctl(1,"sfgc",1)
syscall.devctl(1,"sfgc",0xFFFFFF)
for _, u in ipairs(users) do
local lock_marker = u.locked and " [locked]" or ""
if u.locked then syscall.devctl(1,"sfgc",2) end
if u.locked then syscall.devctl(1,"sfgc",0xFF0000) end
print(string.format("%-6d %-6d %-16s %-20s %s%s",
u.uid, u.gid, u.username, u.homedir, u.shell, lock_marker))
if u.locked then syscall.devctl(1,"sfgc",1) end
if u.locked then syscall.devctl(1,"sfgc",0xFFFFFF) end
end

View File

@@ -69,17 +69,17 @@ if #args == 0 and not opts.o then
end
if next(loDevs) == nil then
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0xFF00FF)
print("(no loop devices attached)")
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end
for id, info in pairs(loDevs) do
local colour = info.mode == "image" and 5 or 4
local colour = info.mode == "image" and 0x00FFFF or 0x0000FF
syscall.devctl(1, "sfgc", colour)
printInline(info.mode.." "..id)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
print(" on "..info.path)
end
return
@@ -119,9 +119,9 @@ if opts.o and opts.o:lower() == "loop" then
print(name..": mount: "..msg); syscall.exit(1); return
end
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": "..loopId.." mounted at "..dest)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end
@@ -141,9 +141,9 @@ if #args == 2 then
print(name..": "..msg); syscall.exit(1); return
end
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": "..loopId.." mounted at "..dest)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end

View File

@@ -1,6 +1,9 @@
--:Minify:--
local targetUser = ({ ... })[1]
local currentUid = syscall.getuid()
if syscall.geteuid()~=0 then
syscall.exec("/bin/su", {...})
end
local targetUid
if targetUser then
targetUid = syscall.getuidbyname(targetUser)

View File

@@ -59,9 +59,9 @@ if opts.l then
end
print(name..": "..msg); syscall.exit(1); return
end
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": detached "..id)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
return
end
@@ -95,17 +95,17 @@ if not ok then
print(name..": "..msg); syscall.exit(1); return
end
syscall.devctl(1, "sfgc", 10)
syscall.devctl(1, "sfgc", 0x00FFFF)
print(name..": unmounted "..mpt)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
if loopIdToDetach then
for _, id in ipairs(loopIdToDetach) do
local dok = pcall(syscall.lodetach, id)
if dok then
syscall.devctl(1, "sfgc", 14)
syscall.devctl(1, "sfgc", 0xFF00FF)
print(name..": auto-detached "..id)
syscall.devctl(1, "sfgc", 1)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
end
end