Commit graph

315 commits

Author SHA1 Message Date
Daniel Eklöf
48cf57818d
term: performance: use a bitfield to track which ascii printer to use
The things affecting which ASCII printer we use have grown...

Instead of checking everything inside term_update_ascii_printer(), use
a bitfield.

Anything affecting the printer used, must now set a bit in this
bitfield. This makes term_update_ascii_printer() much faster, since
all it needs to do is check if the bitfield is zero or not.
2024-06-26 18:39:24 +02:00
Daniel Eklöf
a45ccfaed0
csi: remove debug log 2024-06-26 18:39:23 +02:00
Daniel Eklöf
32effc6657
csi: wip: styled underlines
This is work in progress, and fairly untested.

This adds initial tracking of styled underlines. Setting attributes
seems to work (both color and underline style). Grid reflow has *not*
been tested.

When rendering, style is currently ignored (all styles are rendered as
a plain, legacy underline).

Color however, *is* applied.
2024-06-26 18:39:23 +02:00
Daniel Eklöf
8716ca5784
url-mode: disable IME mode while URL-mode is active
This prevents the IME from stealing "our" key-presses, and thus
preventing the user from opening URLs.

Closes #1718, hopefully.
2024-05-21 08:37:39 +02:00
Daniel Eklöf
c4f1380943
config: add cursor.blink-rate option
The default is 500ms, which corresponds to the old, hardcoded default.

Closes #1707
2024-05-20 09:17:42 +02:00
Craig Barnes
27330a5dd6
csi: indicate "permanently reset" for DECRQM queries of mode 67 (DECBKM)
This allows dynamic querying for the equivalent of terminfo's "kbs"
capability.
2024-03-16 15:36:00 +01:00
Daniel Eklöf
712bc95db3
csi: the CSI-t family of queries now report unscaled pixel values
Before this patch, we reported scaled pixel values. This was rather
useless, since applications have no way of getting the scaling factor,
to "scale up" e.g. images.

Furthermore, the most common use of these queries are probably to
calculate the dimensions to use when emitting sixels.

Closes #1643
2024-03-14 07:26:37 +01:00
Daniel Eklöf
e2b3eb91dd
csi: params_to_rectangular_area(): ensure left/right is within bounds 2024-03-10 17:37:11 +01:00
Daniel Eklöf
6a01642a6f
csi: DECCARA+DECRARA: dirty cells 2024-03-07 16:25:04 +01:00
Daniel Eklöf
d6c5bc3262
csi: DECRARA: fix comment: DECCARA -> DECRARA 2024-03-07 16:24:33 +01:00
Daniel Eklöf
f5c574cd94
csi: DECCRA: no need for a counter here 2024-03-07 16:24:33 +01:00
Daniel Eklöf
23908d9277
term_fill(): change ‘character’ parameter from char -> uint8_t 2024-03-07 16:24:33 +01:00
Daniel Eklöf
b3a84ba71b
term: modify term_fill() to optionally reset the SGR attributes 2024-03-07 16:24:33 +01:00
Daniel Eklöf
189cfd717f
term: replace term_put_char() with term_fill() 2024-03-07 16:24:33 +01:00
Daniel Eklöf
1b66c6a3ac
csi: rectangular: add helper function params_to_rectangular_area()
This functions reads the four top/left/bottom/right parameters,
validates them, and converts relative row numbers to absolute.

Returns true if the params are valid, otherwise false.
2024-03-07 16:24:33 +01:00
Daniel Eklöf
95293f142a
csi: add ‘28’ (rectangular edit) to primary DA response 2024-03-07 16:24:33 +01:00
Daniel Eklöf
926d88fd30
csi: implement rectangular edit escapes
* DECCARA - change attributes in rectangular area
* DECRARA - reverse attributes in rectangular area
* DECCRA - copy rectangular area
* DECFRA - fill rectangular area
* DECERA - erase rectangular area

Not implemented:

* DECSERA - selective erase rectangular area
2024-03-07 16:24:33 +01:00
Craig Barnes
fa01bf2b75 csi: support DECRQM queries for ECMA-48 (SM/RM) modes
This is in addition to the existing support for DECRQM queries
of DEC private modes.
2024-02-11 15:09:28 +00:00
Daniel Eklöf
7999975016
Don't use fancy Unicode quotes, stick to ASCII 2024-02-06 12:36:45 +01:00
Craig Barnes
44c0cf594b
csi: simplify handling of Set/Reset Mode (SM/RM) sequences 2024-01-27 08:43:32 +01:00
Daniel Eklöf
7fcbca808b
csi: decrqm: 2027: permanently disabled when grapheme-width-method != double-width 2023-09-25 16:50:50 +02:00
Daniel Eklöf
4eef001d58
csi: implement DECSET/DECRST/DECRQM 2027 - grapheme cluster processing
This implements private mode 2027 - grapheme cluster processing, as
defined in the "Terminal Unicode Core"[1] specification.

Internally, we just flip the already existing option "grapheme
shaping". Since it's now runtime changeable, we need a copy of it in
the terminal struct, rather than referencing the conf object.

[1]: 13fc5a8993/spec/terminal-unicode-core.tex (L50-L53)
2023-09-25 16:50:44 +02:00
Daniel Eklöf
613c61abb4
scaling: always round the scaling factor when converting to int
* In all calls to wl_subsurface_set_position()
* (wp_viewport_set_destination() already does this)
* Whenever we use the scale to calculate margins (search box,
  scrollback indicator etc)
* Since the scaling factor is stored as a float (and not a double),
  use roundf() instead of round()
2023-07-25 16:48:50 +02:00
Daniel Eklöf
c1f374cc8d
term: convert ‘scale’ to a float 2023-06-29 15:38:22 +02:00
Daniel Eklöf
2c0c4ce821
csi: CHA+HPA (cursor horizontal absolute): use term_cursor_col() 2023-06-20 14:55:32 +02:00
Daniel Eklöf
dc7642f2a5
csi: implement "CSI ? m" 2023-04-26 18:30:09 +02:00
Daniel Eklöf
f114068a46
csi: DECCOLM+DECSCLM: remove all support
We don’t support neither 132 column mode, nor smooth scrolling. Thus
it makes little sense to recognize these control condes.

Note that while XTerm does support 132 columns, it is disabled by
default. In this mode, XTerm also doesn’t trigger the
side-effects (i.e. clearing the screen).

Closes #1265
2023-03-31 13:16:43 +02:00
Harri Nieminen
ae26915916 fix typos 2023-03-29 00:45:18 +03:00
Daniel Eklöf
0fc8b65a2b
selection: selection_on_rows(): typo: row_start -> row_end
This fixes an issue where selections in the scroll margins were not
detected correctly. This meant they weren’t canceled as they should
have been, which in turn caused a visual glitch where text appeared to
be selected, but were in fact not.
2022-11-24 19:18:20 +01:00
Craig Barnes
46f6bad728
csi: reply with 4 instead of 2 for DECRQM queries of unsupported modes
The status value 4 means "permanently reset", as opposed to 2, which
means "reset". The former implies that there's no way to enable the
mode because it's unsupported (but recognized).

Note: this commit also fixes an unrelated typo in CHANGELOG.md.
2022-09-18 17:55:03 +02:00
Daniel Eklöf
c311229b9e
csi: damage *viewport* when exiting the alt screen
This fixes a redraw issue when the normal screen were somewhere in the
scrollback history when exiting the alt screen.
2022-09-06 17:37:19 +02:00
Daniel Eklöf
87e4004960
csi: clamp color index for ‘CSI 38/48 ; 5 ; idx m’ sequences
Indexed color values are stored in the cell attributes as color
indices (into the 256-color table). However, the index from the CSI
was not validated in any way, meaning you can do something like this:

  echo -e ‘\e[38:5:1024m CRASH \e[m’

and foot will crash on an out-of-bounds access.

Fix by clamping the color index.

Closes #1111
2022-07-22 10:44:33 +02:00
Daniel Eklöf
8485cdaaaa
csi: implement CSI > 4n (reset modifyOtherKeys) 2022-04-19 17:25:06 +02:00
Craig Barnes
856086bbbe
csi: reduce duplication in code handling SGR 38 and 48 sequences 2022-04-11 14:20:11 +02:00
jvoisin
58a1ffe724
config: add tweak option to allow disabling sixels
Closes #950
2022-04-06 19:25:43 +02:00
Craig Barnes
8d4d22218e csi: add support for DECNKM private mode
This is equivalent to DECKPAM/DECKPNM when enabled/disabled, but can
also be saved/restored/queried with XTSAVE/XTRESTORE/DECRQM.

See also:

* https://vt100.net/docs/vt510-rm/DECNKM.html
* https://vt100.net/docs/vt510-rm/DECKPAM.html
* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
2022-03-19 13:44:14 +00:00
Craig Barnes
f066f28026 csi: fix case label typo in decrqm()
The other functions that deal with private modes all use 1070 for
term->sixel.use_private_palette. The xterm docs[1] also list this
param as 1070:

> Ps = 1 0 7 0  ⇒  use private color registers for each graphic

Using 1079 seems to have been a mistake in commit 4aa980a6a2.
2022-02-16 17:31:09 +00:00
Craig Barnes
e32707ffc0 csi/input: remove private mode 27127
This effectively reverts commit 31c73f0cf0.
2022-02-09 20:50:20 +00:00
Daniel Eklöf
e0227266ca
fcft: adapt to API changes in fcft-3.x
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -> fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
2022-02-05 17:00:54 +01:00
Autumn Lamonte
d72ba4a062
SGR-Pixels mouse mode, closes #762 2022-01-01 11:02:30 +01:00
Daniel Eklöf
39bb6be8bf
term_erase(): replace coord-typed arguments with regular ints 2021-12-26 12:39:34 +01:00
Daniel Eklöf
c2bf2d3650
csi: store color index, not actual color, in cell’s fg/bg attributes
When using indexed colors (i.e. SGR 30/40/90/100), store the index
into the cell’s fg/bg attributes, not the actual color value.

This has a couple of consequences:

Color table lookup is now done when rendering. This means a rendered
cell will always reflect the *current* color table, not the color
table that was in use when the cell was printed to.

This simplifies the OSC-4/104 logic, since we no longer need to update
the grid - we just have to damage it to trigger rendering.

Furthermore, this change simplifies the VT parsing, since we no longer
need to do any memory loads (except loading the SGR parameter values),
only writes.
2021-12-26 12:37:48 +01:00
Daniel Eklöf
8bf757f466
csi: no need to set VT state’s fg/bg to the default ones on SGR reset 2021-12-26 12:37:47 +01:00
Daniel Eklöf
8f38cd486f
term: rename: KITTY_KBD_MASK -> KITTY_KBD_SUPPORTED 2021-11-28 15:14:55 +01:00
Daniel Eklöf
28ad0ca602
csi: kitty: remove unneeded xasserts
‘idx’ is calculated just above, and the logic is simple enough that we
don’t really need to assert it.
2021-11-28 15:14:55 +01:00
Daniel Eklöf
c3fda01554
csi: kitty: log flags after ‘update’ operation 2021-11-28 15:14:52 +01:00
Daniel Eklöf
ad2539af44
csi: kitty: s/mode/flags in debug logs 2021-11-28 15:14:52 +01:00
Daniel Eklöf
fec42e5941
kitty kbd: add flag state, implement push/pop/update/query 2021-11-28 15:14:40 +01:00
Daniel Eklöf
d46af6bd7a
term: track cell color source
Each cell now tracks it’s current color source:

* default fg/bg
* base16 fg/bg (maps to *both* the regular and bright colors)
* base256 fg/bg
* RGB

Note that we don’t have enough bits to separate the regular from the
bright colors. These _shouldn’t_ be the same, so we ought to be
fine...
2021-11-20 16:46:38 +01:00
Daniel Eklöf
4a74050999
input: add support for modifyOtherKeys=2
Similar to modifyOtherKeys=1 (foot’s default, and only, mode), except
that:

* All modifiers (and not just Ctrl) generate \E[27;m;n~ escapes
* Regular keys (with modifiers) also generate \E[27;m;n~ escapes (for
  example, C-h no longer generates ^H, but \E[27;5;104~)

For our keymap based lookups, this is handled by adding
MOD_MODIFY_OTHER_KEYS_STATE<N> variants.

For “generic” keys, we simply adjust the conditions for when to emit a
\E[27;m;n~ escape - the only requirement is that at least one modifier
is active.
2021-11-13 11:09:07 +01:00