From eaae8529618a96988e253b166d32a80d9148aa94 Mon Sep 17 00:00:00 2001 From: mcplayer3 <219271061+mcplayer3@users.noreply.github.com> Date: Sat, 20 Jun 2026 22:19:36 +1000 Subject: [PATCH] Started to add custom colour palettes I have literally no idea why it wont work but if anyone picks this up you'll know it works when the old Halyde colours show up --- halyde/config/generate/terminal.json | 1 + halyde/config/terminal.json | 1 + halyde/kernel/modules/terminal.lua | 34 +++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 halyde/config/generate/terminal.json create mode 100644 halyde/config/terminal.json diff --git a/halyde/config/generate/terminal.json b/halyde/config/generate/terminal.json new file mode 100644 index 0000000..2d43851 --- /dev/null +++ b/halyde/config/generate/terminal.json @@ -0,0 +1 @@ +{"palette":{"dark":{"0":"171421","1":"c01c28","2":"26a269","3":"a2734c","4":"12488b","5":"a347ba","6":"2aa1b3","7":"d0cfcc"},"bright":{"0":"5e5c64","1":"f66151","2":"33d17a","3":"e9ad0c","4":"2a7bde","5":"c061cb","6":"33c7de","7":"ffffff"}}} \ No newline at end of file diff --git a/halyde/config/terminal.json b/halyde/config/terminal.json new file mode 100644 index 0000000..2d43851 --- /dev/null +++ b/halyde/config/terminal.json @@ -0,0 +1 @@ +{"palette":{"dark":{"0":"171421","1":"c01c28","2":"26a269","3":"a2734c","4":"12488b","5":"a347ba","6":"2aa1b3","7":"d0cfcc"},"bright":{"0":"5e5c64","1":"f66151","2":"33d17a","3":"e9ad0c","4":"2a7bde","5":"c061cb","6":"33c7de","7":"ffffff"}}} \ No newline at end of file diff --git a/halyde/kernel/modules/terminal.lua b/halyde/kernel/modules/terminal.lua index 28c6918..604c82c 100644 --- a/halyde/kernel/modules/terminal.lua +++ b/halyde/kernel/modules/terminal.lua @@ -15,6 +15,8 @@ function module.init() local serialize = require("serialize") local unicode = require("unicode") local event = require("event") + local fs = require("filesystem") + local json = require("json") local component = require("component") local gpu = component.gpu @@ -39,6 +41,19 @@ function module.init() table.insert(readHistory[id],hist) end + if not fs.exists("/halyde/config/terminal.json") then + fs.copy("/halyde/config/generate/terminal.json", "/halyde/config/terminal.json") + end + local config = "" + local tmpdata + local handle = fs.open("/halyde/config/terminal.json") + repeat + tmpdata = handle:read(math.huge) + config = config .. (tmpdata or "") + until not tmpdata + config = json.decode(config) + require("log").terminal.info("Loaded config file: " .. serialize(config, " ")) + local function getColorPalette(depth) if depth == 1 then return { @@ -91,7 +106,16 @@ function module.init() } end if depth == 8 then - return { + local palette = {["dark"] = {}, ["bright"] = {}} + for i = 0, 7 do + palette["dark"][i] = tonumber(config.palette.dark[tostring(i)], 16) + end + for i = 0, 7 do + palette["bright"][i] = tonumber(config.palette.bright[tostring(i)], 16) + end + require("log").terminal.info("Set colour palette: " .. serialize(palette, " ")) + return palette + --[[ return { ["dark"] = { [0] = 0x0f0f0f, -- black [1] = 0xcc2424, -- dark red @@ -112,7 +136,7 @@ function module.init() [6] = 0x33dbc0, -- cyan [7] = 0xffffff -- white } - } + } ]] end --[[ Original color palette: { @@ -144,12 +168,16 @@ function module.init() local ANSIColorPalette = getColorPalette(gpu.maxDepth()) + local expecting_unicode_bytes = 0 + local unicode_bytes_left = 0 + local unicode_codepoint = 0 local cursor = { x = 1, y = 1, X = nil, Y = nil } -- X and Y are managed by ESC s and ESC u local printState = 0 -- 0:none 1:in ESC 2:in CSI local color = { FG = ANSIColorPalette["bright"][7], BG = ANSIColorPalette["dark"][0], fg = nil, bg = nil, reverse = false } + require("log").terminal.info("FG and BG: " .. color.FG .. " " .. color.BG) color.fg = color.FG color.bg = color.BG local current_codepoint = 0 @@ -562,7 +590,7 @@ function module.init() local args = {...} local stringArgs = {} for _, arg in pairs(args) do - if type(arg) == "table" then + if type(arg)=="table" then table.insert(stringArgs, serialize(arg)) elseif tostring(arg) then table.insert(stringArgs, tostring(arg))