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.
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.
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.
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.
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.
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.
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.
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.
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.
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
* 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
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
../../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)
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.