Commit graph

341 commits

Author SHA1 Message Date
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
Daniel Eklöf
9b232e07f9
config: create a copy of the section name
The parsing context keeps a pointer to the current section name. This
is used when logging errors.

However, the pointer was into a buffer allocated by getline(). This
buffer are often re-used in the next call to getline(), or free:d.

Regardless, the section name pointer is invalid after the next call to
getline(), which meant all error messages were logging a correct
section name.
2021-11-21 10:55:57 +01:00
Arnavion
31c1b91a7c Fix parsing key-bindings config to not read past the end of the string.
pipe_argv_from_value itself stripped the cmd-to-exec from ctx->value,
so the callers should not be doing that themselves.

Fixes #809
2021-11-20 20:49:01 -08:00
Craig Barnes
e89e735995 config: use stack allocation for temporary buffer in value_to_enum()
The maximum size required for the string buffer is relatively small,
known at compile-time and not likely to ever grow beyond 512 bytes.
Therefore we may as well just use the stack.
2021-11-20 15:23:24 +00:00
Craig Barnes
0db125a125 config: fix memory leak in value_to_enum()
This could be triggered by running, for example:

    foot -o tweak.render-timer=invalid

For some reason LeakSanitizer was only detecting this leak when the
option value was invalid, even though it was occuring in either case.
2021-11-20 15:12:56 +00:00
Xiretza
877c1e6f07 config: Simplify render-timer option handling 2021-11-20 11:58:49 +01:00
Xiretza
02bb2768f1 config: Remove some "UNREACHABLE" UB footguns
Every branch of these long if/else if/else chains returns, so the
compiler can figure out on its own that the last line is never reached.

If, for some reason, one of the branches does not return (as was the
case after 205f1f7, fixed by b22322b), this would usually result in a compiler
error ("control reaches end of non-void function"), but adding UNREACHABLE
transforms this into silent undefined behaviour.
2021-11-20 11:58:44 +01:00
Daniel Eklöf
b22322bfd1
config: letter-spacing: add missing ‘return’
The missing return caused us to fall through to the bottom of the
function, where we ended with an error message:

  [main].letter-spacing: 0: not a valid option: letter-spacing

Closes #795
2021-11-15 19:22:06 +01:00
Craig Barnes
759bc8007b user-notification: config: various small cleanups
* Rename user_notification_add() to user_notification_add_fmt()
* Add new user_notification_add() helper function
* Use xvasprintf() to replace user_notification_add_va()
* Make better use of helper functions in config.c
2021-11-14 15:16:32 +00:00
Daniel Eklöf
0686f94b18
config: remove options that were deprecated in 1.8.x
* [main].bell
* [main].jump-label-letters
* [main].url-launch
* [main].osc8-underline
2021-11-14 14:21:11 +01:00
Daniel Eklöf
c01904a2c7
config: add [colors].dim0-7
This allows you to configure custom colors to be used when colors are
being dimmed (`\E[2m`).

It is implemented by color matching (just like
bold-text-in-bright=palette-based); the color-to-be-dimmed is matched
against the current color palette.

If it matches one of the regular colors (colors 0-7), the
corresponding “dim” color will be used.

If it matches one of the bright colors (colors 8-15), the
corresponding “regular” color will be used (but *only* if the “dim”
color has been set).

Otherwise, the color is dimmed by reducing its luminance.

The default behavior, i.e. when dim0-7 hasn’t been configured, is to
dim by reducing luminance for *all* colors. I.e. we don’t do any color
matching at all. In particular, this means that dimming a bright color
will *not* result in the corresponding “regular” color.

Closes #776
2021-11-13 17:39:08 +01:00
Daniel Eklöf
c0e67e7c2f
config: scrollback.indicator.text: use value_to_wchars() 2021-11-13 12:40:59 +01:00
Daniel Eklöf
73c5754f5d
config: value_to_wchars(): free the target variable 2021-11-13 11:04:30 +01:00
Daniel Eklöf
2f0ab1da89
config: appease compiler
../../foot/config.c:154:50: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
    log_msg(log_class, LOG_MODULE, file, lineno, formatted_msg);
                                                 ^~~~~~~~~~~~~
../../foot/config.c:154:50: note: treat the string as an argument to avoid this
    log_msg(log_class, LOG_MODULE, file, lineno, formatted_msg)
2021-11-13 11:04:30 +01:00
Daniel Eklöf
d4b9ef7607
config: drop all warning logs from the tweak section 2021-11-13 11:04:30 +01:00
Daniel Eklöf
1f39c46c17
config: value_to_enum(), return conversion success/failure as a bool
Result is set through a pointer passed as an argument. Note that we
assume enums are 32-bit, and explicitly cast them to int*.

Static asserts have been added to ensure this invariant holds.
2021-11-13 11:04:29 +01:00
Daniel Eklöf
205f1f7c02
config: parse_section_main(): explicit return from each branch
Add UNREACHABLE() at the bottom
2021-11-13 11:04:29 +01:00
Daniel Eklöf
0c0a78498f
config: add value_to_dimensions() 2021-11-13 11:04:29 +01:00
Daniel Eklöf
d29c3cf7b7
config: add {str,value}_to_uint{16,32}()
This allows us to pass the final pointer directly to the conversion
functions, as well as allowing us to print outside-range errors.
2021-11-13 11:04:29 +01:00
Daniel Eklöf
3b27a665da
config: add value_to_str()
Takes a pointer to a char*, free:s it, and strdups the current value.
2021-11-13 11:04:29 +01:00
Daniel Eklöf
c2127fb2de
config: value_to_bool: return success/fail
Write boolean value to a pointer passed as argument, return conversion
success/failure
2021-11-13 11:04:29 +01:00
Daniel Eklöf
57c7fb33af
config: add value_to_enum() 2021-11-13 11:04:28 +01:00
Daniel Eklöf
328b53b166
config: let value_to_double() log errors 2021-11-13 11:04:28 +01:00
Daniel Eklöf
def2d80b0a
config: let value_to_ulong() log errors 2021-11-13 11:04:28 +01:00
Daniel Eklöf
176b85cb10
config: add LOG_CONTEXTUAL_{ERR,WARN,ERRNO}
These work like LOG_AND_NOTIFY_* but add contextual information: path
of the conf file, line number, section name, key/option name and the
value.
2021-11-13 11:04:28 +01:00
Daniel Eklöf
534e9d8bef
config: first argument to log_and_notify() is now a ‘struct context’ 2021-11-13 11:04:28 +01:00