Commit graph

5377 commits

Author SHA1 Message Date
Mariusz Bialonczyk
bbf9dcc2a3 themes/material-design: add missing bright colors 2022-03-29 08:44:49 +02:00
Daniel Eklöf
de5226c930
dcs: don’t automatically buffer anything
If a request handler doesn’t define its own put() handler, simply drop
all DCS parameter data. This way, we won’t end up allocating
potentially large buffers for unsupported/unimplemented DCS requests.

Closes #959
2022-03-21 20:40:51 +01:00
Daniel Eklöf
67a228bf4b
dcs: xtgettcap: use custom put() handler
Grow buffer exponentially, since XTGETTCAP requests can,
theoretically, be very large.
2022-03-21 20:40:50 +01:00
Daniel Eklöf
af88c19561
dcs: decrqss: use a custom put() handler
Only buffer up to two bytes, as that’s the largest DECRQSS request we
support.
2022-03-21 20:40:50 +01:00
Daniel Eklöf
8f06436985
dcs: map BSU/ESU unhook handlers directly to term_{enable,disable}_app_sync_upates()
That is, drop the local bsu() and esu() functions.
2022-03-21 20:40:50 +01:00
Daniel Eklöf
0b9b726bdf
vt: free OSC buffer after dispatch, if larger than 4K 2022-03-21 20:40:10 +01:00
Daniel Eklöf
1e63dddb89
input: don’t allow non-significant modifiers when matching untranslated symbols
When matching “untranslated” bindings (by matching the base symbol of
the key, e.g. ctrl+shift+2 in US layout), require that no
non-significant modifiers are active.

This fixes an issue where AltGr was “ignored”, and would cause certain
combinations to match a key binding.

Example: ctrl+altgr+0, on many European layouts matched against the
default ctrl+0 (reset the font size), instead of emitting ^]

To make this work, we now need to filter out “locked”
modifiers (e.g. NumLock and CapsLock). Otherwise having e.g. NumLock
active would prevent *all* untranslated matching to fail.

Closes #983
2022-03-20 13:29:29 +01:00
Daniel Eklöf
dcdbb3613c
char32: only include stdc-predef.h if it is available
Use the (relatively new) macro __has_include() to check if
stdc-predef.h exists, and only include it if it does.

If stdc-predef.h does not exist, or if the compiler does not implement
__has_include(), stdc-predef.h is *not* included.
2022-03-19 19:52:21 +01:00
Leonardo Neumann
c365df495e
char32: add missing header to work with musl 2022-03-19 19:05:34 +01:00
Mariusz Bialonczyk
b661b47ee1
themes: add material-design 2022-03-19 19:03:57 +01:00
Daniel Eklöf
485c473e76
selection: don’t translate \r to \n when pasting
In non-bracketed paste mode, we translate \n to \r, and \r\n to
\r. The latter matches XTerm, urxvt, alacritty and kitty. The former
matches alacritty and kitty (xterm and urxvt just blindly replaces all
\n occurrences with \r, meaning \r\n is translated to \r\r.

For some reason, we then unconditionally translated all \r back to \n,
regardless of whether bracketed paste was enabled or not. Unsure
why/where this comes from, but it doesn't match any of the other
terminal emulators I tested.

One example where this caused issues is in older versions of nano (at
least up to 2.9).

Closes #980
2022-03-19 19:01:25 +01: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
Daniel Eklöf
a1287220ab
Merge branch 'nord-and-rezza-themes' 2022-03-13 19:49:08 +01:00
merkix
7914c56dab
foot.ini: change vim modeline from ‘conf’ to ‘dosini’ 2022-03-13 19:46:31 +01:00
Daniel Eklöf
3cefe78b40
osc: use four digits in OSC-4 and OSC-11 rgb:r/g/b replies
Closes #971
2022-03-13 19:44:32 +01:00
Craig Barnes
2a4e7fde8d Merge branch 'osc-buffer-growth' 2022-03-13 18:22:04 +00:00
Mariusz Bialonczyk
2d1677e125 add rezza theme 2022-03-11 07:34:14 +01:00
Mariusz Bialonczyk
d3bfa95910 add Nord theme 2022-03-11 07:34:00 +01:00
Daniel Eklöf
6e536e7ed8
input: get_current_modifiers(): don’t crash if seat has no keyboard
Closes #963
2022-03-04 17:54:19 +01:00
Craig Barnes
cc8e86fd2d dcs: prevent possibility of out-of-bounds reads in decrqss()
This could be triggered by running, for example:

    printf '\033P$qrxyz\033\\'

...which would cause a memcmp() of 4 bytes on a 2 byte string literal.

Fixes: #960
2022-03-02 19:05:51 +00:00
Craig Barnes
a3c5e8927d osc: grow OSC buffer exponentially instead of by fixed increments of 128
With fixed increments of 128 bytes, an OSC 52 copy operation could end
up doing thousands or tens of thousands of realloc(3) calls just to
copy a few MB.
2022-03-02 01:55:25 +00:00
jvoisin
7d647c08ff Wrap setlocale in asserts since it can fail 2022-02-27 16:33:20 +01:00
Enes Hecan
525a71422d
Add JetBrains Darcula theme 2022-02-27 11:36:01 +01:00
Daniel Eklöf
9b343fd9fb
meson: stop using deprecated functions, require meson >= 0.58
* get_pkgconfig_variable() -> get_variable()
* prog.path() -> prog.full_path()
* meson.build_root() -> meson.global_build_root()
2022-02-27 11:28:11 +01:00
Daniel Eklöf
a65804139d
Merge branch 'socket-activation'
Closes #604
2022-02-27 11:13:30 +01:00
Max Gautier
522f4e522e Install notes regarding systemd unit files 2022-02-26 16:10:12 +01:00
Max Gautier
0b7f06bad4 Socket activation changelog entry 2022-02-26 16:09:52 +01:00
Max Gautier
4ec172a4ad Document socket activation feature
- Particular mention to included systemd user units
2022-02-26 16:09:30 +01:00
Max Gautier
1783f69cbd Adding systemd unit files for socket activation
- Support for multiples concurrent instances, templated on
  WAYLAND_DISPLAY
- Use standard input for the socket file descriptor (inetd style)
- Always use the socket provided by systemd with the systemd user
  service
- wayland-instance@.target is intended to be a special target a bit like
  graphical-session.target.
2022-02-26 16:09:30 +01:00
Max Gautier
88a0f7397c Make foot able to receive a socket from its parent
If the argument to --server is parsed as a number, consider it to be a
file descriptor, and use that as a socket.
This is necessary to be able to use socket activation with the server
mode of foot.
2022-02-26 16:09:30 +01:00
Daniel Eklöf
bd5576825f
Merge branch 'scrollback-home-and-end' 2022-02-24 19:23:07 +01:00
Daniel Eklöf
f869ca4546
config/input: add scrollback-home|end key bindings (unbound by default) 2022-02-23 19:03:54 +01:00
Daniel Eklöf
cb43c58150
commands: refactor scrollback up/down
When moving the viewport in the scrollback (i.e. “scrolling”), we need
to ensure the viewport is not moved past the beginning, or end, of the
scrollback.

This was previously accomplish by first limiting the number of lines
to scroll to the number of visible rows (i.e the viewport _size_), and
by adjusting the viewport after moving it, to ensure it doesn’t point
into an uninitialized scrollback area etc.

I.e. the implementation was _reactive_.

This patch rewrites the logic to be _proactive_; we now calculate
_where_ the beginning (or end) of the scrollback is, and then how many
lines there is from there, to the viewport. This is our _maximum_
number of lines to scroll.

When done correctly (which I hope this patch does), this allows us to
remove _all_ checks after moving the viewport - we already _know_ it’s
correct, and valid.

As a bonus, we can remove the old limit, where scrolling was only
allowed to be at most a single page.
2022-02-23 19:03:35 +01:00
Daniel Eklöf
f76c9e77f1
Merge branch 'custom-input-escapes'
Closes #325
2022-02-18 18:40:19 +01:00
Daniel Eklöf
bd9041fdb5
doc: foot.ini: document the new [text-bindings] section 2022-02-16 23:02:27 +01:00
Daniel Eklöf
4e69c1d178
foot.ini: move [text-bindings] section, and update example
Use Super+c -> Ctrl+c as example
2022-02-16 23:02:27 +01:00
Daniel Eklöf
8379b48a9e
changelog: remapping input to custom escape sequences 2022-02-16 23:02:27 +01:00
Daniel Eklöf
cff097197f
config: do key binding collision handling in overrides
This ensures we detect, and handle, collisions also for key-bindings
specified as overrides.
2022-02-16 23:02:25 +01:00
Daniel Eklöf
0018e570d4
tests: config: initial tests for text-bindings 2022-02-16 23:02:07 +01:00
Daniel Eklöf
422d94fb46
wip: map key combos to custom text strings (including escapes)
With this, it is now possible to map key combos to custom escapes. The
new bindings are defined in a new section, “text-bindings”, on the
form “string=key combo”.

The string can consist of printable characters, or \xNN style hex
digits:

  [text-bindings]
  abcd = Control+a
  \x1b[A = Control+b Control+c Control+d  # map ctrl+b/c/d to UP
2022-02-16 23:02:07 +01:00
Daniel Eklöf
8fa16f616c
main: --server: don’t exit with code 0 on failure
A foot --server instance would exit with code 0, even on failure, if
the number of currently open terminal instances were 0.

This is because ‘ret’ assumed failure, and then tried to set it to
‘success’ after the even loop had terminated, basted on the server’s
current state.

Fix by:

* set ‘ret’ to success just before entering the event loop
* set ‘ret’ to failure when we detect an FDM failure
* don’t try to second-guess success/failure after having exited the
  event loop

Closes #943
2022-02-16 22:44:42 +01:00
Craig Barnes
6940d2047e Merge branch 'terminfo-sync-2026' 2022-02-16 19:50:30 +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
f8262f2125 doc: ctlseq: recommend using DECSET 2026 for synchronized updates
Instead of the somewhat problematic[1] DCS-based equivalent.

[1]: https://codeberg.org/dnkl/foot/issues/459
2022-02-16 14:48:10 +00:00
Craig Barnes
b6ea9d2dbc terminfo: use DECSET 2026 instead of DCS sequences for Sync capability
Even though it makes little difference to foot which is used in the
terminfo entry, DECSET 2026 has some advantages[1] over the DCS
sequences and we should probably promote the better of the 2 where
possible.

Note: the terminfo string was taken from Nicholas Marriott's
suggestion[2] in the terminal-wg discussion.

[1]: https://codeberg.org/dnkl/foot/issues/459
[2]: https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2#note_973680
2022-02-16 14:08:22 +00:00
Craig Barnes
9db416ccdc doc: ctlseq: tweak formatting of OSC 22 sequence slightly, for clarity
Having 3 separately underlined words made it look a bit like 3 separate
parameters, at a glance.
2022-02-15 15:39:35 +00:00
Craig Barnes
3d3ee2274f doc: ctlseq: make OSC 8 formatting consistent with other sequences 2022-02-15 15:35:04 +00:00
Craig Barnes
23cf80667a Explicitly initialize sigaction::sa_mask members with sigemptyset(3)
Not doing so before calling sigaction(3) is "undefined" according to
POSIX[1]:

> Applications shall call either sigemptyset() or sigfillset() at least
> once for each object of type sigset_t prior to any other use of that
> object. If such an object is not initialized in this way, but is
> nonetheless supplied as an argument to any of pthread_sigmask(),
> sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(),
> sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or
> sigwaitinfo(), the results are undefined.

The use of designated initializers means that sa_mask members were
still being initialized, but sigset_t is an opaque type and implicit
initialization doesn't necessarily produce the same results as using
sigemptyset(3) (although it typically does on most implementations).

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaddset.html
2022-02-12 12:26:42 +00:00
Daniel Eklöf
d34c8007f1
osc: don’t damage the entire view on a single color palette update
Instead, loop the viewport and dirty only those cells that are
affected by the palette change.
2022-02-10 20:09:11 +01:00
Craig Barnes
3c232bec28 Merge branch 'remove-decset-27127' 2022-02-09 20:59:36 +00:00