1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-12-25 10:28:06 +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.
local conW = 40
local conCX, conCY = 1, 1
local conSCX, conSCY = 1, 1
-- Performance
local consoleShown = {}
local conCYShown
@ -138,6 +139,13 @@ local function consoleSU()
end
end
local function consoleCLS()
for i = 1, #console do
console[i] = (" "):rep(conW)
end
conCX, conCY = 1, 1
end
local function writeFF()
if conCY ~= #console then
conCY = conCY + 1
@ -150,6 +158,7 @@ local function writeData(data)
-- handle data until completion
while #data > 0 do
local char = unicode.sub(data, 1, 1)
--neo.emergency("svc-t.data: " .. char:byte())
data = unicode.sub(data, 2)
-- handle character
if char == "\t" then
@ -187,17 +196,22 @@ local function writeANSI(s)
--neo.emergency("svc-t.ansi: " .. s)
-- This supports just about enough to get by.
if s == "c" then
for i = 1, #console do
console[i] = (" "):rep(conW)
end
conCX, conCY = 1, 1
consoleCLS()
return
end
local pfx = s:sub(1, 1)
local cmd = s:sub(#s)
if pfx == "[" then
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(";")
if not p then
conCY = np
@ -206,28 +220,25 @@ local function writeANSI(s)
conCY = tonumber(s:sub(2, p - 1)) or 1
conCX = tonumber(s:sub(p + 1, -2)) or 1
end
elseif cmd == "K" then
console[conCY] = unicode.sub(console[conCY], 1, conCX - 1) .. (" "):rep(1 + conW - conCX)
elseif cmd == "J" then
for i = 1, #console do
console[i] = (" "):rep(conW)
consoleCLS()
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
elseif 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 == "S" then
for i = 1, np do
consoleSU()
end
elseif cmd == "T" then
for i = 1, np do
consoleSD()
elseif cmd == "n" then
if s == "[6n" then
for _, v in pairs(sendSigs) do
v("data", "\x1b[" .. conY .. ";" .. conX .. "R")
end
end
elseif cmd == "s" then
conSCX, conSCY = conCX, conCY
elseif cmd == "u" then
conCX, conCY = conSCX, conSCY
end
end
conCX = math.min(math.max(math.floor(conCX), 1), conW)

View File

@ -34,7 +34,7 @@ term.write([[
KittenOS NEO MUD Terminal
export TERM=ansi-generic <- IMPORTANT!!!
export TERM=ansi.sys <- IMPORTANT!!!
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
subsystem for KittenOS NEO.
--- THEORETICAL TERMINALS MODEL ---
The theoretical model for terminals
in KittenOS NEO is a TELNET client
that only supports the ECHO option,
and uses the non-standard behavior
of treating ECHO ON as 'enable local
line editing'.
in KittenOS NEO is a TELNET client,
using the non-standard behavior of
treating a lack of remote echo as
meaning 'local line editing'.
To prevent code size going too far,
the client is extremely restricted
in capabilities.
the shipped terminal supports:
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,
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
connected to the same terminal is
advised to wait for that process to
@ -82,7 +75,7 @@ When the terminal has shown, the
function provided is called with a
table as follows:
access = "x.svc.t/<...>"
access = "x.neo.pub.t/<...>"
close = function (): close terminal
The k.kill permission and the close
@ -95,7 +88,7 @@ In either case, when the access has
been acquired, the following API is
presented:
id = "x.svc.t/<...>"
id = "x.neo.pub.t/<...>"
pid = <The terminal's PID.>
write = function (text): Writes the
TELNET data to the terminal.