Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5de781471
|
||
|
|
d2ad6be236
|
||
|
|
ca65d252c9 | ||
|
|
fc184ea591 | ||
|
|
8a76ca11c9 | ||
|
|
8a3a34efc0 | ||
|
|
996d81129d | ||
|
|
499dfd6843 | ||
|
|
8aa08814a1 | ||
|
|
eaae852961 |
@@ -0,0 +1,60 @@
|
|||||||
|
-- Despite the name it's not telnet
|
||||||
|
local component = require("component")
|
||||||
|
if not component.isAvailable("internet") then
|
||||||
|
terminal.write("telnet: this program requires an internet card to run\n")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local internet = component.internet
|
||||||
|
if not internet.isTcpEnabled() then
|
||||||
|
terminal.write("telnet: TCP disabled\n")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local arg = {...}
|
||||||
|
local host = arg[1]
|
||||||
|
local port = tonumber(arg[2])
|
||||||
|
|
||||||
|
local sock = internet.connect(host, port)
|
||||||
|
|
||||||
|
local connected = false
|
||||||
|
local err
|
||||||
|
for _ = 1, 5 do
|
||||||
|
local ok
|
||||||
|
ok, err = sock.finishConnect()
|
||||||
|
if ok then
|
||||||
|
connected = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
coroutine.yield()
|
||||||
|
end
|
||||||
|
if not connected then
|
||||||
|
print("telnet: " .. err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
print(("connected to %s:%d"):format(host, port))
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local fromSocket = sock.read(math.maxinteger or math.huge)
|
||||||
|
if fromSocket == nil then
|
||||||
|
print("telnet: connection closed")
|
||||||
|
sock.close()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
terminal.write(fromSocket)
|
||||||
|
terminal.flush()
|
||||||
|
local fromTerminal = terminal.read()
|
||||||
|
if fromTerminal == "" then
|
||||||
|
sock.close()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
while fromTerminal ~= "" do
|
||||||
|
local nbytes, err = sock.write(fromTerminal .. "\r\n")
|
||||||
|
if err then
|
||||||
|
print("telnet: " .. err)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
fromTerminal = fromTerminal:sub(nbytes + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -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"}}}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"palette": {
|
||||||
|
"dark": {
|
||||||
|
"0": "0x0f0f0f",
|
||||||
|
"1": "0xcc2424",
|
||||||
|
"2": "0x339280",
|
||||||
|
"3": "0x996d00",
|
||||||
|
"4": "0x004980",
|
||||||
|
"5": "0x9949c0",
|
||||||
|
"6": "0x33b6c0",
|
||||||
|
"7": "0xc3c3c3"
|
||||||
|
},
|
||||||
|
"bright": {
|
||||||
|
"0": "0x666d80",
|
||||||
|
"1": "0xff6d40",
|
||||||
|
"2": "0x33db80",
|
||||||
|
"3": "0xffb600",
|
||||||
|
"4": "0x336dff",
|
||||||
|
"5": "0xcc6dc0",
|
||||||
|
"6": "0x33dbc0",
|
||||||
|
"7": "0xffffff"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)])
|
||||||
|
end
|
||||||
|
for i = 0, 7 do
|
||||||
|
palette["bright"][i] = tonumber(config.palette.bright[tostring(i)])
|
||||||
|
end
|
||||||
|
require("log").terminal.info("Set color palette: " .. serialize(palette, nil))
|
||||||
|
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:
|
||||||
{
|
{
|
||||||
@@ -146,8 +170,9 @@ function module.init()
|
|||||||
|
|
||||||
local cursor = { x = 1, y = 1, X = nil, Y = nil } -- X and Y are managed by ESC s and ESC u
|
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 printState = 0 -- 0:none 1:in ESC 2:in CSI
|
||||||
local DEFAULT_FG = ANSIColorPalette["bright"][7] -- TODO make configurable
|
local DEFAULT_FG = ANSIColorPalette["bright"][7]
|
||||||
local DEFAULT_BG = ANSIColorPalette["dark"][0]
|
local DEFAULT_BG = ANSIColorPalette["dark"][0]
|
||||||
|
require("log").terminal.info("FG and BG: " .. DEFAULT_FG .. " " .. DEFAULT_BG)
|
||||||
local fg = DEFAULT_FG
|
local fg = DEFAULT_FG
|
||||||
local bg = DEFAULT_BG
|
local bg = DEFAULT_BG
|
||||||
local gpuFg = nil
|
local gpuFg = nil
|
||||||
@@ -567,7 +592,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))
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user