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

Update KTC1 draft, add palette 'suggestion' mechanism, and write a usable draft of us-evrst

This commit is contained in:
20kdc 2018-04-12 11:26:31 +01:00
parent 2597c9e5aa
commit 2e283d2767
3 changed files with 57 additions and 1 deletions

View File

@ -14,7 +14,7 @@ A 256-colour palette is assumed, and it is assumed that the palette is provided
A KTC1 block is one OpenComputers character (2x4 pixels), and is 4 bytes long. A KTC1 block is one OpenComputers character (2x4 pixels), and is 4 bytes long.
The format amounts to a foreground palette index, a background palette index, The format amounts to a background palette index, a foreground palette index,
and a Unicode character index in the Basic Multilingual Plane. and a Unicode character index in the Basic Multilingual Plane.
The unicode character is displayed with the given colours at the position of the The unicode character is displayed with the given colours at the position of the

View File

@ -500,6 +500,22 @@ everestProvider(function (pkg, pid, sendSig)
if y == 0 then return end if y == 0 then return end
handleSpan(surf, x, y + 1, text, bg, fg) handleSpan(surf, x, y + 1, text, bg, fg)
end, end,
recommendPalette = function (pal)
neo.ensureType(pal, "table")
if neo.dead then return 0 end
if not focusState then return 0 end
local m = monitors[surf[1]]
if not m then return 0 end
local cb, rb = m[1]()
if not cb then return 0 end
if rb then
monitorResetBF(m)
end
for k, v in ipairs(pal) do
local ok = pcall(cb.setPaletteColor, k - 1, v)
if not ok then return k - 1 end
end
end,
close = function () close = function ()
if neo.dead then return end if neo.dead then return end
local os1 = surfaces[1] local os1 = surfaces[1]

View File

@ -13,6 +13,46 @@ Implementing this API, by definition,
heavily restricted unless the user heavily restricted unless the user
uses the Advanced Settings panel. uses the Advanced Settings panel.
The API gives you a function:
(w, h, title) -> window
This function creates a window.
Window fields:
id: Window ID.
setSize(w, h): Changes the size of
the window, and sends the line
events (even if the size doesn't
change)
getDepth(): Returns the depth of the
screen the window is on.
span(x, y, text, bg, fg): Draws a
span onto the screen.
This function will error if the
Everest instance is dead.
(Others won't.)
recommendPalette(pal): If the window
is focused, sets the first #pal
palette entries to the given RGB
values.
This is meant only as a hint to
Everest, and may be ignored.
Returns 0.
close(): Close the window.
Events:
api, id, "key", ka, kc, down
api, id, "touch"/"drag"/"drop",
lx, ly, ix, iy, button
api, id, "scroll",
lx, ly, ix, iy, amount
api, id, "clipboard", text
api, id, "close"
api, id, "focus", hasFocus
api, id, "line", lineIndex
-- This is released into -- This is released into
the public domain. the public domain.
-- No warranty is provided, -- No warranty is provided,