Commit graph

5227 commits

Author SHA1 Message Date
Mark Stosberg
0777d3b35f doc: document the 8 ANSI escape codes. 2022-01-15 14:36:45 -05:00
Daniel Eklöf
379e68916e
meson: fix race build order of builtin terminfo
The builtin terminfo is used by dcs.c, which is built as part of the
static library ‘vtlib’. Thus, vtlib needs to depend on the
builtin_terminfo target.
2022-01-15 17:15:45 +01:00
Daniel Eklöf
179ab08161
Merge branch 'clock-gettime' 2022-01-15 17:08:42 +01:00
Pranjal Kole
0da19a81bc replace gettimeofday with clock_gettime
POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the
use of clock_gettime(2) instead.

CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is
unaffected by manual changes in the system clock. This makes it better
for our purposes, namely, measuring the difference between two points in
time.

tv_sec has been casted to long in most places since POSIX does not
define the actual type of time_t.
2022-01-15 21:35:45 +05:30
Daniel Eklöf
0d649408a0
Merge branch 'clock' 2022-01-14 16:17:21 +01:00
Érico Nogueira
5af65d897c terminal: use CLOCK_MONOTONIC instead of literal.
CLOCK_MONOTONIC isn't guaranteed to have the same value on all
platforms, and this makes the code more readable.
2022-01-14 11:39:27 -03:00
Daniel Eklöf
b292e735bb
dcs: decrqss: refactor: append_sgr_attr_n() is now a proper function 2022-01-14 14:09:28 +01:00
Daniel Eklöf
f048e08f10
Merge branch 'decrqss'
Closes #798
2022-01-14 13:52:58 +01:00
Daniel Eklöf
7243b094b7
dcs: decrqss: add note about Ps in the reply 2022-01-14 13:52:42 +01:00
Daniel Eklöf
a8681ea440
dcs: decrqss: BUG on invalid cursor style 2022-01-14 13:52:42 +01:00
Daniel Eklöf
add530e66d
dcs: implement DECRQSS
This patch adds support for DECRQSS (request Selection or Setting),
for the following sub-queries:

* DECSTBM   Set Top and Bottom Margins
* SGR       Set Graphic Rendition
* DECSCUSR  Set Cursor Style

Closes #798
2022-01-14 13:52:41 +01:00
Daniel Eklöf
2d3d8ca3d0
Merge branch 'xtgettcap'
Closes #846
2022-01-14 13:49:25 +01:00
Daniel Eklöf
49a8c7fc76
doc: foot.1: XTGETTCAP 2022-01-14 13:45:23 +01:00
Daniel Eklöf
b819d38f1e
changelog: XTGETTCAP 2022-01-14 13:41:17 +01:00
Daniel Eklöf
da9d732855
readme: document XTGETTCAP behavior 2022-01-14 13:41:17 +01:00
Daniel Eklöf
5a032c4c6f
xtgettcap: switch from a table based internal structure, to a single char array
Having the builtin terminfo DB as a table, with one entry per
capability/value pair was ineffective memory-wise - we ended up adding
~20K to the final binary size.

This patch changes the internal representation from a table, to a
single NULL-separated (and NULL-terminated) char array:

  cap1-name \0 cap1-value \0 cap2-name \0 cap2-value \0

The capabilities are still sorted; to lookup a capability we need to
scan from the beginning until we either find a match, or until the
capabilities from the DB sort higher (lexicographically) than the
searched-for capability.

The terminfo char array is 3.3K - more better than before.
2022-01-13 13:42:12 +01:00
Daniel Eklöf
7258e0b005
doc: ctlseq: add XTGETTCAP 2022-01-13 13:42:11 +01:00
Daniel Eklöf
44aad0941f
dcs: xtgettcap: handle boolean capabilities
Reply with DCS 1 + r <cap> ST
2022-01-13 13:42:11 +01:00
Daniel Eklöf
7feab6092c
scripts: generate-builtin-terminfo: add custom capability ‘Co’
This is a “special feature”, similar to “TN” and “RGB”:

   Co for termcap colors (or colors for terminfo colors)
2022-01-13 13:42:11 +01:00
Daniel Eklöf
3fa6bec912
dcs: implement XTGETTCAP
We emit one DCS reply for each queried capability (like Kitty, but
unlike XTerm), as this allows us to a) not skip any capabilities in
the query, and b) reply with correct success/fail flag for each
capability.

We do not batch the entire reply - as soon as the reply for _one_
capability is done, we write it to the PTY.

Closes #846
2022-01-13 13:42:11 +01:00
Daniel Eklöf
1a91cbecc7
uri: move hex2nibble() to util.h 2022-01-13 13:42:11 +01:00
Daniel Eklöf
b8fc56ecb4
script: add generate-builtin-terminfo.py
This script parses a terminfo source file and generates a C header
file with a static struct containing terminfo names and their values.

The table is sorted on the capability names
2022-01-13 13:42:11 +01:00
Daniel Eklöf
467e4f2ef8
test: config: tweak.grapheme-shaping can’t be set when grapheme-clustering has been disabled 2022-01-13 12:26:20 +01:00
Daniel Eklöf
9bd9f55d5a
test: config: test ‘tweak’ section 2022-01-13 12:16:57 +01:00
Daniel Eklöf
891fce6236
config: convert tweak.render_timer to an enum 2022-01-13 12:08:20 +01:00
Daniel Eklöf
69ec74a605
Merge branch 'bad-locale' 2022-01-13 11:48:03 +01:00
Daniel Eklöf
d85feb02ed
main: log locale errors (in addition to adding a user notification) 2022-01-13 11:47:43 +01:00
Daniel Eklöf
2bc77ebf09
main: display warning only, when we succeed in enabling a fallback locale 2022-01-13 11:47:42 +01:00
Daniel Eklöf
820b15b844
changelog: improved handling of incompatible locales 2022-01-13 11:47:42 +01:00
Daniel Eklöf
827bfef550
main: try to force an UTF-8 locale if user’s locale isn’t UTF-8 2022-01-13 11:47:42 +01:00
Daniel Eklöf
9873d2732f
main: present invalid locale errors as a user-notification
Foot does not support running under non-UTF8 locales. If we detect a
non-UTF8 locale, we log this and exit with an error.

However, it appears a fairly common situation is this:

user (knowingly or unknowingly) only configures his/hers locale in
e.g. the shell RC files. These aren’t sourced when the compositor is
started via a display manager.

Thus, compositor key binds will fail to launch, and the user typically
has no way of seeing foot’s output.

So, the user proceeds to start another terminal, and from that one
tries launching foot. And it works... (because the shell in the other
terminal sourced the locale configuration).

User is left confused and often don’t know how to debug.

This patch is somewhat hackish; in addition to logging the locale
error, it also pushes a user notification. For this to be visible, we
need to actually start a terminal window.

So, we ignore the configured shell, and we ignore any custom command
line, and instead spawns “/bin/sh -c ‘’”. This allows us to get
something running (that hopefully doesn’t produce too much output we
can’t decode due to the non-UTF8 locale). But, it will exit
immediately. So we also set the --hold flag.

This works, and may be a good enough “solution”. However, it only
works for standalone foot instances, not footclients.
2022-01-13 11:47:33 +01:00
Daniel Eklöf
7bb8d48b75
Merge branch 'improve-mouse-button-multi-click'
Closes #883
2022-01-13 11:22:50 +01:00
Daniel Eklöf
e853c7139e
input: reset mouse button click counter when mouse moves
As described in #883, creating a block selection (with ctrl+BTN_LEFT),
then *quickly* (within 300ms from) creating a new one, will, in fact,
_not_ create a new block selection, but a ‘select-word-whitespace’
selection (ctrl+BTN_LEFT-2).

A similar effect can be seen with plain selections (BTN_LEFT). Click
and drag to make a selection, but *release*, and make a new selection
within 300ms from the initial button press, and the new selection is
suddenly a word-based selection.

This happens because triggering a binding does *not* reset the button
click counter.

So, shouldn’t we just do that?

No, because we rely on this behavior to handle single-, double- and
triple-click actions. If we were to reset the button click handler,
then we’d have to instead delay triggering the first action with
300ms, which would make things appear laggy. If we don’t do this, it
would be impossible to double- and triple-click, since the
single-click action would keep resetting the click counter.

This patch takes a slightly different approach; we reset the click
counter when the mouse has moved “too much”. For now, “too much” is
when the cursor has moved to a different cell.

This way, single-, double- and triple-clicks continue to work as
before. But, creating actual selections, and then quickly releasing
and starting a new selection produces the expected results.

Closes #883
2022-01-13 11:22:01 +01:00
Daniel Eklöf
29c31054a1
input: reset view when pasting from primary
We’re already doing this for keyboard input, and regular clipboard
pastes.
2022-01-11 20:26:49 +01:00
Daniel Eklöf
e37edba387
Merge branch 'wl-output-version-4'
Closes #876
2022-01-06 21:25:06 +01:00
Daniel Eklöf
ccf9c0fe29
wayland: don’t try to bind wl_output version 4 unconditionally
The compositor may offer version 4, while we’re still linked against
an old libwayland that does not implement version 4.

While we properly #ifdef the callbacks from version 4, we were still
requesting version 4 (if offered by the compositor), even when
compiled against a too old libwayland.

Closes #876
2022-01-06 20:00:00 +01:00
Daniel Eklöf
99ebff5a51
Merge branch 'argc-is-zero' 2022-01-02 09:15:52 +01:00
Daniel Eklöf
0ccdb27520
changelog: fixed failing to launch when exec(3):ed with an empty argv 2022-01-01 21:17:36 +01:00
Daniel Eklöf
9f26b250bb
foot{,client}: handle argc == 0
Our getopt_long() based argument parser would (correctly) break out of
the while loop immediately. However, we would then proceed and
decrement ‘argc’ by 1, resulting in it being -1.

This was then passed to the terminal constructor, which passed it on
to the client application fork+exec logic. That finally resulted in an
exec(3) failure:

   err: slave.c:339: SHELL=/bin/zsh: failed to execute: No such file or directory
   err: fdm.c:215: no such FD: 7
  info: main.c:604: goodbye
2022-01-01 21:17:32 +01:00
Daniel Eklöf
b83daaac46
doc: ctlseq: add missing ‘[‘ to a couple of CSI sequences 2022-01-01 14:22:48 +01:00
Daniel Eklöf
8ffcd425e7
doc: ctlseq: kitty kbd: swap name/from 2022-01-01 14:15:21 +01:00
Daniel Eklöf
9af4b95234
doc: ctlseq: kitty keyboard protocol 2022-01-01 14:14:17 +01:00
Daniel Eklöf
2cae7d18b8
doc: ctlseq: private mode 1016 - SGR-Pixels 2022-01-01 14:01:15 +01:00
Daniel Eklöf
92dfab3bd1
Merge branch 'sgr-pixels'
Closes #762
2022-01-01 11:03:22 +01:00
Autumn Lamonte
d72ba4a062
SGR-Pixels mouse mode, closes #762 2022-01-01 11:02:30 +01:00
Daniel Eklöf
c0aa414404
test: config: colors: test ‘256’ is an invalid key 2021-12-30 21:49:08 +01:00
Daniel Eklöf
b7976e9565
test: config: test colors section 2021-12-29 19:54:21 +01:00
Daniel Eklöf
3583d1cd98
test: config: csd: test color options 2021-12-29 19:43:11 +01:00
Daniel Eklöf
7938b9e811
test: config: add test_color() utility function 2021-12-29 19:43:01 +01:00
Daniel Eklöf
a780a8b66f
test: config: test csd section 2021-12-29 19:33:18 +01:00