Commit graph

4988 commits

Author SHA1 Message Date
Daniel Eklöf
ebad4bba28
input: kitty: disable CSI for Caps- and Num-Lock
Not sure why these keys have CSIs in the kitty spec; they don’t emit
anything.

Could it be that they are used if the keys are *not* modifiers in the
current layout?
2021-11-28 15:14:53 +01:00
Daniel Eklöf
e744cee760
input: kitty: printables are emitted as text, even if Caps- or Num-Lock is in effect
Not sure if this is the best/correct way to do it. But kitty seems to
ignore at least Num-Lock for printables, while it _does_ affect other
keys. For example, Return, which usually emits ‘\r’, are affected by
Num-Lock and emit ‘CSI 13;129u’.

Note that as soon as some other modifier is in effect, the Num-Lock
modifier *is* encoded in the CSI, also for printables.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
db746d72ed
input: get_current_modifiers() no longer strips insignificant mods
Our internal binding handling cares about a different set of
modifiers, compared to the kitty keyboard protocol.

To handle this, get_current_modifiers() has been modified, to no
longer strip the “unsignificant” modifiers. This is now up to the
caller to do.

To help, we keep two masks (for significant modifiers) in the seat
struct; one for our internal binding handling (and the legacy keyboard
protocol), and one for the kitty keyboard protocol. These two masks
are updated when the seat’s keymap is updated/changed.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
b9d03c16a6
input: kitty: use base symbol instead of lowering the symbol
When emitting an escape sequence for a printable character, with
modifiers (e.g. ctrl+a), use the key’s base symbol instead of
“lowering” it.

This means we now handle e.g. ctrl+2 and ctrl+shift+2, with Swedish
layout.

There’s a twist however. We *only* use the base symbol if the
modifiers that is used to “generate” the symbol are “significant”.

Significant modifiers are, in this context, modifiers we can encode in
the kitty escape sequences.

In the Swedish layout, pressing AltGr+2 results in ‘@’. AltGr cannot
be encoded in the kitty protocol. If we were to use the base symbol,
AltGr+Alt+2 would result in exactly the same escape sequence as Alt+2.
2021-11-28 15:14:53 +01:00
Daniel Eklöf
ab5dfa3f3b
input: wip: add support for kitty kbd protocol “Disambiguate escape codes”
Most things appear to work as in kitty. There’s one known difference:
tri-state keys don’t generate the same unshifted symbol while holding
Shift (but e.g. Ctrl+a and Ctrl+Shift+a *does* generate the same base
symbol).

For example, the Swedish keyboard layout has double quote, ‘2’ and ‘@’
on the same key. ‘2’ is the base (unshifted) symbol. Double quote is
Shift+2. ‘@’ is AltGr+2.

Kitty generates the same base symbol for ‘2’ and double quote (the
base symbol is, as expected, ‘2’).

But, for ‘@’ kitty generates the base symbol ‘@’.

Currently, foot generates the base symbol by calling
xkb_keysym_to_lower().

I _think_ what we need to do is “consume” the shift modifier, and then
re-retrieve the symbol (given the current xkb state and key pressed).
2021-11-28 15:14:53 +01:00
Daniel Eklöf
2d85dbec6b
input: enable repeat while COMPOSING 2021-11-28 15:14:52 +01:00
Daniel Eklöf
9f3dba683e
input: refactor: new function: legacy_kbd_protocol()
This breaks out all handling of key escapes to-be-sent to the client,
to a separate function, legacy_kbd_protocol().

That is, the key press/release handler first handles key generic
handling, such as starting and stopping the repeat timer.

Then it checks for foot keyboard bindings. If not bindings match, we
need to pass the keyboard event to the client. This code has now been
separated out into a new function.
2021-11-28 15:14:52 +01:00
Daniel Eklöf
3c01eb48dc
term: kitty kbd: fix typo: ‘BKD’ -> ‘KBD’ 2021-11-28 15:14:52 +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
2fe2dfa847
grid: uri_range_erase(): unittest: try erasing a row without any URIs 2021-11-28 11:05:00 +01:00
Daniel Eklöf
66b8c92c30
grid: uri_range_erase: walk the ranges backwards
This way, ranges are deleted last-to-first, thus avoiding memmoving
multiple ranges over and over again when erasing e.g. a full line.
2021-11-28 11:03:07 +01:00
Daniel Eklöf
747da83c76
grid: remove useless assertion
grid.c:1041:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
2021-11-27 18:15:59 +01:00
Daniel Eklöf
512a07fd14
Merge branch 'osc8-dont-use-tllist' 2021-11-27 16:41:24 +01:00
Daniel Eklöf
5ce6c89df6
grid: resize without reflowing: use URI range utility functions 2021-11-27 16:31:33 +01:00
Daniel Eklöf
dfeca4e134
grid: uri_range_{append,insert}: pass range attributes as separate parameters 2021-11-27 16:25:29 +01:00
Daniel Eklöf
5c6c2de051
grid: snapshot: use uri range utility functions 2021-11-27 16:11:26 +01:00
Daniel Eklöf
5c7e881cd4
grid: uri_range_ensure_size(): add the requested amount of entries 2021-11-27 16:03:07 +01:00
Daniel Eklöf
7699271316
grid: reflow: no need to keep a uri-range-idx variable
The URI ranges are now an array, which means we can get the next URI
range by incrementing the pointer.

Instead of checking if range is not NULL, check that it isn’t the
range terminator (which is NULL when we don’t have any ranges, and
the first address *after* the last range otherwise).
2021-11-26 20:57:08 +01:00
Daniel Eklöf
41565a0d0e
grid: resize without reflow: only verify URI ranges in debug builds 2021-11-26 20:36:59 +01:00
Daniel Eklöf
be203aeae1
grid: bug: OSC-8 URIs were incorrectly skipped while resizing the alt screen 2021-11-26 20:29:23 +01:00
Daniel Eklöf
4eb0aa0f18
osc8: replace grid_row_uri_range_add() with internal uri_range_append()
grid_row_uri_range_add() was only used while reflowing. In this case,
we know the new URIs being added are always going at the end of the
URI list (since we’re going top-to-bottom, left-to-right).

Thus, we don’t need the insertion logic, and can simply append instead.
2021-11-26 20:25:07 +01:00
Daniel Eklöf
ccee08a393
osc8: uri ranges: use a dynamically re-sizable array instead of a tllist 2021-11-26 20:09:15 +01:00
Daniel Eklöf
b1043a72f8
ci: fcft:text-shaping -> fcft:grapheme-shaping + fcft:run-shaping 2021-11-26 20:08:45 +01:00
Daniel Eklöf
a2d3a04ce7
Merge branch 'osc8-more-sgr-like' 2021-11-26 19:53:37 +01:00
Daniel Eklöf
8c50a7afd4
osc8: update URI ranges as we print data, *not* when the URI is closed
At first, an OSC-8 URI range was added when we received the closing
OSC-8 escape (i.e. with an empty URI).

But, this meant that cursor movements while the OSC-8 escape was in
effect wasn’t handled correctly, since we’d add a range that spanned
the cursor movements.

Attempts were made to handle this in the cursor movement functions, by
closing and re-opening the URI.

However, there are too many corner cases to make this a viable
approach. Scrolling is one such example, line-wrapping another.

This patch takes a different approach; emit, or update the URI range
when we print to the grid. This models the intended behavior much more
closely, where an active OSC-8 URI act like any other SGR attribute -
it is applied to all cells printed to, but otherwise have no effect.

To avoid killing performance, this is only done in the “generic”
printer. This means OSC-8 open/close calls must now “switch” the ASCII
printer.

Note that the “fast” printer still needs to *erase* pre-existing OSC-8
URIs.

Closes #816
2021-11-25 19:31:03 +01:00
Daniel Eklöf
82219713cc
Merge branch 'finalize-selection-on-pointer-leave' 2021-11-25 16:53:33 +01:00
Daniel Eklöf
325ad6dd4e
input: finalize mouse selection on a pointer-leave event on the GRID surface
If a mouse selection was ongoing, and the user switched
workspace (probably using the keyboard...), and then back, the
selection was still treated as ongoing, while all other mouse state
has been reset.

This meant the user had to tap at least once to stop the selection.
2021-11-25 15:21:53 +01:00
Daniel Eklöf
2eef28590a
Merge branch 'grapheme-width-max' 2021-11-25 12:44:35 +01:00
Daniel Eklöf
c1c0f11821
config: add tweak.grapheme-width-method=max
‘max’ is a new value for ‘tweak.grapheme-width-method’. When enabled,
the width of a grapheme cluster is that of the cluster’s widest
codepoint.
2021-11-23 19:50:05 +01:00
Daniel Eklöf
caec64cbda
changelog: add new ‘unreleased’ section 2021-11-22 22:24:13 +01:00
Daniel Eklöf
8b979e9dba
changelog: add #801 to “OSC-8 data not being cleared...” 2021-11-22 22:23:28 +01:00
Daniel Eklöf
72e1c7713e
Merge branch 'releases/1.10' 2021-11-22 22:23:09 +01:00
Daniel Eklöf
5eded7292c
meson: bump version to 1.10.1 2021-11-22 22:01:28 +01:00
Daniel Eklöf
f91dc5dd00
changelog: prepare for 1.10.1 2021-11-22 21:56:38 +01:00
Daniel Eklöf
f9854d93cf
Merge branch 'master' into releases/1.10 2021-11-22 21:55:06 +01:00
Daniel Eklöf
4a47730f15
Merge branch 'osc8-overwrite-2'
Closes #801
Closes #804
2021-11-22 21:50:30 +01:00
Daniel Eklöf
5b176dd5d6
term: print: reset ‘col’ after padding the right margin 2021-11-21 18:09:40 +01:00
Daniel Eklöf
315769b50b
Revert "term: print: erase URI range when printing right-margin padding"
This reverts commit bb967fd2f927d90e881ed2b05db1fa6946033580.
2021-11-21 18:09:40 +01:00
Daniel Eklöf
65944906bf
term: print: erase URI range when printing right-margin padding 2021-11-21 18:09:40 +01:00
Daniel Eklöf
3c6239c66f
term: print: re-order col/row/cell assigments 2021-11-21 18:09:39 +01:00
Daniel Eklöf
ad8d1bf25c
changelog: osc-8 data not being cleared when cell is overwritten 2021-11-21 18:09:37 +01:00
Daniel Eklöf
f27ccd999e
grid: refactor grid_row_uri_range_erase()
The old algorithm always created a new URI, followed by (maybe)
removing the existing URI, when an URI needed to be modified.

That is, if e.g. the tail of an URI was being erased, the old
algorithm would create a new URI for the part of the URI that should
remain, and then removed the old URI.

This isn’t very effective. The new algorithm instead identifies all
possible overlap cases, and handles each one differently:

* URI ends *before* erase range starts - continue with the next URI
  without further checks
* URI starts *after* the erase range ends - return, we’re done
* Erase range erases the entire URI - remove the URI
* Erase range erases a part in the middle - split the URI
* Erase range erases the head of the URI - adjust the URI’s start
* Erase range erases the tail of the URI - adjust the URI’s end
2021-11-21 18:09:27 +01:00
Daniel Eklöf
503c2ebd50
grid: row_uri_range_erase(): assume caller has checked row->extra != NULL 2021-11-21 18:09:27 +01:00
Daniel Eklöf
0be55ef74c
term: erase_cell_range(): check if row->extra != NULL 2021-11-21 18:09:27 +01:00
Daniel Eklöf
53fc1a1cb1
term: tail-call optimize calls to grid_row_uri_range_erase() 2021-11-21 18:09:27 +01:00
Daniel Eklöf
09a331857a
term: call grid_row_uri_range_erase() when printing cells 2021-11-21 18:09:26 +01:00
Daniel Eklöf
1a0de0017f
grid: add grid_row_uri_range_erase()
This function handles erasing of an URI range. That is, a range of the
row is being either erased, or overwritten (from the URI perspective,
these two are the same thing).

We handle both partial overwrites (split up, or truncate URI), as well
as complete overwrites (remove URI).
2021-11-21 18:09:26 +01:00
Daniel Eklöf
7522c2d211
changelog: pipe-* key bindings not being parsed correctly 2021-11-21 18:09:10 +01:00