Commit graph

5104 commits

Author SHA1 Message Date
Daniel Eklöf
bb4b4ae43d
config: value_to_key_combos(): reset modifiers in binding 2021-12-11 20:19:11 +01:00
Daniel Eklöf
e67639a682
main: ignore SIGPIPE
We want to handle SIGPIPEs without crashing... One way to trigger this
was to use e.g.

  pipe-visible=[cat /foo/bar] Control+Shift+q

That is, pipe output to something that did not consume it. This led
to a SIGPIPE when we tried to write the terminal contents to the pipe,
and crashed the whole foot instance.
2021-12-11 20:19:11 +01:00
Daniel Eklöf
197c1c5ced
config: do key binding collision detection after loading the conf
This allows the user to write, to swap two key bindings:

  [key-bindings]
  show-urls-launch=Control+Shift+r
  search-start=Control+Shift+u

instead of:

  [key-bindings]
  search-start=none
  show-urls-launch=Control+Shift+r
  search-start=Control+Shift+u

This should simplify the configuration for people who replace a lot of
the default key bindings.

This also simplifies the parsing somewhat, since we no longer has to
parse a key-binding into a temporary list, ensure it doesn’t have any
collisions, and then copy it into the actual key binding list.

_While_ parsing a key-binding, we still need a temporary array (at
least for the time being), but that temporary array is no longer
visible outside the parsing function that allocates it.
2021-12-11 20:19:11 +01:00
Daniel Eklöf
fc2bacbb78
config: remove struct key_combo, use config_key_binding instead 2021-12-11 20:19:10 +01:00
Daniel Eklöf
87c454c044
test: meson: add fontconfig to ‘test-config’ binary (fixes PGO builds) 2021-12-11 20:09:30 +01:00
Daniel Eklöf
8d7dceb88a
Merge branch 'config-unittest'
Part of #813
2021-12-11 18:54:42 +01:00
Daniel Eklöf
614de228a8
test: config: mouse-bindings 2021-12-11 18:52:06 +01:00
Daniel Eklöf
9c5019ae77
test: config: key-bindings
This adds tests for all [key-bindings] options, as well as an invalid
“action”.

The tests also verify key combo collisions are detected correctly.
2021-12-11 18:52:05 +01:00
Daniel Eklöf
8cf9f0f0dc
tests: meson: link with tllist 2021-12-11 18:52:05 +01:00
Daniel Eklöf
4a00d0d050
ci (gitlab+builds.sr.ht): execute foot{,client} --version
This runs our builtin unit tests (debug builds only), and verifies it
runs, at all. (and also logs the version in the build logs...)
2021-12-11 18:52:05 +01:00
Daniel Eklöf
7a9f929368
test: config: cover all basic (primitive) options in [main] 2021-12-11 18:52:05 +01:00
Daniel Eklöf
e1c3bdc6f2
test: initial external unit test suite for ‘config.c’
This patch adds a separate (external) test binary with unit tests for
config.c

This is achieved by having the test’s source file include
config.c (yes, the C file, not the header file).

This allows us to call e.g. parse_section_*() directly, without having
to go through config_load() (which requires having a readable file at
“path”).
2021-12-11 18:52:05 +01:00
Daniel Eklöf
c685406a13
changelog: kitty kbd: add link to codeberg issue 2021-12-08 19:06:51 +01:00
Daniel Eklöf
7ed671ef59
Merge branch 'releases/1.10' 2021-12-08 18:20:53 +01:00
Daniel Eklöf
baae46ea75
changelog: kitty: alternate keys: base layout key is implemented 2021-12-08 18:20:26 +01:00
Daniel Eklöf
3d7643b181
Merge branch 'releases/1.10' 2021-12-08 18:14:44 +01:00
Daniel Eklöf
a9026f16a7
meson: bump version to 1.10.3 2021-12-08 18:09:50 +01:00
Daniel Eklöf
924726ac76
changelog: prepare for 1.10.3 2021-12-08 18:08:45 +01:00
Daniel Eklöf
352077c78a
kitty: simplify: always calculate alternate/base keys
But only _emit_ them if report alternate has been enabled.
2021-12-08 18:06:10 +01:00
Daniel Eklöf
30a66996b2
kitty: when emitting associated text, don’t report mods/events unless necessary 2021-12-08 18:06:08 +01:00
Daniel Eklöf
db95a90e57
kitty: report-alternate: apply base-layout key to composed characters 2021-12-08 18:06:06 +01:00
Daniel Eklöf
7e9ca65f4d
kitty: implement “base layout key” in “report alternate key” 2021-12-08 18:06:04 +01:00
Daniel Eklöf
010c4001d2
kitty: initial support for “report alternate key”
In this mode, the “shifted” and “base layout” keys are added to the
CSIs, as sub-parameters to the “key” parameter.

Note that this PR only implements the “shifted” key, not the “base
layout key”.

This is done by converting the original XKB symbol to it’s
corresponding UTF-32 codepoint. If this codepoint is different from
the one we use as “key” in the CSI, we add it as a sub-parameter.

Related to #319
2021-12-08 18:06:02 +01:00
Daniel Eklöf
f3f3f60040
kitty: only emit plain text on key press- and repeat events
That is, release events always generate CSIs
2021-12-08 18:05:56 +01:00
Daniel Eklöf
40b69ab521
kitty: add ISO_Level{3,5}_Shift keys 2021-12-08 18:05:51 +01:00
Daniel Eklöf
305f3122b1
kitty: composed characters with “report associated text”
The generic input handler now converts the composed character to it’s
UTF-32 equivalent. This means we now provide a valid UTF-32 codepoint
for both composed characters, and non-composed (plain-text)
characters.

Use this in the kitty protocol to simplify the logic around composed
characters, by simply treating them as plain text.
2021-12-08 18:05:49 +01:00
Daniel Eklöf
7a5386d883
kitty: implement “report associated text”
In this mode, key events that generate text now add a third CSI
parameter, indicating the actual codepoint.

Remember that we always use the *unshifted* key in the CSI
escapes. With this mode, those CSI escapes now also included the text
codepoint. I.e. what would have been emitted, had we not generated a
CSI escape.

As far as I can tell, this mode has no effect unless “report all keys
as escape sequences” is enabled (reason being, without that, there
aren’t any text events that generate CSIs - they’re always emitted
as-is).

Note that Kitty itself seems to be somewhat buggy in this mode. At
least on Wayland, with my Swedish layout. For example ‘a’ and ‘A’ does
generate the expected CSIs, but ‘å’ and ‘Å’ appears to be treated as
non-text input.

Furthermore, Kitty optimizes away the modifier parameter, if no
modifiers are pressed (e.g. CSI 97;;97u), while we always emit the
modifier (CSI 97;1;97u).

Related to #319
2021-12-08 18:05:46 +01:00
Daniel Eklöf
9649842eca
grid: reload pointers into the uri range vector after inserting
Inserting elements into the URI range vector typically triggers a
vector resize. This is done using realloc(). Sometimes this causes the
vector to move, thus invalidating all existing pointers into the
vector.
2021-12-08 18:05:40 +01:00
Daniel Eklöf
4e34fb8fb7
input: kitty: add support for “report all keys as escape codes” 2021-12-08 18:05:33 +01:00
Daniel Eklöf
8b260568fb
term: ensure cell dimensions are non-zero
Closes #830
2021-12-08 18:05:20 +01:00
Daniel Eklöf
46cd5dfafc
changelog: move entry to ‘unreleased’ 2021-12-08 18:05:04 +01:00
Daniel Eklöf
85b1067514
input: kitty: merge handling of plain-text and composed characters
All plain-text and composed characters are now printed as-is, in a
single place.

Also fix handling of “generic” keys when emitted as escapes; don’t use
the raw XKB symbol as key in the escape, convert it to a unicode code
point first. For many symbols, these are the same. But not
all.

For now, we fallback to using the symbol as is if XKB fails to convert
it to a codepoint. Not sure if we should simply drop the key press
instead.

Composed characters also need special treatment; we can’t use the
symbol as is, since it typically refers to the last key
pressed (i.e. not the composed character). And, that key is
also (usually) a special “dead” key, which cannot be converted to a
unicode codepoint.

So, what we do is convert the generated utf8 string, and (try to)
convert it to a wchar. If it succeeds, use that. If not, fallback to
using the XKB symbol (as above).
2021-12-08 18:03:52 +01:00
Daniel Eklöf
149e978bc4
input: reset compose state on key *releases*, not presses 2021-12-08 18:03:51 +01:00
Daniel Eklöf
5d94b02a03
input: kitty: treat repeating == pressed when report-events is off 2021-12-08 18:03:48 +01:00
Daniel Eklöf
a242ba3f97
changelog: kitty: report events 2021-12-08 18:03:44 +01:00
Daniel Eklöf
30f60259cc
input: kitty: add support for the “report event” mode (0b10) 2021-12-08 18:03:42 +01:00
Daniel Eklöf
71606009fd
input: don’t ignore key release events
Before this, key release events stopped the repeat timer, and then
returned.

Now, we run through the entire function. Most things are still only
done on key press events. But, the goal here is to get to the keyboard
protocol functions (and the kitty protocol in particular), and call
them on release events too.

This is in preparation for the kitty protocol mode 0b10, report event
types.
2021-12-08 18:03:39 +01:00
Daniel Eklöf
6f6af910a5
install: add UTF-8 locate to runtime deps 2021-12-08 18:03:18 +01:00
Daniel Eklöf
d73c683ab1
install: update instructions on how to manually compile the terminfo 2021-12-08 18:03:15 +01:00
Daniel Eklöf
1a5a0952d5
changelog: add new ‘unreleased’ section 2021-12-08 18:02:57 +01:00
Daniel Eklöf
c2ed88e0f0
Merge branch 'kitty-report-alternate-key-part-1'
Closes #319
2021-12-08 17:56:04 +01:00
Daniel Eklöf
34ce9f97bb
kitty: simplify: always calculate alternate/base keys
But only _emit_ them if report alternate has been enabled.
2021-12-08 17:54:37 +01:00
Daniel Eklöf
52eee4482b
kitty: when emitting associated text, don’t report mods/events unless necessary 2021-12-08 17:54:37 +01:00
Daniel Eklöf
c0cfec89e0
kitty: report-alternate: apply base-layout key to composed characters 2021-12-08 17:54:37 +01:00
Daniel Eklöf
9b57ef07f1
kitty: implement “base layout key” in “report alternate key” 2021-12-08 17:54:37 +01:00
Daniel Eklöf
9d5ab91b6a
kitty: initial support for “report alternate key”
In this mode, the “shifted” and “base layout” keys are added to the
CSIs, as sub-parameters to the “key” parameter.

Note that this PR only implements the “shifted” key, not the “base
layout key”.

This is done by converting the original XKB symbol to it’s
corresponding UTF-32 codepoint. If this codepoint is different from
the one we use as “key” in the CSI, we add it as a sub-parameter.

Related to #319
2021-12-08 17:54:37 +01:00
Daniel Eklöf
a1c9635ed8
Merge branch 'kitty-report-associated-text'
Related to #319
2021-12-08 17:54:10 +01:00
Daniel Eklöf
21fe01099c
kitty: only emit plain text on key press- and repeat events
That is, release events always generate CSIs
2021-12-08 17:53:01 +01:00
Daniel Eklöf
e9a762f8a1
kitty: add ISO_Level{3,5}_Shift keys 2021-12-08 17:53:00 +01:00
Daniel Eklöf
69f97446fa
kitty: composed characters with “report associated text”
The generic input handler now converts the composed character to it’s
UTF-32 equivalent. This means we now provide a valid UTF-32 codepoint
for both composed characters, and non-composed (plain-text)
characters.

Use this in the kitty protocol to simplify the logic around composed
characters, by simply treating them as plain text.
2021-12-08 17:53:00 +01:00