Commit graph

2936 commits

Author SHA1 Message Date
Daniel Eklöf
deb2c2db6d
input: enforce ‘numerical’ keypad mode when Num Lock override is enabled
When num lock override has been enabled via “CSI?1035h” (the default),
keypad is always considered to be in ‘numerical’ mode.

This affects how keypad keys are translated to escape sequences when
Num Lock is active.

The keypad has four modes:

* Num Lock off, numerical mode
* Num Lock off, application mode
* Num Lock on, numerical mode
* Num Lock on, application mode

The keymap is identical for numerical and application mode when Num
Lock is off, meaning the keypad effectively has three different modes.

In XTerm, numerical and application mode _can_ be the same, **if** the
‘numLock’ resource is set to true (the default). It is only when
‘numLock’ is false that the application mode is actually used.

This patch changes foot to do the same. We don’t expose an option, but
do implement “CSI ? 1035”.

Closes #194
2020-11-11 18:28:37 +01:00
Daniel Eklöf
bdaf20ba71
input: track num lock state 2020-11-11 18:28:13 +01:00
Daniel Eklöf
2382d6b448
csi: implement “CSI ? 1035” - toggle Num Lock override
This adds a num_lock_modifier state to the terminal, and hooks up
“CSI?1035h/l” to toggle it.
2020-11-11 18:26:47 +01:00
Daniel Eklöf
75bd780f02
input: use XKB_MOD_NAME_* macros instead of hard-coded strings 2020-11-11 18:25:54 +01:00
Daniel Eklöf
c9de30e2bc
client: let getopt_long(3) print error messages
Closes #191
2020-11-10 19:04:20 +01:00
Daniel Eklöf
3fa3c58c8b
input: ignore keymap if we don’t recognize its format 2020-11-09 19:59:48 +01:00
Daniel Eklöf
85220a5543
wayland: use wl_*_release() instead of wl_*_destroy()
This lets the compositor free up internal state.
2020-11-09 19:59:45 +01:00
Daniel Eklöf
71e98d5b8f
Merge branch 'jeromenerf-patch-1'
Closes #185
2020-11-07 11:54:00 +01:00
jeromenerf
dbac3e4e4a Fix documentation snippets
- zsh doesn't like "export var+=value", make it two steps
- meson was complaining with "ERROR: Must specify at least one directory name.", so add the relative "../.."
2020-11-06 21:30:39 +01:00
Daniel Eklöf
6f28c16023
Merge branch 'releases/1.5' 2020-11-06 20:21:33 +01:00
Daniel Eklöf
90abdab345
meson/pkgbuild: bump version to 1.5.3 2020-11-06 20:16:27 +01:00
Daniel Eklöf
442e10dd28
selection: fix enum type
enum selection_scroll_direction is used when extending a selection by
auto-scrolling the terminal content while the mouse is outside the
grid.

What we want is enum selection_direction.
2020-11-06 20:13:44 +01:00
Daniel Eklöf
2281ee852a
selection: fix enum type
enum selection_scroll_direction is used when extending a selection by
auto-scrolling the terminal content while the mouse is outside the
grid.

What we want is enum selection_direction.
2020-11-06 20:12:15 +01:00
Daniel Eklöf
66f846d723
selection: explicitly set direction when right-click extending
Fixes an issue where right-click-and-dragging to extend a selection
caused one cell being removed from the selection.

Closes #180
2020-11-06 20:09:26 +01:00
Daniel Eklöf
c512dc4490
input: don’t use seat->kbd_focus as terminal when processing a key press
When converting mouse scroll events to keyboard input (in alternate
scroll mode), we need to use seat->mouse_focus, not seat->kbd_focus.

To enable this, break out key press/release handling code to a
separate function that takes an explicit term argument. Call this
function from keyboard_key(), input_repeat() and in alternate scroll
mode.

Closes #179
2020-11-06 20:09:16 +01:00
Daniel Eklöf
273f105af5
tiocswinsz: fix compilation error on e.g. ppc64
On some platforms, TIOCSWINSZ has a very large value, >
0x80000000.

On some platforms, the `request` argument to `ioctl(3)` is an `int`.

For platforms where both of the above is true, gcc will warn (and
error out if compiled with `-Werror`) on:

  ioctl(fd, TIOCSWINSZ, ...)

To silence this warning, we need to cast `TIOCSWINSZ` to an
integer.

However, doing this on platforms where `request` is an `unsigned long`
will result in `TIOCSWINSZ` being sign-extended (and thus we end up
with an invalid value).

It seems that casting to `unsigned int` works in both cases; it
silences the long -> int conversion warning, while also preserving the
correct value in all cases.
2020-11-06 20:08:52 +01:00
Daniel Eklöf
d31139515f
main: remove trailing ‘, ’ from arch log line 2020-11-06 20:08:33 +01:00
Daniel Eklöf
30f23a3b74
input: handle XKB errors
* Don’t de-reference the xkb context/keymap/state if we failed to
  instantiate them.
* Don’t try to send a translated utf8 key sequence if the translation
  failed.
* Handle xkb_compose_state_get_utf8() and xkb_state_key_get_utf8()
  returning more than 64 bytes.

This _may_ fix #171.
2020-11-06 20:08:15 +01:00
Daniel Eklöf
90544ef391
input: don’t allow diagonal resize when tiled 2020-11-06 20:08:07 +01:00
Daniel Eklöf
ebd4a32768
wayland: properly restore window size when being un-tiled
Bind to xdg-shell version 2 if available, as this enables us to
track our window’s ‘tiled’ state in the ‘configure’ events.

This in turn allows us to stash the ‘old’ window size when being
tiled, to be used again when restoring the window size when un-tiled.
2020-11-06 20:07:59 +01:00
Daniel Eklöf
9e7783596a
input: don’t crash if xkbcommon cannot find a compose file
Handle xkb_compose_table_new_from_locale() returning NULL. When this
happens, log a warning that “dead keys” will be disabled, and make
sure to never de-reference the compose table pointer.

Closes #170
2020-11-06 20:07:31 +01:00
Daniel Eklöf
e85ace0b0d
changelog: prepare for 1.5.3 2020-11-06 20:06:31 +01:00
Daniel Eklöf
9ce79e2ef0
config: add support for pipe-* actions in mouse bindings
Closes #183
2020-11-06 19:30:05 +01:00
Daniel Eklöf
398f0b699a
config: mouse combos: set count=1 if user has omitted click count 2020-11-06 19:30:05 +01:00
Daniel Eklöf
8ede3dc886
config: break out “[cmd arg1 arg2]” parsing to separate function 2020-11-06 19:30:05 +01:00
Daniel Eklöf
a1a68b7d50
config: don’t use memcmp() to compare structs 2020-11-06 19:30:04 +01:00
Daniel Eklöf
b541ce9d5c
wayland: output removed: only call surface_leave() if term is actually mapped on that output 2020-11-06 19:25:54 +01:00
Daniel Eklöf
a8fb51a34c
selection: explicitly set direction when right-click extending
Fixes an issue where right-click-and-dragging to extend a selection
caused one cell being removed from the selection.

Closes #180
2020-11-04 19:01:59 +01:00
Daniel Eklöf
9209adf6fa
input: don’t use seat->kbd_focus as terminal when processing a key press
When converting mouse scroll events to keyboard input (in alternate
scroll mode), we need to use seat->mouse_focus, not seat->kbd_focus.

To enable this, break out key press/release handling code to a
separate function that takes an explicit term argument. Call this
function from keyboard_key(), input_repeat() and in alternate scroll
mode.

Closes #179
2020-11-03 19:44:51 +01:00
Daniel Eklöf
f3e6941c9a
search: add {clipboard,primary}-paste key bindings
These bindings copy from the clipboard or primary selection into the
search buffer.

Default bindings:

* clipboard-paste: ctrl+v, ctrl+y
* primary-paste: shift+insert
2020-11-01 12:39:57 +01:00
Daniel Eklöf
43f293f22e
selection: do mime-type based decoding before passing data to callback
The intention here is to make *all* text_from_clipboard() and
text_from_primary() callers benefit from mime-type base
decoding (e.g. URI list decoding).

Previously, the decoding was done *in* the callback, which meant only
the “default” clipboard/primary selection paste functions, and DnD,
recognized URI lists.
2020-11-01 11:52:11 +01:00
Daniel Eklöf
0271e377c0
Merge branch 'silence-tiocswinsz-conversion-warning' 2020-10-31 11:17:00 +01:00
Daniel Eklöf
102d4975a1
selection: dnd: fix wl_data_offer_destroy() race
At the end of a drag-and-drop operation, we need to call
`wl_data_offer_finish()`.

We *must* ensure the data offer hasn’t been destroyed before
that. This could previously happen if the compositor decided to send a
regular clipboard offer *after* we had started a drop operation,
but *before* it had finished. The dnd offer was then destroyed when
the clipboard offer was received, causing us to crash in
`wl_data_offer_finish()`.

To handle this, let the receive_offer_context take over ownership of
the data_offer pointer, and “manually” destroy it *after* calling
`wl_data_offer_finish()` in `receive_dnd_done()`.

Note: we should not, and can not, do the same thing for regular
clipboard and primary selection offers; such offers can be used
multiple times and should *not* be destroyed after a single copy
operation.
2020-10-31 10:36:11 +01:00
Daniel Eklöf
beaf220f39
tiocswinsz: fix compilation error on e.g. ppc64
On some platforms, TIOCSWINSZ has a very large value, >
0x80000000.

On some platforms, the `request` argument to `ioctl(3)` is an `int`.

For platforms where both of the above is true, gcc will warn (and
error out if compiled with `-Werror`) on:

  ioctl(fd, TIOCSWINSZ, ...)

To silence this warning, we need to cast `TIOCSWINSZ` to an
integer.

However, doing this on platforms where `request` is an `unsigned long`
will result in `TIOCSWINSZ` being sign-extended (and thus we end up
with an invalid value).

It seems that casting to `unsigned int` works in both cases; it
silences the long -> int conversion warning, while also preserving the
correct value in all cases.
2020-10-29 18:06:04 +01:00
Daniel Eklöf
dddeb14e1a
Merge branch 'drag-and-drop' 2020-10-28 20:33:05 +01:00
Daniel Eklöf
bb43695426
codespell: fix misspelled words 2020-10-28 19:34:49 +01:00
Daniel Eklöf
be22fefdc7
selection: add support for different mime-types
Add support for `text/plain`, `text/plain;charset=utf-8` and
`text/uri-list` to regular copy operations (both from clipboard and
primary selection) and drag-and-drop operations.
2020-10-28 19:16:04 +01:00
Daniel Eklöf
cad0ae957d
osc: use new uri_parse() to parse an OSC7 PWD URI 2020-10-28 19:11:22 +01:00
Daniel Eklöf
608cc746ad
uri: add uri_parse() - new function extracts components from an URI 2020-10-28 19:10:44 +01:00
Daniel Eklöf
9580c04dd3
selection: debug log of data offer mime-types and actions 2020-10-26 21:19:07 +01:00
Daniel Eklöf
8e23b5b70d
selection: implement support for drag-and-drop
We accept COPY and MOVE actions, for text/plain;charset=utf-8
mime-types.

To implement DnD, we need to track the current DnD data offer *and*
the terminal instance it is (currently) targeting.

To do this, a seat has a new member, ‘dnd_term’. On a DnD enter event,
we lookup the corresponding terminal instance and point ‘dnd_term’ to
it.

On a DnD leave event, ‘dnd_term’ is reset.

The DnD data offer is tracked in the terminal’s wayland window
instance. It is reset, along with the seat’s ‘dnd_term’ on a DnD leave
event.

On a drop event, we immediately clear the seat’s ‘dnd_term’, to ensure
we don’t reset it, or destroy the offer before the drop has been
completed.

The drop’s ‘done()’ callback takes care of destroying and resetting
the DnD offer in the terminal’s wayland window instance.

Closes #175
2020-10-26 21:02:53 +01:00
Daniel Eklöf
af3b604d8e
wayland: bind to data-device-manager version 3, for drag-and-drop support 2020-10-26 21:02:24 +01:00
Daniel Eklöf
2928ef5fbe
main: remove trailing ‘, ’ from arch log line 2020-10-25 19:27:57 +01:00
Daniel Eklöf
4283e96865
render: blink switches between foreground and dimmed foreground 2020-10-22 18:41:47 +02:00
Daniel Eklöf
353e51b0a1
Merge branch 'custom-bold-italic-fonts'
Closes #169
2020-10-21 16:33:45 +02:00
Daniel Eklöf
f0d91fc490
changelog: restored -> restore 2020-10-20 21:32:20 +02:00
Daniel Eklöf
84859f475e
doc: foot.ini.5: mention how one can disable bold/italic fonts completely 2020-10-20 21:12:25 +02:00
Daniel Eklöf
2c101a21ee
config: add font-bold, font-italic and font-bold-italic options
These options lets the user configure custom fonts and styles, to use
with the bold and italic cell attributes.

By default, they are unset, meaning we use the bold/italic variants of
the regular font.

Closes #169.
2020-10-20 21:04:47 +02:00
Daniel Eklöf
b507d3a55e
osc: change info logging to debug logging when changing the cursor color 2020-10-20 21:03:51 +02:00
Daniel Eklöf
0d319f8793
input: handle XKB errors
* Don’t de-reference the xkb context/keymap/state if we failed to
  instantiate them.
* Don’t try to send a translated utf8 key sequence if the translation
  failed.
* Handle xkb_compose_state_get_utf8() and xkb_state_key_get_utf8()
  returning more than 64 bytes.

This _may_ fix #171.
2020-10-20 21:01:33 +02:00