dnkl/foot
41
2.0k
Fork
You've already forked foot
243

XTGETTCAP #875

Manually merged
dnkl merged 10 commits from xtgettcap into master 2022年01月14日 13:49:36 +01:00
Owner
Copy link

Summary

foot now has its entire terminfo builtin, and will respond to XTGETTCAP queries for all capabilities, including the XTGETTCAP specific TN, Co and RGB ones.

For reference, XTerm only sends replies for keyboard escapes (i.e. k* capabilities). Kitty sends replies for everything (as far as I can tell), except for boolean capabilities.

Details

We emit one DCS reply for each queried capability (like Kitty, but unlike XTerm), as this allows us to a) not skip any capabilities in the query, and b) reply with correct success/fail flag for each capability.

Similar to Kitty (but again, unlike XTerm), we support quering all terminfo capabilities. In unparameterized capabilities, \E is "expanded" to a literal ESC, while in parameterized capabilities, \E is kept as-is (this is identical to Kitty's behavior).

We do not batch the entire reply - as soon as the reply for one capability is done, we write it to the PTY.

(削除) In this iteration, boolean capabilities are not supported. Not even Kitty supports this. (削除ここまで)

We now reply with DCS 1 + r <capability> ST for boolean capabilities. That is, a normal "success" reply, minus the = <value> part. Note that foot is the only terminal emulator I'm aware of that does this. Kitty does not respond with any boolean capabilities.

Closes #846

https://codeberg.org/attachments/f4834e44-9967-4816-96e8-20c473630504
Image shows a mix of boolean, integer and string capabilities being queried, as well as one invalid capability.

Size

~(削除) This adds 20K to the final binary size. In the variant currently used here (const char * for each capability/value pair), each capability uses 16 bytes (two 8-byte pointers), plus the size of the actual strings. However, this results in lots of relocations, which increases the binary size further. (削除ここまで)

~(削除) If we instead use a table with fixed-sized char arrays (allowing for the longest capability names/values), then we lose the relocations, but the table itself becomes 20K. (削除ここまで)

The internal representation has been changed, from a table, to a single NULL-separated char array. This drops all extra pointers, and all extra relocations. The array itself is ~3.3K - much better than the 20K we saw before.

# Summary foot now has its entire terminfo builtin, and will respond to `XTGETTCAP` queries for **all** capabilities, including the `XTGETTCAP` specific `TN`, `Co` and `RGB` ones. For reference, XTerm only sends replies for keyboard escapes (i.e. `k*` capabilities). Kitty sends replies for everything (as far as I can tell), except for boolean capabilities. # Details We emit one DCS reply for each queried capability (like Kitty, but unlike XTerm), as this allows us to **a)** not skip any capabilities in the query, and **b)** reply with correct success/fail flag for each capability. Similar to Kitty (but again, unlike XTerm), we support quering **all** terminfo capabilities. In unparameterized capabilities, `\E` is "expanded" to a literal ESC, while in parameterized capabilities, `\E` is kept as-is (this is identical to Kitty's behavior). We do not batch the entire reply - as soon as the reply for _one_ capability is done, we write it to the PTY. ~~In this iteration, boolean capabilities are not supported. Not even Kitty supports this.~~ We now reply with `DCS 1 + r <capability> ST` for boolean capabilities. That is, a normal "success" reply, minus the `= <value>` part. Note that foot is the only terminal emulator I'm aware of that does this. Kitty does not respond with any boolean capabilities. Closes #846 ![https://codeberg.org/attachments/f4834e44-9967-4816-96e8-20c473630504](https://codeberg.org/attachments/f4834e44-9967-4816-96e8-20c473630504) Image shows a mix of boolean, integer and string capabilities being queried, as well as one invalid capability. # Size ~~This adds ~20K to the final binary size. In the variant currently used here (`const char *` for each capability/value pair), each capability uses 16 bytes (two 8-byte pointers), plus the size of the actual strings. However, this results in lots of relocations, which increases the binary size further.~~ ~~If we instead use a table with fixed-sized char arrays (allowing for the longest capability names/values), then we lose the relocations, but the table itself becomes ~20K.~~ The internal representation has been changed, from a table, to a single NULL-separated char array. This drops all extra pointers, and all extra relocations. The array itself is ~3.3K - much better than the 20K we saw before.
Author
Owner
Copy link

@dankamongmen I know you already use XTGETTCAP with the TN and RGB capabilities (which foot currently does not implement at all), but was wondering if the extended XTGETTCAP functionality implemented in this PR would be of interrest to you?

I find XTerm's XTGETTCAP is of limited use, but I also see no point in implementing anything more advanced, if no one's going to use it...

@dankamongmen I know you already use `XTGETTCAP` with the `TN` and `RGB` capabilities (which foot currently does not implement at all), but was wondering if the extended `XTGETTCAP` functionality implemented in this PR would be of interrest to you? I find XTerm's `XTGETTCAP` is of limited use, but I also see no point in implementing anything more advanced, if no one's going to use it...
Contributor
Copy link

i have https://github.com/dankamongmen/notcurses/issues/2144 open. ideally, i'd stop using terminfo and get all properties from the terminal itself. i don't see myself moving to mass XTGETTCAP anytime soon, due to a noted miserly nature regarding bytes, but the first person who implements a more reasonable XTGETTCAP (i'd like to see the ability to query multiple entries or all entries, and a less grotesque encoding) will see me adopt it immediately, and also know they will no longer have TERM/terminfo-related issues with Notcurses.

i have https://github.com/dankamongmen/notcurses/issues/2144 open. ideally, i'd stop using terminfo and get all properties from the terminal itself. i don't see myself moving to mass XTGETTCAP anytime soon, due to a noted miserly nature regarding bytes, but the first person who implements a more reasonable XTGETTCAP (i'd like to see the ability to query multiple entries or all entries, and a less grotesque encoding) will see me adopt it immediately, and also know they will no longer have TERM/terminfo-related issues with Notcurses.
Contributor
Copy link

oh hey, it looks like you can already query multiple entities in a single XTGETTCAP, and indeed that i am doing this:

// XTGETTCAP['TN', 'RGB'] (Terminal Name, RGB) 
#define XTGETTCAP "\x1bP+q544e;524742\x1b\\" 
oh hey, it looks like you can already query multiple entities in a single XTGETTCAP, and indeed that i am doing this: ```c // XTGETTCAP['TN', 'RGB'] (Terminal Name, RGB) #define XTGETTCAP "\x1bP+q544e;524742\x1b\\" ```
Author
Owner
Copy link

but the first person who implements a more reasonable XTGETTCAP (i'd like to see the ability to query multiple entries or all entries, and a less grotesque encoding) will see me adopt it immediately, and also know they will no longer have TERM/terminfo-related issues with Notcurses.

This PR does allow you to query all entries, at once. The query will of course be rather big, since there's no keyword for "give me everything".

And for compatibility reasons, I haven't really changed the encoding, besides adopting Kitty's behavior of sending one DCS response per capability.

But if we're going to be changing a lot, it's probably better to use a new sequence all together, rather than pretending to be implementing XTGETTCAP.

> but the first person who implements a more reasonable XTGETTCAP (i'd like to see the ability to query multiple entries or all entries, and a less grotesque encoding) will see me adopt it immediately, and also know they will no longer have TERM/terminfo-related issues with Notcurses. This PR does allow you to query all entries, at once. The query will of course be rather big, since there's no keyword for "give me everything". And for compatibility reasons, I haven't really changed the encoding, besides adopting Kitty's behavior of sending one DCS response per capability. But if we're going to be changing a lot, it's probably better to use a new sequence all together, rather than pretending to be implementing XTGETTCAP.
Contributor
Copy link

But if we're going to be changing a lot, it's probably better to use a new sequence all together, rather than pretending to be implementing XTGETTCAP.

agreed.

interestingly(?), as we've had this discussion, i've expanded my use of XTGETTCAP to include "hpa" because of some snafu regarding kitty's terminfo on freebsd that i don't care to investigate.

> But if we're going to be changing a lot, it's probably better to use a new sequence all together, rather than pretending to be implementing XTGETTCAP. agreed. interestingly(?), as we've had this discussion, i've expanded my use of XTGETTCAP to include "hpa" because of some snafu regarding kitty's terminfo on freebsd that i don't care to investigate.
Author
Owner
Copy link

I guess my question then is: is the current form of XTGETTCAP "good enough" for querying all capabilities?

My gut feeling is that the bulkiness of the protocol isn't going to be a problem (besides maybe being ugly...) since the terminfo is fairly small.

Or should we invest time in a new sequence?

I guess my question then is: is the current form of XTGETTCAP "good enough" for querying all capabilities? My gut feeling is that the bulkiness of the protocol isn't going to be a problem (besides maybe being ugly...) since the terminfo is fairly small. Or should we invest time in a new sequence?
Contributor
Copy link

i mean, i'm definitely being silly bitching about the encoding (though on even a 9600bps connection, it would be noticeable).

i mean, i'm definitely being silly bitching about the encoding (though on even a 9600bps connection, it would be noticeable).
Contributor
Copy link

XTerm only sends replies for keyboard escapes

is this true? maybe i have some configuration element set, but i'm pretty sure i get RGB from it; that was what motivated my initial use of XTGETTCAP, since i very much want 24-bit color if it's available.

> XTerm only sends replies for keyboard escapes is this true? maybe i have some configuration element set, but i'm pretty sure i get RGB from it; that was what motivated my initial use of XTGETTCAP, since i very much want 24-bit color if it's available.
Contributor
Copy link

XTerm only sends replies for keyboard escapes

is this true? maybe i have some configuration element set, but i'm pretty sure i get RGB from it; that was what motivated my initial use of XTGETTCAP, since i very much want 24-bit color if it's available.

from my XTerm:

tcap_cb:1486:xtgettcap [544e=787465726D2D323536636F6C6F72;524742=38]
tcap_cb:1523:got rgb (524742=38)

> > XTerm only sends replies for keyboard escapes > > is this true? maybe i have some configuration element set, but i'm pretty sure i get RGB from it; that was what motivated my initial use of XTGETTCAP, since i very much want 24-bit color if it's available. from my XTerm: tcap_cb:1486:xtgettcap [544e=787465726D2D323536636F6C6F72;524742=38] tcap_cb:1523:got rgb (524742=38)
Author
Owner
Copy link

Yes. XTGETTCAP defines three "special" capabilities: TN, RGB and Co.

Co is just an alias for colors.

RGB's semantic however, differs from a normal terminfo. In terminfo, RGB is a boolean, while in XTGETTCAP it's an integer that specifies the number of bits per channel (i.e 8).

Beyond those, XTerm only responds to key capability queries.

Yes. XTGETTCAP defines three "special" capabilities: TN, RGB and Co. Co is just an alias for `colors`. RGB's semantic however, differs from a normal terminfo. In terminfo, RGB is a boolean, while in XTGETTCAP it's an integer that specifies the number of bits per channel (i.e 8). Beyond those, XTerm only responds to key capability queries.
Author
Owner
Copy link

Alright, I just might proceed, and merge this. Just going to sleep on it. Maybe more than one night...

Alright, I just might proceed, and merge this. Just going to sleep on it. Maybe more than one night...
dnkl force-pushed xtgettcap from 060076b223
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 18fa977c26
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年01月13日 11:25:51 +01:00
Compare
dnkl force-pushed xtgettcap from 18fa977c26
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 5a032c4c6f
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年01月13日 13:42:15 +01:00
Compare
Author
Owner
Copy link

The internal representation has been changed, from a table, to a single NULL-separated char array. This drops all extra pointers, and all extra relocations. The array itself is ~3.3K - much better than the 20K we saw before.

The internal representation has been changed, from a table, to a single NULL-separated char array. This drops all extra pointers, and all extra relocations. The array itself is ~3.3K - much better than the 20K we saw before.
dnkl force-pushed xtgettcap from 007fd24e72
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline failed
to d1796dc1c9
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline failed
2022年01月14日 13:41:21 +01:00
Compare
dnkl force-pushed xtgettcap from d1796dc1c9
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline failed
to 49a8c7fc76
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2022年01月14日 13:45:29 +01:00
Compare
dnkl manually merged commit 2d3d8ca3d0 into master 2022年01月14日 13:49:36 +01:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot!875
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "xtgettcap"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?