improve framebuffer mechanism

This commit is contained in:
osmarks 2023-11-10 11:38:46 +00:00
parent de706045a7
commit 1fa9891453
2 changed files with 25 additions and 10 deletions

View File

@ -1,2 +1,2 @@
{"build":302,"description":"potatOS.read_display","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"18d0c78709d714122fbde6df5647676f49632bad1a612f0042693cdff7257c99","bin/5rot26.lua":"417891a232e325476f980d31d88edc486d526611a6350ce47fd29cca464ebf2c","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/factor.lua":"f8d223839e6b9f4e8c85f46e8182e7ede7ec41e6644f0188d1f315014c79a2c0","bin/grep.lua":"1509bc267867b933e528ab74cfbc2a15fa2df0ec7389df4f9033194ab9037865","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"4399d7cc33004fb21be5a0e2ab8405b8e454c004395844ce7ec42a19965fd415","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","bin/workspace.lua":"acc8bb6f08b243378b68ab5f611e9a6cc8216b0713343dc93ddaa9101f07ffc5","potatobios.lua":"d7b199929333b33f0c50271ab0dbc35c89c413c0ccd8e876185db92b675217d1","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"d98dd13732ec63ce01347749823efc7cc3715816be818501f95416e3014d1061","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","xlib/00_cbor.lua":"8b1cc3588a5e31298d22e50b6752a4413f12f8113622962ed6555557448b408b","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":102422,"bin/5rot26.lua":1661,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/factor.lua":4263,"bin/grep.lua":1196,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6584,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"bin/workspace.lua":42971,"potatobios.lua":41565,"signing-key.tbl":190,"startup":8438,"stdlib.hvl":851,"xlib/00_cbor.lua":15831,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1699573443}
{"hash":"b940937bdb244c266dfea2dadfc7d334670721379fa6bb98fc4d9d85ba5c4b68"}
{"build":307,"description":"redo display read correctly","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"18d0c78709d714122fbde6df5647676f49632bad1a612f0042693cdff7257c99","bin/5rot26.lua":"417891a232e325476f980d31d88edc486d526611a6350ce47fd29cca464ebf2c","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/factor.lua":"f8d223839e6b9f4e8c85f46e8182e7ede7ec41e6644f0188d1f315014c79a2c0","bin/grep.lua":"1509bc267867b933e528ab74cfbc2a15fa2df0ec7389df4f9033194ab9037865","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"4399d7cc33004fb21be5a0e2ab8405b8e454c004395844ce7ec42a19965fd415","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","bin/workspace.lua":"acc8bb6f08b243378b68ab5f611e9a6cc8216b0713343dc93ddaa9101f07ffc5","potatobios.lua":"b1507c1f12a5b227fb7ced04c69966c687bea9b5d3bc39936d1c0cfe945bcf06","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"d98dd13732ec63ce01347749823efc7cc3715816be818501f95416e3014d1061","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","xlib/00_cbor.lua":"8b1cc3588a5e31298d22e50b6752a4413f12f8113622962ed6555557448b408b","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":102422,"bin/5rot26.lua":1661,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/factor.lua":4263,"bin/grep.lua":1196,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6584,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"bin/workspace.lua":42971,"potatobios.lua":41955,"signing-key.tbl":190,"startup":8438,"stdlib.hvl":851,"xlib/00_cbor.lua":15831,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1699616219}
{"hash":"91767804cfb486843313acb3947949e34dbcdda8c231b3662c28c915ca4e24c3"}

View File

@ -1850,23 +1850,38 @@ function potatOS.send(m)
end
do
if not potatOS.registry.get "potatOS.disable_window" then
local w, h = term.native().getSize()
local win = window.create(term.native(), 1, 1, w, h)
term.redirect(win)
potatOS.screen = win
potatOS.framebuffers = {}
potatOS.framebuffers_inv = {}
if not potatOS.registry.get "potatOS.disable_framebuffers" then
local raw_redirect = term.redirect
function term.redirect(target)
local buffer = potatOS.framebuffers[target]
if not buffer then
local w, h = target.getSize()
buffer = window.create(target, 1, 1, w, h)
potatOS.framebuffers[target] = buffer
potatOS.framebuffers_inv[buffer] = target
end
raw_redirect(buffer)
end
local raw_current = term.current
function term.current()
return potatOS.framebuffers_inv[raw_current()]
end
term.redirect(term.native())
else
term.redirect(term.native())
end
end
function potatOS.read_display(end_y, end_x)
function potatOS.read_framebuffer(end_y, end_x, target)
local buffer = potatOS.framebuffers[target or term.current()]
if not end_x and not end_y then
end_x, end_y = potatOS.screen.getCursorPos()
end_x, end_y = buffer.getCursorPos()
end
local out = {}
for line = 1, end_y do
local text, fg, bg = potatOS.screen.getLine(line)
local text, fg, bg = buffer.getLine(line)
if end_y == line then
text = text:sub(1, end_x)
end