1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-27 04:48:05 +11:00

Finally settle on an exact level of support

This commit is contained in:
20kdc 2020-04-02 21:39:30 +01:00
parent c9157a1b7c
commit fe17b0fb93
3 changed files with 50 additions and 46 deletions

View File

@ -30,6 +30,7 @@ local console = {}
-- This must not go below 3. -- This must not go below 3.
local conW = 40 local conW = 40
local conCX, conCY = 1, 1 local conCX, conCY = 1, 1
local conSCX, conSCY = 1, 1
-- Performance -- Performance
local consoleShown = {} local consoleShown = {}
local conCYShown local conCYShown
@ -138,6 +139,13 @@ local function consoleSU()
end end
end end
local function consoleCLS()
for i = 1, #console do
console[i] = (" "):rep(conW)
end
conCX, conCY = 1, 1
end
local function writeFF() local function writeFF()
if conCY ~= #console then if conCY ~= #console then
conCY = conCY + 1 conCY = conCY + 1
@ -150,6 +158,7 @@ local function writeData(data)
-- handle data until completion -- handle data until completion
while #data > 0 do while #data > 0 do
local char = unicode.sub(data, 1, 1) local char = unicode.sub(data, 1, 1)
--neo.emergency("svc-t.data: " .. char:byte())
data = unicode.sub(data, 2) data = unicode.sub(data, 2)
-- handle character -- handle character
if char == "\t" then if char == "\t" then
@ -187,17 +196,22 @@ local function writeANSI(s)
--neo.emergency("svc-t.ansi: " .. s) --neo.emergency("svc-t.ansi: " .. s)
-- This supports just about enough to get by. -- This supports just about enough to get by.
if s == "c" then if s == "c" then
for i = 1, #console do consoleCLS()
console[i] = (" "):rep(conW)
end
conCX, conCY = 1, 1
return return
end end
local pfx = s:sub(1, 1) local pfx = s:sub(1, 1)
local cmd = s:sub(#s) local cmd = s:sub(#s)
if pfx == "[" then if pfx == "[" then
local np = tonumber(s:sub(2, -2)) or 1 local np = tonumber(s:sub(2, -2)) or 1
if cmd == "H" or cmd == "f" then if cmd == "A" then
conCY = conCY - np
elseif cmd == "B" then
conCY = conCY + np
elseif cmd == "C" then
conCX = conCX + np
elseif cmd == "D" then
conCX = conCX - np
elseif cmd == "f" or cmd == "H" then
local p = s:find(";") local p = s:find(";")
if not p then if not p then
conCY = np conCY = np
@ -206,28 +220,25 @@ local function writeANSI(s)
conCY = tonumber(s:sub(2, p - 1)) or 1 conCY = tonumber(s:sub(2, p - 1)) or 1
conCX = tonumber(s:sub(p + 1, -2)) or 1 conCX = tonumber(s:sub(p + 1, -2)) or 1
end end
elseif cmd == "K" then
console[conCY] = unicode.sub(console[conCY], 1, conCX - 1) .. (" "):rep(1 + conW - conCX)
elseif cmd == "J" then elseif cmd == "J" then
for i = 1, #console do consoleCLS()
console[i] = (" "):rep(conW) elseif cmd == "K" then
if s == "[K" or s == "[0K" then
-- bash needs this
console[conCY] = unicode.sub(console[conCY], 1, conCX - 1) .. (" "):rep(1 + conW - conCX)
else
console[conCY] = (" "):rep(conW)
end end
elseif cmd == "A" then elseif cmd == "n" then
conCY = conCY - np if s == "[6n" then
elseif cmd == "B" then for _, v in pairs(sendSigs) do
conCY = conCY + np v("data", "\x1b[" .. conY .. ";" .. conX .. "R")
elseif cmd == "C" then
conCX = conCX + np
elseif cmd == "D" then
conCX = conCX - np
elseif cmd == "S" then
for i = 1, np do
consoleSU()
end end
elseif cmd == "T" then
for i = 1, np do
consoleSD()
end end
elseif cmd == "s" then
conSCX, conSCY = conCX, conCY
elseif cmd == "u" then
conCX, conCY = conSCX, conSCY
end end
end end
conCX = math.min(math.max(math.floor(conCX), 1), conW) conCX = math.min(math.max(math.floor(conCX), 1), conW)

View File

@ -34,7 +34,7 @@ term.write([[
KittenOS NEO MUD Terminal KittenOS NEO MUD Terminal
export TERM=ansi-generic <- IMPORTANT!!! export TERM=ansi.sys <- IMPORTANT!!!
Enter target server:port... Enter target server:port...
]]) ]])

View File

@ -1,34 +1,27 @@
The "svc-t" program / "x.svc.t" The "svc-t" program / "x.neo.pub.t"
permission makes up the terminal permission makes up the terminal
subsystem for KittenOS NEO. subsystem for KittenOS NEO.
--- THEORETICAL TERMINALS MODEL --- --- THEORETICAL TERMINALS MODEL ---
The theoretical model for terminals The theoretical model for terminals
in KittenOS NEO is a TELNET client in KittenOS NEO is a TELNET client,
that only supports the ECHO option, using the non-standard behavior of
and uses the non-standard behavior treating a lack of remote echo as
of treating ECHO ON as 'enable local meaning 'local line editing'.
line editing'.
To prevent code size going too far, To prevent code size going too far,
the client is extremely restricted the shipped terminal supports:
in capabilities.
1. Built-in history as part of the
line editing functionality
2. ANSI.SYS-compatible display, but
no support for attributes.
If you really want full support, If you really want full support,
write a better terminal application. write a better terminal application.
Features that get added will be added
in accordance with ANSI/TELNET where
reasonable or in a compatible-ish
fashion where unreasonable.
The defaults will be set based on
whatever app-luashell requires, as
this is what is expected of modern
terminal systems regardless of what
the standards may have to say.
A process starting another process A process starting another process
connected to the same terminal is connected to the same terminal is
advised to wait for that process to advised to wait for that process to
@ -82,7 +75,7 @@ When the terminal has shown, the
function provided is called with a function provided is called with a
table as follows: table as follows:
access = "x.svc.t/<...>" access = "x.neo.pub.t/<...>"
close = function (): close terminal close = function (): close terminal
The k.kill permission and the close The k.kill permission and the close
@ -95,7 +88,7 @@ In either case, when the access has
been acquired, the following API is been acquired, the following API is
presented: presented:
id = "x.svc.t/<...>" id = "x.neo.pub.t/<...>"
pid = <The terminal's PID.> pid = <The terminal's PID.>
write = function (text): Writes the write = function (text): Writes the
TELNET data to the terminal. TELNET data to the terminal.