Commit graph

366 commits

Author SHA1 Message Date
Daniel Eklöf
755f96321a
config: add a new ‘environment’ section
This section allows the user to define custom environment variables to
be set in the child process:

  [environment]
  name=value
2022-06-13 11:55:23 +02:00
Daniel Eklöf
bc7214cd88
config: use $HOME instead of getpwuid() to retrieve users’s home dir
When searching for foot.ini, use $HOME instead of getpwuid() to
retrieve the user’s home directory.
2022-05-25 17:02:41 +02:00
Daniel Eklöf
aa4c7c5a30
config: add ctrl+shift+v and XF86 paste to SEARCH_CLIPBOARD_PASTE
We now bind ctrl+v, ctrl+shift+v, ctrl+y and XF86Paste to pasting from
the clipboard into the scrollback search buffer.

Why all these? Because we can, and because all are common shortcuts
for pasting:

* ctrl+v: “normal” apps use this by default
* ctrl+shift+v: used in terminals (including foot)
* ctrl+y: Emacs
* XF86Paste: special keyboard key, for pasting
2022-04-26 20:37:30 +02:00
Daniel Eklöf
90a2ca966f
key-binding: new API, for handling sets of key bindings
Up until now, our Wayland seats have been tracking key bindings. This
makes sense, since the seat’s keymap determines how the key bindings
are resolved.

However, tying bindings to the seat/keymap alone isn’t enough, since
we also depend on the current configuration (i.e. user settings) when
resolving a key binding.

This means configurations that doesn’t match the wayland object’s
configuration, currently don’t resolve key bindings correctly. This
applies to footclients where the user has overridden key bindings on
the command line (e.g. --override key-bindings.foo=bar).

Thus, to correctly resolve key bindings, each set of key bindings must
be tied *both* to a seat/keymap, *and* a configuration.

This patch introduces a key-binding manager, with an API to
add/remove/lookup, and load/unload keymaps from sets of key bindings.

In the API, sets are tied to a seat and terminal instance, since this
makes the most sense (we need to instantiate, or incref a set whenever
a new terminal instance is created). Internally, the set is tied to a
seat and the terminal’s configuration.

Sets are *added* when a new seat is added, and when a new terminal
instance is created. Since there can only be one instance of each
seat, sets are always removed when a seat is removed.

Terminals on the other hand can re-use the same configuration (and
typically do). Thus, sets ref-count the configuration. In other words,
when instantiating a new terminal, we may not have to instantiate a
new set of key bindings, but can often be incref:ed instead.

Whenever the keymap changes on a seat, all key bindings sets
associated with that seat reloads (re-resolves) their key bindings.

Closes #931
2022-04-17 15:39:51 +02:00
Daniel Eklöf
501a9fbb5e
url-mode: add a key binding that enables “persistent” URL mode
This is an alternative to ‘show-urls-launch’, where we stay in URL
mode after activating an URL.

Closes #964
2022-04-17 11:24:27 +02:00
Daniel Eklöf
fbcebd4f1c
config: add [csd].hide-when-maximized=yes|no
When enabled, the CSD titlebar will be hidden when the window is
maximized.

Closes #1019
2022-04-16 11:45:50 +02:00
Merlin Büge
5539eac590
fix some small typos 2022-04-13 09:41:10 +02:00
Daniel Eklöf
99db7aa7cf
config: config_free(): pass conf struct by pointer, not by-value 2022-04-12 15:21:43 +02:00
Daniel Eklöf
06d7432af3
config: simplify lookup of foot.ini
The old, complex, way of using a dynamic list to hold each path
component made _some_ sense before, when we needed to support both
~/.config/foot.ini and ~/.config/foot/foot.ini.

But now, it just over complicates things.
2022-04-12 15:21:11 +02:00
Daniel Eklöf
c7dd30742a
config: use fallback when XDG_CONFIG_{HOME,DIRS} is set, but empty 2022-04-07 13:06:01 +02:00
Daniel Eklöf
20608c987b
config: fallback to /etc/xdg if XDG_CONFIG_DIRS is unset
Closes #1008
2022-04-07 13:06:01 +02:00
jvoisin
58a1ffe724
config: add tweak option to allow disabling sixels
Closes #950
2022-04-06 19:25:43 +02: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
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
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
757768dbe5
config: rename csd.color.close -> quit
This fixes a compilation error on FreeBSD:

../../foot/render.c:2055:45: error: no member named 'epoll_shim_close' in 'struct config::(anonymous at ../../foot/config.h:254:9)'
        conf_color = &term->conf->csd.color.close;
                      ~~~~~~~~~~~~~~~~~~~~~ ^

/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:8:15:
note: expanded from macro 'close': #define close epoll_shim_close
2022-02-09 17:51:05 +01:00
Daniel Eklöf
e5c5cd5478
config: ‘pipe’ is now optional ‘aux’ data in the key-binding struct
This allows us to add helper functions that e.g. compare bindings’ aux
data in a generic way.
2022-02-09 17:51:05 +01:00
Daniel Eklöf
9814d96206
config: rename enum config_key_binding_type -> key_binding_type 2022-02-09 17:51:05 +01:00
Daniel Eklöf
b0e9ee2137
config: font->name may be NULL
If it is, fallback to the font pattern instead, like we used to do
before fcft-3.
2022-02-06 12:07:42 +01:00
Daniel Eklöf
e0227266ca
fcft: adapt to API changes in fcft-3.x
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -> fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
2022-02-05 17:00:54 +01:00
Daniel Eklöf
343f2c51a4
config: s/of the form/on the form/ 2022-02-05 16:59:42 +01:00
Pranjal Kole
06fdebbbcb config: use getline idiomatically
getline(3) contains an example program at the end, showing its usage.

A few other changes have also been made.
2022-02-05 13:48:08 +05:30
Pranjal Kole
65b5469e86 config: don't pass null strings to *printf()
musl and glibc's *printf() convert NULL strings to "(null)" [0][1], but
this is undefined behaviour.

context.value has to be set to two backspaces, so that the extra colon
is removed. context.key is set to one backspace, so that the extra dot
is removed. context.section is now set to "main" by default, so it is
never NULL.

[0]: https://git.musl-libc.org/cgit/musl/tree/src/stdio/vfprintf.c#n593
[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf-internal.c;hb=HEAD#l1011
2022-02-05 11:50:41 +05:30
Mark Stosberg
6d76bb0f32 config: support Copy and Paste keycodes by default
These work as expected and don't interfere with anything else.

They are useful on the increasing number of keyboards with custom
firmware. The keycodes enable using the same key combination
for terminals as other apps.

For example: by holding down a layer-switching key with a thumb, the
Copy and Paste key codes can be assigned to the C and V keys on a secondary
layer, making for a natural universal copy/paste key combination.
2022-01-25 15:27:58 -05:00
Daniel Eklöf
891fce6236
config: convert tweak.render_timer to an enum 2022-01-13 12:08:20 +01:00
Simon Ser
3f34ec7470 Add irc:// to default URL schemes 2021-12-27 12:10:44 +01:00
Daniel Eklöf
a3dc0d287d
config: update most parse_section_*() functions to return in each if-branch 2021-12-25 23:51:02 +01:00
Daniel Eklöf
8771bb20bf
config: scrollback: add missing return for ‘lines’
The missing return meant failures were not reported correctly.
2021-12-25 23:48:05 +01:00
Daniel Eklöf
521bd84a99
config: csd.border_width now always reflects the full/total width 2021-12-22 20:21:46 +01:00
Daniel Eklöf
c076f03dc4
config: error out on empty key- or mouse binding
Closes #851
2021-12-18 20:39:08 +01:00
Daniel Eklöf
6911a50df7
config: NOINLINE modifiers_to_str() 2021-12-11 20:59:08 +01:00
Daniel Eklöf
2a02ba77a1
config: resolve collisions: argv_compare() returns -1,0,+1, not a bool 2021-12-11 20:19:12 +01:00
Daniel Eklöf
17250ec393
config: resolve collisions: return ‘false’ on failure 2021-12-11 20:19:12 +01:00
Daniel Eklöf
6fa09d24e5
config: use “(default)” as path in log message, if path is NULL 2021-12-11 20:19:12 +01:00
Daniel Eklöf
3512a7febf
config: remove unneeded function prototype 2021-12-11 20:19:11 +01:00
Daniel Eklöf
f6a591b80a
config: unify key- and mouse bindings
With this patch, key- and mouse-bindings structs (the non-layout
specific ones) are unified into a single struct.

The logic that parses, and manages, the key- and mouse binding lists
are almost identical. The *only* difference between a key- and a mouse
binding is that key bindings have an XKB symbol, and mouse bindings a
button and click-count.

The new, unified, struct uses a union around these, and all functions
that need to know which members to use/operate on now takes a ‘type’
parameter.
2021-12-11 20:19:11 +01:00
Daniel Eklöf
4c50c44cf7
config: do mouse binding collision detection after loading the conf 2021-12-11 20:19:11 +01:00
Daniel Eklöf
bb4b4ae43d
config: value_to_key_combos(): reset modifiers in binding 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
feeptr@codeberg.org
a15c6025ec config: improve error reporting when selection-override-modifiers conflict with mouse bindings 2021-12-04 01:33:25 +00:00
feeptr@codeberg.org
9e111118d6 config: move button_map out of value_to_mouse_combos for reuse
this mapping is only available here or in libevdev (libevdev_event_code_get_name) and it's simpler to factor it out here
2021-12-02 18:47:43 -05:00
feeptr@codeberg.org
b52cd67467 config, doc, changelog: move selection-override-modifiers to [mouse-bindings] and validate other case
specifically, check for conflicts both when mouse bindings are set and when the selection-override-modifiers setting itself is set
2021-12-02 18:47:41 -05:00
feeptr@codeberg.org
46cadee80f config: parse 'none' as empty modifiers value 2021-12-02 18:47:07 -05:00
feeptr@codeberg.org
a4d53bdf88 config, input: allow configuring select-override modifiers 2021-12-02 18:44:08 -05: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
cdb2d90b89
config: argv_compare(): change parameters to ‘struct argv *’
Instead of passing raw char** pointers to argv_compare(), pass
pointers to ‘struct argv’.

This lets argv_compare() handle both argv’s being NULL, or one of them
being NULL. That is, the caller no longer needs to check that both
argv’s are non-NULL before calling argv_compare().

Furthermore, update has_key_binding_collisions() to require the pipe
argv to match, in addition to matching the ‘action’, when allowing a
key collision.
2021-11-21 18:04:36 +01:00
Daniel Eklöf
9174e6d79a
config: pipe_argv_from_value(): plug memory leak
When parsing a key binding with a pipe-argv, we failed to free the
argv vector (or to be precise, the strdup:ed entries in the array)
when failing to parse the remainder of the binding.
2021-11-21 17:51:46 +01:00
Daniel Eklöf
106e14391f
Merge branch 'fix-809'
Closes #809
2021-11-21 17:45:17 +01:00
Craig Barnes
c683116f8a Merge branch 'remove-unreachable' 2021-11-21 10:44:24 +00:00