|
|
@@ -15,6 +15,8 @@ function module.init()
|
|
|
|
local serialize = require("serialize")
|
|
|
|
local serialize = require("serialize")
|
|
|
|
local unicode = require("unicode")
|
|
|
|
local unicode = require("unicode")
|
|
|
|
local event = require("event")
|
|
|
|
local event = require("event")
|
|
|
|
|
|
|
|
local fs = require("filesystem")
|
|
|
|
|
|
|
|
local json = require("json")
|
|
|
|
|
|
|
|
|
|
|
|
local component = require("component")
|
|
|
|
local component = require("component")
|
|
|
|
local gpu = component.gpu
|
|
|
|
local gpu = component.gpu
|
|
|
@@ -39,6 +41,19 @@ function module.init()
|
|
|
|
table.insert(readHistory[id],hist)
|
|
|
|
table.insert(readHistory[id],hist)
|
|
|
|
end
|
|
|
|
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)
|
|
|
|
local function getColorPalette(depth)
|
|
|
|
if depth == 1 then
|
|
|
|
if depth == 1 then
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@@ -91,7 +106,16 @@ function module.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if depth == 8 then
|
|
|
|
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"] = {
|
|
|
|
["dark"] = {
|
|
|
|
[0] = 0x0f0f0f, -- black
|
|
|
|
[0] = 0x0f0f0f, -- black
|
|
|
|
[1] = 0xcc2424, -- dark red
|
|
|
|
[1] = 0xcc2424, -- dark red
|
|
|
@@ -112,7 +136,7 @@ function module.init()
|
|
|
|
[6] = 0x33dbc0, -- cyan
|
|
|
|
[6] = 0x33dbc0, -- cyan
|
|
|
|
[7] = 0xffffff -- white
|
|
|
|
[7] = 0xffffff -- white
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} ]]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--[[ Original color palette:
|
|
|
|
--[[ Original color palette:
|
|
|
|
{
|
|
|
|
{
|
|
|
@@ -150,6 +174,7 @@ function module.init()
|
|
|
|
FG = ANSIColorPalette["bright"][7], BG = ANSIColorPalette["dark"][0],
|
|
|
|
FG = ANSIColorPalette["bright"][7], BG = ANSIColorPalette["dark"][0],
|
|
|
|
fg = nil, bg = nil, reverse = false
|
|
|
|
fg = nil, bg = nil, reverse = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
require("log").terminal.info("FG and BG: " .. color.FG .. " " .. color.BG)
|
|
|
|
color.fg = color.FG
|
|
|
|
color.fg = color.FG
|
|
|
|
color.bg = color.BG
|
|
|
|
color.bg = color.BG
|
|
|
|
local current_codepoint = 0
|
|
|
|
local current_codepoint = 0
|
|
|
@@ -562,7 +587,7 @@ function module.init()
|
|
|
|
local args = {...}
|
|
|
|
local args = {...}
|
|
|
|
local stringArgs = {}
|
|
|
|
local stringArgs = {}
|
|
|
|
for _, arg in pairs(args) do
|
|
|
|
for _, arg in pairs(args) do
|
|
|
|
if type(arg) == "table" then
|
|
|
|
if type(arg)=="table" then
|
|
|
|
table.insert(stringArgs, serialize(arg))
|
|
|
|
table.insert(stringArgs, serialize(arg))
|
|
|
|
elseif tostring(arg) then
|
|
|
|
elseif tostring(arg) then
|
|
|
|
table.insert(stringArgs, tostring(arg))
|
|
|
|
table.insert(stringArgs, tostring(arg))
|
|
|
|