dankamongmen / notcurses

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

explore a general scheme for acquiring terminfo data from the terminal directly #2144

Open dankamongmen opened 3 years ago

dankamongmen commented 3 years ago

XTerm supports XTGETTCAP to request terminfo data. Experiment with it and other terminals to see whether or not critical terminfo escapes can be generally acquired. If so, we could eliminate our dependence on a correct TERM. Indeed, we could eliminate our dependency on the terminfo library entirely, and be guaranteed up-to-date information.

WSLUser commented 3 years ago

Would the DECRQSS settings query also possibly work instead? Better to support DEC over XT sequences when possible.

dankamongmen commented 3 years ago

Would the DECRQSS settings query also possibly work instead? Better to support DEC over XT sequences when possible.

unfortunately no. i need terminfo strings (e.g. "what do i write to make things bold"?). decrqss is a different set of capabilities: https://vt100.net/docs/vt510-rm/DECRQSS.html

WSLUser commented 3 years ago

Was just a thought. I assumed settings query to mean what you can do with the terminal, which it does but in a different way than I realized.

kovidgoyal commented 3 years ago

Note that kitty supports XTGETTCAP and I am a big fan of using it if you are anyway doing query roundtripping. Indeed kitty extends XTGETTCAP to allow you to query things not covered by terminfo (which is completely ossified anyway). https://sw.kovidgoyal.net/kitty/kittens/query_terminal/

dankamongmen commented 3 years ago

yep, kitty would work very well with this scheme.

dankamongmen commented 3 years ago

so a few things to think about:

right now setupterm() is called before we start the input engine (and begin parsing potential replies). i'd like that to be in parallel, but we need to know the escape sequences covered by terminfo before starting the input engine, so i'm not sure whether that's ever possible. it doesn't seem so =/.

kovidgoyal commented 3 years ago

Do you actually need a 100 different things? I suggest you do a bit of differential analysis on the common terminals you support to see what they actually differ on (which is very few things these days). You will likely get a set of dozen or so. If TERM is any of those terminals use a smaller query, on other less common/esoteric/legacy terminals, use a larger query.

In other words I am suggesting you craft the query based on an internal database of TERM values.

dankamongmen commented 3 years ago

Do you actually need a 100 different things? I suggest you do a bit of differential analysis on the common terminals you support to see what they actually differ on (which is very few things these days). You will likely get a set of dozen or so. If TERM is any of those terminals use a smaller query, on other less common/esoteric/legacy terminals, use a larger query.

yep, that's about what i'm planning.

In other words I am suggesting you craft the query based on an internal database of TERM values.

hrmmm so a dynamic query. interesting. the thing i don't like about this is that one of the major points is to eliminate problems, where possible, caused by an incorrect TERM.

i think further analysis requires a quantitative differential analysis of the existing terminfo database.

kovidgoyal commented 3 years ago

On Mon, Oct 18, 2021 at 10:27:34AM -0700, nick black wrote:

Do you actually need a 100 different things? I suggest you do a bit of differential analysis on the common terminals you support to see what they actually differ on (which is very few things these days). You will likely get a set of dozen or so. If TERM is any of those terminals use a smaller query, on other less common/esoteric/legacy terminals, use a larger query.

yep, that's about what i'm planning.

In other words I am suggesting you craft the query based on an internal database of TERM values.

hrmmm so a dynamic query. interesting. the thing i don't like about this is that one of the major points is to eliminate problems, where possible, caused by an incorrect TERM.

Well, you can still largely do that, since one of the queries you can make is for the term name, and if the user has set a different TERM you can then do a second round if needed. This will penalize users who set incorrect TERM values a little, but hopefully that hack will become rarer with time.

i think further analysis requires a quantitative differential analysis of the existing terminfo database.

Indeed.

dankamongmen commented 3 years ago

also hpa, which is of critical importance, and which seems to be missing from the Kitty FreeBSD termcap

dankamongmen commented 2 years ago

this could resolve #2541 for good and immediately, and hpa is certainly important to us.

dankamongmen commented 2 years ago

tcap_cb() could really stand some cleanup (and unit testing).