Commit graph

321 commits

Author SHA1 Message Date
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
Daniel Eklöf
958ef9dd3b
config: rename str_to_spawn_template() -> value_to_spawn_template() 2021-11-13 11:04:27 +01:00
Daniel Eklöf
70aec2068a
config: rename str_to_fonts() -> value_to_fonts() 2021-11-13 11:04:27 +01:00
Daniel Eklöf
4aa3d1d5f8
config: rename str_to_wchars() -> value_to_wchars() 2021-11-13 11:04:27 +01:00
Daniel Eklöf
5fb86859df
config: rename str_to_double() -> value_to_double()
* str_to_double() -> value_to_double()
* str_to_pt_or_px() -> value_to_pt_or_px()
2021-11-13 11:04:27 +01:00
Daniel Eklöf
922490217e
config: rename str_to_ulong() -> value_to_ulong()
* str_to_ulong() -> value_to_ulong()
* str_to_color() -> value_to_color()
* str_to_two_colors() -> value_to_two_colors()
2021-11-13 11:04:27 +01:00
Daniel Eklöf
92e08a04ed
config: value_to_bool(): fixup 2021-11-13 11:04:27 +01:00
Daniel Eklöf
5bb2973c39
config: rename str_to_bool() -> value_to_bool()
Change argument to a ‘struct context’ pointer
2021-11-13 11:04:26 +01:00
Daniel Eklöf
82a7885324
config: pass aggregated struct to top-level section handlers 2021-11-13 11:04:26 +01:00
Daniel Eklöf
347e79f8a1
config: format all (well, most) error messages in the same way
path:lineno: [section].key: value: message desribing what’s wrong with value
2021-10-31 20:58:17 +01:00
Daniel Eklöf
86cc0e0c95
config: use "[section].key" syntax when logging errors 2021-10-31 20:25:54 +01:00
Daniel Eklöf
b0ba58b841
config: improve error messages for invalid section keys 2021-10-31 20:23:35 +01:00
Daniel Eklöf
5e4de143de
csd: add support for a visible border
When we’re using CSDs, we’ve up until now rendered a 5px invisible
border. This border handles interactive resizing. I.e. hovering it
changes the mouse cursor, and mouse button events are used to start an
interactive resize.

This patch makes it possible to color part of (or the entire) border,
with a configurable color.

To facilitate this, two new options have been added:

* csd.border-width
* csd.border-color

border-width defaults to 0, resulting in the look we’re used to.

border-color defaults to the title bar color. If the title bar color
hasn’t been set, it defaults to the default foreground color (just
like the title bar color does).

This means that, setting border-width but not border-color, results in
a border that blends with the title bar.
2021-10-27 18:32:28 +02:00
Daniel Eklöf
bcea929c94
config: add [key-bindings].noop action
Key combinations assigned to this action will not be sent to the
application.

Closes #765
2021-10-27 17:07:26 +02:00
Daniel Eklöf
d60e303c33
config: error out on invalid grapheme-width-method values 2021-10-21 16:17:41 +02:00
Daniel Eklöf
37f9f54840
config: enable grapheme shaping by default
This changes the default value of tweak.grapheme-shaping to “yes”,
thus enabling grapheme shaping by default.

It also changes the default value of tweak.grapheme-width-method to
“wcswidth”, for maximum compatibility with terminal applications.
2021-10-13 17:42:40 +02:00
feeptr@codeberg.org
650cfa18ef config, render: scrollback indicator: allow configuring scrollback indicator colors 2021-10-09 16:59:52 -04:00
Mitja Horvat
729f7466ae notify: add the notify-focus-inhibit config option
foot doesn't show desktop notifications (via OSC777) if the current
terminal has keyboard focus.

This is probably a sane default, but there are use cases where showing
a notification regardless of the focus status may be desired. For
example, a completion notification of a long running task inside a
non-focused tmux window.

This PR adds the notify-focus-inhibit option which can be used to
disable inhibition of notifications when the window has focus.

The default value is `yes`, which retains the old behavior.
2021-10-06 23:33:17 +02:00
Craig Barnes
9361e7c072 config: add comments to default_color_table[] about color channel values 2021-09-25 22:01:03 +01:00
Craig Barnes
a669ba0bf6 config: simplify initialization of color table in config_load() 2021-09-25 02:56:19 +01:00
Daniel Eklöf
73b488a2b2
config: codespell: setting has only two ‘t’ 2021-08-31 20:01:35 +02:00