v2.2.0 - Added support for 8-bit color and 24-bit color ANSI control codes in the terminal library.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
local agcfg = {
|
local agcfg = {
|
||||||
["halyde"] = {
|
["halyde"] = {
|
||||||
["maindir"] = "",
|
["maindir"] = "",
|
||||||
["version"] = "2.1.1",
|
["version"] = "2.2.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,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 2.1.1"
|
_G._OSVERSION = "Halyde 2.2.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
|
||||||
|
|||||||
+37
-1
@@ -72,6 +72,29 @@ local function parseCodeNumbers(code)
|
|||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function from8BitColor(num)
|
||||||
|
num=math.floor(num)&255
|
||||||
|
if num<16 then return 0x444444*((num>>3)&1)+(0xBB0000*((num>>2)&1)|0x00BB00*((num>>1)&1)|0x0000BB*(num&1)) end
|
||||||
|
if num>=232 then return 0x10101*(8+(num-232)*10) end
|
||||||
|
num=num-16
|
||||||
|
local palette = {0,95,135,175,215,255}
|
||||||
|
return (palette[(num//36)%6+1]<<16)|(palette[(num//6)%6+1]<<8)|palette[num%6+1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function from24BitColor(r,g,b)
|
||||||
|
r,g,b=math.floor(r)&255,math.floor(g)&255,math.floor(b)&255
|
||||||
|
return (r<<16)|(g<<8)|b
|
||||||
|
end
|
||||||
|
|
||||||
|
local function findCodeEnd(text,i)
|
||||||
|
local function inRange(v,min,max)
|
||||||
|
return v>=min and v<=max
|
||||||
|
end
|
||||||
|
i=i+2
|
||||||
|
while not inRange(text:byte(i),0x40,0x7F) do i=i+1 end
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
|
||||||
function termlib.write(text, textWrap)
|
function termlib.write(text, textWrap)
|
||||||
width, height = gpu.getResolution()
|
width, height = gpu.getResolution()
|
||||||
|
|
||||||
@@ -130,7 +153,8 @@ function termlib.write(text, textWrap)
|
|||||||
if codeType=="[" then
|
if codeType=="[" then
|
||||||
-- Control Sequence Introducer
|
-- Control Sequence Introducer
|
||||||
--ocelot.log("Control Sequence Introducer")
|
--ocelot.log("Control Sequence Introducer")
|
||||||
codeEndIdx = string.find(text,"m",i)
|
codeEndIdx = findCodeEnd(text,i)
|
||||||
|
-- codeEndIdx = string.find(text,"m",i)
|
||||||
code = string.sub(text,i,codeEndIdx)
|
code = string.sub(text,i,codeEndIdx)
|
||||||
--ocelot.log("Code: "..code.." ("..i..", "..codeEndIdx..")")
|
--ocelot.log("Code: "..code.." ("..i..", "..codeEndIdx..")")
|
||||||
readBreak = readBreak + #code - 1
|
readBreak = readBreak + #code - 1
|
||||||
@@ -143,12 +167,24 @@ function termlib.write(text, textWrap)
|
|||||||
if nums[1]>=30 and nums[1]<=37 then
|
if nums[1]>=30 and nums[1]<=37 then
|
||||||
gpu.setForeground(ANSIColorPalette["dark"][nums[1]%10])
|
gpu.setForeground(ANSIColorPalette["dark"][nums[1]%10])
|
||||||
end
|
end
|
||||||
|
if nums[1]==38 and nums[2]==5 then
|
||||||
|
gpu.setForeground(from8BitColor(nums[3]))
|
||||||
|
end
|
||||||
|
if nums[1]==38 and nums[2]==2 then
|
||||||
|
gpu.setForeground(from24BitColor(nums[3],nums[4],nums[5]))
|
||||||
|
end
|
||||||
if nums[1]==39 or nums[1]==0 then
|
if nums[1]==39 or nums[1]==0 then
|
||||||
gpu.setForeground(defaultForegroundColor)
|
gpu.setForeground(defaultForegroundColor)
|
||||||
end
|
end
|
||||||
if nums[1]>=40 and nums[1]<=47 then
|
if nums[1]>=40 and nums[1]<=47 then
|
||||||
gpu.setBackground(ANSIColorPalette["dark"][nums[1]%10])
|
gpu.setBackground(ANSIColorPalette["dark"][nums[1]%10])
|
||||||
end
|
end
|
||||||
|
if nums[1]==48 and nums[2]==5 then
|
||||||
|
gpu.setBackground(from8BitColor(nums[3]))
|
||||||
|
end
|
||||||
|
if nums[1]==48 and nums[2]==2 then
|
||||||
|
gpu.setBackground(from24BitColor(nums[3],nums[4],nums[5]))
|
||||||
|
end
|
||||||
if nums[1]==49 or nums[1]==0 then
|
if nums[1]==49 or nums[1]==0 then
|
||||||
gpu.setBackground(defaultBackgroundColor)
|
gpu.setBackground(defaultBackgroundColor)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user