by kragen · 3y ago · 0 comments
excerpt from my comments yesterday at https://news.ycombinator.com/item?id=35940188:
> some technologies, like the unix shell, smalltalk, and tcp/ip, make hard things easy and easy things possible. others, like retrocomputing, code golf, and malbolge, make easy things hard and hard things impossible. sixel makes easy things hard and hard things impossible, ....
> that's a fun way to spend my time when i choose to (e.g., in https://asciinema.org/a/390271 i did real-time 3d graphics in a unicode terminal emulator with braille) but it's not how i want my primary user interface to my computer to work ...
> sixel is oulipo programming; encoding your graphics in sixel is like writing a novel without the letter 'e'. btw, a wonderful article about oulipo programming is https://100r.co/site/working_offgrid_efficiently.html
> sixel is an art project, not an engineering project
You can do all kinds of things to make something better, but the two things that matters for this usecase is being able to do it over ssh and wide enough support that you can start relying on it. Better performance or more features only matters if both of those are met.
i think the problem here is that x11 is shitty at 'inline' (things tend to open annoying new windows) and a modern terminal cosplaying a vt100 is shitty at graphics
sixel doesn't solve that problem; your terminal emulator is still shitty at graphics
Just something that's marginally better than emulating bitmaps with unicode characters is sufficient, as long as it's inline and simple to output.
(you do have to worry about bugs in yeso, of which there are several)
if you don't like c, in cpython it's four lines of code with yeso
from yeso import *
w = Window('hello, world', (406, 220))
w.frame().copy(read_png('admu_shell.png'))
while True: w.wait()
this requires a little bit of tweaking to work in pypyalso it works on the linux framebuffer as well as in x-windows
not being inline is a harder problem to solve
Is there a better alternative for pixel graphics in the terminal? If yes I'm all ears. The way Sixels encodes pixel data sucks, but currently it seems to be the only way to render pixels in the terminal (and that's implemented in more than one terminal application).
but i've used graphical terminals like ncd x terminals since 01994, and they provided smooth graphical interactions even over shared 10-megabit ethernet. current xorg and xwayland do a great job of emulating those terminals, with most of their deficiencies fixed, and ssh has built-in support for transparently passing along the needed credentials
xpra works even better, supporting h.264 compression and reattaching to applications you've detached from
the big problem with x11 is that trying to write a program to do something simple like display an image or draw a bar graph ensnares you in five pages of bureaucracy
to solve that problem i wrote yeso: https://gitlab.com/kragen/bubbleos/blob/master/yeso
here's a program to display a png with yeso:
#include <yeso.h>
int main(int argc, char **argv)
{
ypic img = yp_read_png(argv[1]);
if (!img.p) return 1;
ywin w = yw_open(argv[1], img.size, "");
yp_copy(yw_frame(w), img);
yw_flip(w);
for (;;) yw_wait(w, 0);
}
it also runs on the linux framebuffer without x-windowshere's a color generalization of munching squares in yeso in python:
import yeso
def munch(t, fb):
for y, p in enumerate(fb):
for x in range(fb.size.x):
p[x] = (t & 1023) - ((x ^ y) & 1023)
if __name__ == '__main__':
with yeso.Window(u"CPython μunching", (256, 128)) as w:
t = 0
while True:
with w.frame() as fb:
munch(t, fb)
t += 1
it uses python context managers so you don't forget to yw_flip()there's also a luajit binding
the example programs above are non-interactive, like virtually everything sixel that isn't full-screen; here's a lua program to test mouse interaction:
local yeso = require 'yeso'
function bounds(a, b)
if a < b then return a, b else return b, a end
end
yeso.Window("mΩuso", {256, 256}):run(function (w)
local m, dragStart = {x=128, y=128}
while true do
for ev in w:events() do
if ev.isMouse then
m = ev.p
if ev:button(1) and dragStart == nil then
dragStart = {x=ev.p.x, y=ev.p.y}
elseif not ev:button(1) then
dragStart = nil
end
end
end
w:frame(function (f)
f:fill(0x7f7f7f)
if dragStart then
local minX, maxX = bounds(dragStart.x, m.x)
local minY, maxY = bounds(dragStart.y, m.y)
f:sub({minX, minY}, {maxX-minX, maxY-minY}):fill(0x336699)
end
end)
w:wait()
end
end)
as for embedding interactive graphics in a text stream, i'm still trying to figure out the bubbleos solution to that. but i'll get there, and the result will be usable over ssh, while sixel probably hasn't gotten there even for low-bandwidth interactive localhost cases and probably never willThe problem is that with the predominance of toolkits like GTK & Qt in the *nix application space, which pre-rasterize everything for easier cross-platform compatibility, X forwarding is nowhere near as efficient as it once was. Under present circumstances, the h.264 route is probably as good as it gets.
Also, I'm curious what you think of Arcan (https://arcan-fe.com)
was it you that linked me to arcan the other day? i've been studying it. i think it's interesting
i think you could probably get pretty far by creating a new x11 socket with fresh xauth for each new program launched; then, instead of opening new floating overlapping windows for them, embedding the display of whatever windows they create in your notebook, just below below the command that created them
a bytestream protocol has some real advantages, including being able to forward it over a network socket, including an ssh-forwarded socket, or providing a gui for whatever little embedded electronic gadget you build and connect to your terminal over spi or usb serial
i had previously rejected it as too inefficient for the localhost use case, but in https://news.ycombinator.com/item?id=35693474, and some later protocol-design ideas i haven't shared yet, i convinced myself that you can probably make it efficient enough for anything that doesn't use custom shaders
is this something you'd be interested in talking about in a less hostile environment
unless you ran across the pobox address, which has been dead for... a while
the canonical.org address is the correct one
comment if you've emailed me and not gotten a response