dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.55k stars 112 forks source link

picture-in-a-picture by becoming a pseudoterminal #487

Open dankamongmen opened 4 years ago

dankamongmen commented 4 years ago

Walking around the streets of plague, I had an inspiration. Rather than trying to munge a TUI subprocess down via LINES/COLUMNS or anything like that, which was never really going to fly, we can do this properly by providing pseudoterminal functionality. We'd launch the process with its stdout/stderr/stdin connected to a terminal, valid under istty(), but that terminal would be us. We'd export a locked-down terminal the size of the desired rendering area, with the capabilities we wish to support, and it would work perfectly.

BOOM.

Hell, at that point we basically can become screen/tmux.

Very exciting.

dankamongmen commented 3 years ago

This would be necessary for #381.

I have reached out to the NCURSES list. They're full of wisdom, when not too grumpy. Let's see if we hear back anything interesting. https://lists.gnu.org/archive/html/bug-ncurses/2020-11/msg00007.html

ghost commented 3 years ago

Are you looking for a terminal widget that behaves like "TERM=xterm" ? There is vte (current git head has sixel support), but I think that requires GTK. Here is one in C++ that relies on the Ultimate-C++ (U++) framework that also supports sixel: https://github.com/ismail-yilmaz/upp-components/tree/master/CtrlLib/Terminal . If you were interested in the latter I would be very unsurprised if İsmail helped in isolating it from U++ for other uses.

dankamongmen commented 3 years ago

Are you looking for a terminal widget that behaves like "TERM=xterm" ? There is vte (current git head has sixel support), but I think that requires GTK. Here is one in C++ that relies on the Ultimate-C++ (U++) framework that also supports sixel: https://github.com/ismail-yilmaz/upp-components/tree/master/CtrlLib/Terminal . If you were interested in the latter I would be very unsurprised if İsmail helped in isolating it from U++ for other uses.

Bryan Christ pointed me at this: https://github.com/TragicWarrior/libvterm. I think it would fit into our current idiom better. upp looks interesting!

joseluis commented 3 years ago

@dankamongmen I'm personally very interested in this feature and I'd like to discuss how much work would be necessary, and how hard would be to make this a reality? Is there any chance to add this to the 3.0 milestone?

As a tmux user/addict I'm sad about its lack of sixel support, which according to some info I read it's deeply ingrained in its design and wont probably ever change. And I don't want to wait years hoping for a viable alternative to come up.

So I would very much like to attempt creating a simple terminal multiplexer with notcurses, that allows me to manage multiple sessions, windows and panels with pixel support...

What are the missing pieces?

dankamongmen commented 3 years ago

@dankamongmen I'm personally very interested in this feature and I'd like to discuss how much work would be necessary, and how hard would be to make this a reality? Is there any chance to add this to the 3.0 milestone?

As a tmux user/addict I'm sad about its lack of sixel support, which according to some info I read it's deeply ingrained in its design and wont probably ever change. And I don't want to wait years hoping for a viable alternative to come up.

So I would very much like to attempt creating a simple terminal multiplexer with notcurses, that allows me to manage multiple sessions, windows and panels with pixel support...

What are the missing pieces?

well, there's the argument that multiplexing really belongs in the terminal itself, which i kinda subscribe to. that's why i closed up #1332 . this is more about processing a stream including escapes, and directly rendering it. we have ncfd_subprocess to soak up subprocess data, but if it includes escapes, we don't do anything with those.

as for how much effort....i don't know! there's the U++ tool @klamonte mentions above, and also libvterm. do i need some vterm terminfo database for the latter? i'm unsure; i've never really looked into this.

i don't see it happening in 3.0 unless

there's just so much crap scheduled for 3.0 already, and i want to have it out this summer.

joseluis commented 3 years ago

Thank you for the quick response... that helps framing the situation.

this is more about processing a stream including escapes, and directly rendering it.

If I wanted to to that part in Rust, (e.g. by forking vt100 to add support for the vt340 escape codes), am I right to assume that only missing part in notcurses would be to offer an API point in order to receive all the subprocess data so that I could then render it myself?

dankamongmen commented 3 years ago

https://notcurses.com/notcurses_fds.3.html ...although you don't want to render directly to a plane. so you just kinda want popen(3) heh, unless i'm missing something.

joseluis commented 3 years ago

Wow, I've realize I never used that before... In fact, I didn't even include it in the bindings. I'll have to remedy it.

Then I think I'll port the procroller. and fileroller.c pocs before attempting anything more ambitious....

dankamongmen commented 3 years ago

@tomek-szczesny , not sure if you've seen this issue, but it seems relevant

tomek-szczesny commented 3 years ago

Thanks for pointing it out for me. Well that explains why @joseluis lurks my repo :d

For me, equally exciting is a fact that @joseluis is tempted to write ntmux (not tmux), and I'm eager to write ncssh (not cssh). Two perfect examples of potential use and ultimate tests of new capabilities.

So, what do we take out from this, given all new information we generated in the meantime? I see the grumpy ncurses people told you to use libvterm and dropped the mic. The tty witchcraft will definitely be left to you. What are the other pieces?

(still waiting for your respone here, @dankamongmen )

ghost commented 3 years ago

Some additional references: