29 Commits

Author SHA1 Message Date
Mitchell Hashimoto
ae987c68e0 terminfo: reset kbs back to ^?, clear high bit for encoding 2024-04-21 10:07:53 -07:00
Mitchell Hashimoto
631ac651ab terminfo: for XTGETTCAP, non-parameterized string values return encoded
Fixes #1699

See #1699 for a lot more research. I haven't found a definitive source
of this behavior but this appears to match most of the mainstream
terminals and xterm for the realistic terminfo entries we have and
I'm going to consider that good enough.

For non-parameterized string values in a terminfo, the XTGETTCAP result
should be the tcap encoded form. This means replacing characters such as
`\E` with their byte form of 0x1B, and control characters such as `^H`
with their actual character 0x08, and so on.

"Non-parameterized" is a bit weird, the comment in this commit explains
my best guess (thanks to some community help) of why this may be.

This commit does NOT handle all encodings, but it handles the encodings
we use and the encodings I could cross-check with other terminals. The
actual tcap encoding is much more complicated and I'm sure for specific
types of terminfo values our encoding is not correct. If and when those
come up we should fix them.
2024-04-20 20:34:49 -07:00
Tim Culverhouse
534f97dff0 terminfo: remove completed todo
OSC4 has been implemented. Remove this todo
2024-02-21 20:21:59 -06:00
Tim Culverhouse
416950a447 terminfo: fix xr and rv
Commit 5e473ebd ("terminfo: add additional entries, fix smkx/rmkx")
added entries `xr` and `rv`, but without proper escaping of the
backslashes. This commit adds the extras. Output of `infocmp` now
matches foot, kitty, et al.
2023-12-21 13:36:00 -06:00
Gregory Anders
1aef1f0049 terminfo: add entries for focus reporting
These sequences have been used "informally" forever, and until recently
mode 1004 was included in Xterm's XM (enable mouse reporting) sequence.
But as of ncurses 6.4 patch 20231028, focus reporting mode is removed
from XM and added to new fe and fd capabilities. Xterm also includes
definitions for the actual focus events ("kxIN" and "kxOUT"), so include
those too.
2023-11-08 15:05:34 -06:00
Gregory Anders
f58478822c terminfo: fixup Sync terminfo string
The closing string on a conditional is "%;", not "%".
2023-11-06 13:48:01 -06:00
Gregory Anders
ffaf1f6a6f terminfo: add missing % character after conditional
Not sure this is _strictly_ necessary, but according to terminfo(5) a
conditional (`%?`) should have a closing `%` character after the "else"
part. Adding it just in case some parser somewhere depends on this.
2023-11-03 08:53:36 -07:00
Mitchell Hashimoto
155cd099ba terminfo: add E3 for clear scrollback
`clear(1)` uses this to clear scrollback unless supressed with `-x`.
2023-10-29 12:52:33 -07:00
Gregory Anders
3d898bf30d terminfo: remove focus reporting mode from XM entry (#748)
The XM entry enables mouse reporting events to applications. An
application that supports mouse events may not necessarily support focus
events, so these should not be bundled together.

Vim includes focus reporting mode (1004) in their example XM entry in
their docs [1], but they do not actually use it in the default value XM
value [2].

Ncurses also includes only modes 1000 and (optionally) mode 1006 in
their mouse driver [3]. The ncurses documentation for XM similarly does
not mention focus reporting (mode 1004) anywhere [4].

Including focus reporting causes bugs in some programs that want to use
mouse mode but do not handle focus events (e.g. `htop`).

[1]: https://vimhelp.org/term.txt.html#xterm-terminfo-entries
[2]: 87ca5e86fa/src/term.c (L477)
[3]: 87c2c84cbd/doc/html/man/curs_mouse.3x.html (L339)
[4]: https://www.man7.org/linux/man-pages/man5/user_caps.5.html
2023-10-27 17:40:41 -07:00
Mitchell Hashimoto
0d2bfacd5b terminfo: add left/right margin entries 2023-10-10 15:59:24 -07:00
Tim Culverhouse
d0c673cdfc terminfo: use 'xterm-ghostty' as primary name
Use "xterm-ghostty" as the primary terminfo name. This is a hack on a
hack...we use "xterm-ghostty" to prevent vim from breaking, and when we
do this as the default we break tcell-based applications (lazygit, aerc,
etc). tcell has a bug where the primary terminfo name must be the
value of TERM. https://github.com/gdamore/tcell/pull/639 fixes the issue
but is not merged yet.

Fixes: 779186ad ("config: add term config option")
2023-09-28 10:00:37 -05:00
Tim Culverhouse
5e473ebdb0 terminfo: add additional entries, fix smkx/rmkx
Add entries for secondary device attributes, XTVERSION.
2023-09-28 06:57:00 -05:00
Mitchell Hashimoto
0529c8bc28 terminfo: increase buffer size for test 2023-09-27 21:56:55 -07:00
Tim Culverhouse
25710dfa6d terminfo: add mouse entries, correct kmouse
Add entries for XM and xm, these tell certain applications how to enable
mouse and the format of response they will receive.

Fix 'kmous' entry to match standard terminfo files.
2023-09-27 21:42:13 -05:00
Tim Culverhouse
fe0b93389e terminfo: add bracketed paste entries BD, BE, PS, PE
Add terminal entries for bracketed paste mode and start/end signals
2023-09-27 09:20:13 -05:00
Mitchell Hashimoto
767a78020a terminfo: add a few more missing entries from tmux(1) 2023-09-26 22:08:52 -07:00
Mitchell Hashimoto
ece4ddac81 terminfo: OSC 52 support 2023-09-26 21:56:22 -07:00
Tim Culverhouse
c77f0dc6fc terminfo: add cursor styles to terminfo
Add Ss and Se definitions
2023-09-26 12:53:41 -05:00
Tim Culverhouse
da6dfbbf3d terminfo: add Setulc string for colored underlines
Add terminfo key 'Setulc' to enable colored underlines.
2023-09-25 15:54:03 -05:00
Tim Culverhouse
e70e763e8c terminfo: add Smulx (underline styles) entry
Add a terminfo entry for Smulx, which advertises support for curly,
dashed, dotted, etc underlines

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2023-09-21 16:47:10 -05:00
Mitchell Hashimoto
f60066a64d terminfo: add fullkbd for kitty keyboard protocol 2023-08-16 17:31:05 -07:00
Mitchell Hashimoto
60d4024d64 terminal: reset CSI param separator in parser on clear 2023-06-24 15:16:54 -07:00
Mitchell Hashimoto
97df179b04 terminfo: switch to semicolon SGR 48 to prevent render issues 2023-06-24 15:04:33 -07:00
Mitchell Hashimoto
7092078585 terminfo: fix 0 => O 2023-06-24 14:43:11 -07:00
Mitchell Hashimoto
7e51dbb7e5 build: fix race conditions, use actual filesource 2023-06-24 14:24:58 -07:00
Mitchell Hashimoto
3ae2a3e1fa ghostty encoding test needs more buffer 2023-06-24 11:11:08 -07:00
Mitchell Hashimoto
629fddcf5f terminfo: more capabilties, I think this is all of them 2023-06-24 11:04:02 -07:00
Mitchell Hashimoto
0f43e79bda terminfo: a bunch more capabilities 2023-06-24 10:29:19 -07:00
Mitchell Hashimoto
ea67b4aa48 terminfo: working on Ghostty's terminfo 2023-06-24 08:59:05 -07:00