Commit graph

309 commits

Author SHA1 Message Date
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
Daniel Eklöf
8ffc556d44
main: verify primary font is monospaced at startup
Load a couple of ASCII glyphs and check if their advance widths
matches. If not, warn the user that the font is probably not
monospaced.

This can be disabled by setting tweak.font-monospace-warn=no.

Closes #704.
2021-08-31 19:58:35 +02:00
Daniel Eklöf
7639186865
terminfo: install to $datadir/foot/terminfo by default, append to TERMINFO_DIRS
As of 2021-07-31, ncurses ships its own version of foot’s terminfo.

Since:

* It doesn’t have the non-standard Sync,Tc,setrgbf,setrgbb
  capabilities.
* It doesn’t set hs,fsl,dsl (statusbar).
* We want to be able to update our termminfo without waiting for an
  ncurses release.
* Foot should be installable and usable on Linux systems that doesn’t
  have the latest ncurses.

we still want to ship our own version. We can however not install it
to the default terminfo location (e.g. /usr/share/terminfo), since it
will collide with the ncurses provided files.

Our options are to either rename our terminfo to something else, or to
keep the name, but install our terminfo files somewhere else.

The first option would be the easy one. However, I think it makes
sense to use the same name. For example, a user that SSH’s into a
remote system that does *not* have our own version installed,
but *does* have the ncurses one, will gracefully fall back to that
one, which is better than manually having to set
e.g. TERM=xterm-256color.

Now, if we want to use the same name, we need to install it somewhere
else. But where? And how do we ensure our version is preferred over
the ncurses one?

I opted to $datadir/foot/terminfo (e.g. /usr/share/foot/terminfo) by
default. It makes it namespaced to foot (i.e. we’re not introducing a
new “standard” terminfo location), thus guaranteeing it wont collide
with ncurses.

To enable applications to find it, we export TERMINFO_DIRS. This is a
list of *additional* directories to search for terminfo files. If it’s
already defined, we *append* to it.

The nice thing with this is, if there’s no terminfo in that
location (e.g. when you SSH into a remote), the default terminfo
location is *also* searched. But only *after* having searched through
TERMINFO_DIRS.

In short: our version is preferred, but the ncurses one (or an older
version of our terminfo package!) will be used if ours cannot be
found.

To enable packagers full control over the new behavior, the existing
meson command line options have been modified, and a new option added:

-Dterminfo=disabled|enabled|auto: *build* and *install* the terminfo
files.

-Dcustom-terminfo-install-location=<path>: *where* the terminfo files
are expected to be found.

This *needs* to be set *even* if -Dterminfo=disabled. For example, if
the packaging script builds and packages the terminfo files separate
from the regular foot build. The path is *relative to $prefix*, and
defaults to $datadir/foot/terminfo.

This is the value that will be appended to TERMINFO_DIRS. Note that
you can set it to ‘no’, in which case foot will *not* set/modify
TERMINFO_DIRS. Only do this if you don’t intend to package foot’s
terminfo files at all (i.e. you plan on using the ncurses ones only).

-Ddefault-terminfo=foot. Allows overriding the default TERM
value. This should only be changed if the target platform doesn’t
support terminfo files.

Closes #671
2021-08-17 21:04:30 +02:00
Daniel Eklöf
0c03e9a766
config: add url.uri-characters
This option specifies the characters allowed in the auto-detected
URLs.

Any character not in this set constitutes an URL delimiter, and will
never be included in auto-detected URLs.

This option does not affect OSC-8 URLs.

Closes #654
2021-08-09 18:25:36 +02:00
Daniel Eklöf
8f307178df
config: include: use xasprintf() instead of two calls to snprintf() 2021-07-31 00:39:51 +02:00
Daniel Eklöf
7cfa48f369
config: include: handle get_user_home_dir() returning NULL 2021-07-30 14:57:35 +02:00
Daniel Eklöf
02f0e0d912
config: include: add support for ~-expansion
Closes #659
2021-07-30 14:57:28 +02:00
Daniel Eklöf
50f59fe575
config: add csd.font option 2021-07-24 11:02:43 +02:00
Timur Celik
91801ae55d render: Allow cells to bleed into their neighbor
This patch adds a `confined` flag to each cell to track if the last
rendered glyph bled into it's right neighbor.  To keep things simple,
bleeding into any other neighbor cell than the immediate right one is
not allowed.  This should cover most use cases.

Before rendering a row we now do a prepass and mark all cells unclean
that are affected by a bleeding neighbor.  If there are consecutive
bleeding cells, the whole group must be re-rendered even if only a
single cell has changed.

The patch also deprecates both old overflowing glyph options
*allow-overflowing-double-width-glyphs* and *pua-double-width* in favor
of a single new one named *overflowing-glyphs*.
2021-07-17 13:22:44 +02:00
Daniel Eklöf
fcb60abc13
config: add locked-title=no|yes
Closes #386
2021-07-04 17:59:40 +02:00
Daniel Eklöf
5138f02214
config: rename at-most-2 (value for grapheme-width-method) to double-width 2021-07-01 08:00:23 +02:00
Daniel Eklöf
9817e44c32
config: add tweak.grapheme-width-method=wcswidth|at-most-2 2021-07-01 07:58:06 +02:00
Daniel Eklöf
55bd3cfd62
config: add unit test for config_clone()
We’re mainly interested in seeing that we don’t leak memory, or double
free heap allocated data.

Valgrind and/or gcc/clang sanitizers are best at this, hence the very
few asserts in the test itself.
2021-06-30 21:06:21 +02:00