Commit graph

242 commits

Author SHA1 Message Date
Daniel Eklöf
f9a13e2eec
config: notify: change default value to use ${app-id}
Make the default value of ‘notify’ use ${app-id} for icon and
application name.
2021-05-27 11:41:57 +02:00
Craig Barnes
6eb6668c3c config: bind ctrl+c to "cancel" in search/url mode by default
Closes #544
2021-05-25 16:51:07 +01:00
Daniel Eklöf
121ea39942
config: url.protocols: make it comma separated, for consistency 2021-05-22 14:50:47 +02:00
Daniel Eklöf
53516aceec
config: add url.protocols
This makes the protocols recognized by auto-detected URLs
configurable.

Closes #531
2021-05-22 14:50:47 +02:00
Daniel Eklöf
0f483d65ce
config: move url-mode related options to a dedicated section, ‘url’ 2021-05-22 14:50:47 +02:00
Daniel Eklöf
1b5c849994
config: add cursor.underline-thickness
Works in pretty much the same way as ‘beam-thickness’, except that the
default value is “the font’s underline thickness”.

This means, that when unset, the cursor underline thickness scales
with the font size.

But, when explicitly set, either to a point size value, or a pixel
size, it remains fixed at that size.

Closes #524
2021-05-22 14:49:25 +02:00
Daniel Eklöf
b75bd6507a
notifications: use \e[22m to disable bold
\e[21m was previously used to disable bold. That changed a while ago,
to align foot with the majority of other terminal emulators.

\e[22m now disables both bold and dim.

When this change was done, the user notifications were not updated,
meaning the ‘message’ part was always in bold. This was never the
intended behavior.
2021-05-20 17:51:04 +02:00
Daniel Eklöf
e7109d6b77
config: add tweak.box-drawing-solid-shades=yes|no
When enabled, shades are rendered as solid blocks, using a darker
variant of the current foreground color.

When disabled, shades are instead rendered in a checker box pattern,
using the foreground color unmodified.

Default is enabled.
2021-05-17 17:58:30 +02:00
Craig Barnes
758a36dac1 Merge branch 'simplify-parse_section_colors' 2021-05-08 18:30:56 +01:00
Craig Barnes
db4b206409 config: simplify parsing of "scaling-filter" values slightly 2021-05-08 16:50:49 +01:00
Craig Barnes
9c8c99c9e0 config: simplify parse_section_colors() 2021-05-08 14:56:11 +01:00
Daniel Eklöf
df6c6f5bd6
Merge branch 'config-code-size' 2021-05-08 13:58:25 +02:00
Ryan Farley
3b089b4203 configure full color palette in foot.ini
Allow the use of numeric keys in [colors] to configure the full set of
256 colors in the palette. Fixes #489
2021-05-08 06:40:00 -05:00
Daniel Eklöf
ba2c3606bf
config: avoid tll() code expansion when generating default bindings
tll_push_back() is a macro that results in quite a lot of
instructions. Expanding this macro explicitly in many places thus
causes code explosion.

This is what happened in when we generate the default key/mouse
bindings.

Fix by calling tll_push_back() in a no-inline function.

Reduces code size with ~4-5K
2021-05-07 17:21:18 +02:00
Daniel Eklöf
449ac7c361
config: don’t inline str_to_*() functions 2021-05-07 17:18:27 +02:00
Daniel Eklöf
0b97740bd0
config: implement LOG_AND_NOTIFY_* macros in terms of no-inline functions
Reduces code size by quite a lot:

From:

    section               size   addr
    .text                37857      0
    ...
    Total                45169

To:

    section               size   addr
    .text                31681      0
    ...
    Total                38993

LTO release build goes from 500K -> 492K
2021-05-07 16:52:56 +02:00
Ryan Farley
5df981d23f consistent booleans in config, reset legacy bell 2021-05-07 07:16:48 -05:00
Ryan Farley
b3117f75d8 clearly mark bell as a section 2021-05-07 04:41:50 -05:00
Ryan Farley
dc9751cbfe style, consistent bool names, deprecate old config 2021-05-07 04:40:07 -05:00
Ryan Farley
5d71ccc174 enhanced bell configuration
Add a separate section for bell configuration, with a bell-specific
command option and a setting to allow that command to run without regard
to keyboard focus (for those of us who enjoy being beeped at at all
times, for example). The actions are also no longer mutually exclusive;
this is primarily anticipating urgency support which cannot be
replicated outside the process (in server mode anyway) and would thus be
complementary to any notification or arbitrary command.
2021-05-07 03:12:27 -05:00
Daniel Eklöf
a720188b42
config: fix color cube generation
Closes #479
2021-05-06 12:39:30 +02:00
Daniel Eklöf
7ce767ab87
config: add ‘beam-thickness’ option
* Rename cursor.style value ‘bar’ to ‘beam’. ‘bar’ remains recognized,
  but should eventually be deprecated and then removed.
* Add ‘cursor.beam-thickness’ option, a pt-or-px value specifying the
  thickness of the beam cursor. Defaults to 1.5pt.
* Rename (and export) pt_or_px_as_pixels() to
  term_pt_or_px_as_pixels()
* Change term_pt_or_px_as_pixels() to round point values instead of
  truncating them.
2021-04-30 20:36:16 +02:00
Daniel Eklöf
cdfc864cf0
config: bold-text-in-bright: add ‘palette-based’ as a special value
When ‘bold-text-in-bright’ is set ‘to palette-based’, colors matching
one of the 8 regular palette colors are brightened by using the
corresponding bright palette color.

Other colors, or all colors if ‘bold-text-in-bright’ is set to
‘yes|true’, are brightened by increasing the luminance.
2021-04-17 22:00:48 +02:00
Daniel Eklöf
0713ab45c6
config: add box-drawings-uses-font-glyphs=no|yes option
When disabled, we render box drawing characters ourselves. This is the
default.

When enabled, we instead use font glyphs. I.e. no special treatment.

Closes #430
2021-04-09 23:21:20 +02:00
Daniel Eklöf
936063271f
config/terminal: refactor: remove “default_*” color members from terminal struct
Access the original colors in the configuration instead.
2021-04-07 08:07:43 +02:00
Daniel Eklöf
65dead29e0
config: make {search,url}_binding_action_map[] function local
This ensures we don’t accidentally reference them from places we
shouldn’t.

Unfortunately, binding_action_map[] (for “normal” key bindings) cannot
easily be made function local since it is used when parsing both key-
and mouse bindings (i.e. it’s used in multiple functions).
2021-04-05 14:50:21 +02:00
Daniel Eklöf
285e3c4aa2
config: parse_key_binding_section(): use provided action-map
Don’t call has_key_binding_collisions() with ‘binding_action_map’
unconditionally; use the provided ‘action_map’ instead.

This fixes wrong error messages for key combo collisions in key
binding sections other than the regular “key-bindings”.
2021-04-05 14:36:22 +02:00
Daniel Eklöf
11f2c85acf
config: open_config(): remove unused argument ‘conf’ 2021-03-16 09:54:32 +01:00
Daniel Eklöf
a5b554761a
input: repair key combos containing both explicit modifier and shifted symbol
If a user-provided key combo contains both an explicit modifier, and
the shifted symbol it produces, replace the symbol with its un-shifted
version.

Example: Control+Shift+U contains both ‘Shift’, and ‘U’, where ‘Shift’
is the modifier that shifts ‘u’ to ‘U’.

Such modifiers are “consumed”, i.e. filtered out, when matching key
combos. As such, Control+Shift+U will never trigger since we’ll never
be able to match the consumed modifier ‘Shift’.

The above combo can be written in two ways:

- Control+U
- Control+Shift+u

To be able to detect that Control+Shift+U is an invalid combination,
we need to check all *shifted* symbols for all key *codes*.

Once we’ve detected a shifted symbol (and where it differs from the
un-shifted symbol), we loop all modifier sets that produce the shift
level where our shifted symbol is. For each such set, check if it
intersects with the user-provided key combo’s modifier set.

If there is an intersection, it means the user provided a key combo
containing a modifier and symbol, such that the modifier is consumed
when the symbol is produced.

In this case, we replace the symbol with its un-shifted version.
2021-03-04 09:43:44 +01:00
Daniel Eklöf
1b4d9eade0
config: parse_key_combos: lower case manually, instead of calling tolower()
tolower() is locale dependent, something we do not want in this case.
2021-03-04 09:43:43 +01:00
Daniel Eklöf
cfa82bc920
config: fix default key binding for extend-to-next-whitespace
Bindings now use lower-cased keys
2021-03-04 09:43:43 +01:00
Daniel Eklöf
5e64e06a55
input: rewrite of how we match foot’s own key bindings
Bindings are matched in one out of three ways:

* By translated (by XKB) symbols
* By untranslated symbols
* By raw key codes

A translated symbol is affected by pressed modifiers, some of which
can be “consumed”. Consumed modifiers to not partake in the comparison
with the binding’s modifiers. In this mode, ctrl+shift+2 maps to
ctrl+@ on a US layout.

Untranslated symbols, or un-shifted symbols refer to the “base” symbol
of the pressed key, i.e. it’s unaffected by modifiers. In this mode,
consumed modifiers *do* partake in the comparison with the binding’s
modifiers, and ctrl+shift+2 maps to ctrl+shift+2 on a US layout.

More examples: ctrl+shift+u maps to ctrl+U in the translated lookup,
while ctrl+shift+u maps to ctrl+shift+u in the untranslated lookup.

Finally, we also match raw key codes. This allows our bindings to work
using the same physical keys when the user switches between latin and
non-latin layouts.

This means key bindings in foot.ini *must* not include both +shift+
and a *shifted* key. I.e. ctrl+shift+U is not a valid combo as it
cannot be triggered. Unfortunately, this was how you were supposed to
write bindings up until now... so, we try to detect such bindings, log
a deprecation warning and then “fix” the binding for the user.

When specifying bindings in foot.ini, both ctrl+U and ctrl+shift+u are
valid, and will work. The latter is preferred though, since we cannot
detect the raw key code for the former variant. Personally, I also
prefer the latter one because it is more explicit; it’s more obvious
which keys are involved.

However, in some cases it makes more sense to use the other
variant. Typically for non-letter combos.
2021-03-04 09:43:43 +01:00
L3MON4D3
093df837ca Fix typo. 2021-03-01 13:44:46 +01:00
Chloe Kudryavtsev
80b95eeb7e
config: reuse HAVE_TERMINFO via DEFAULT_TERM
add detection in --help output
also make it more easily accessible for other locations to change
2021-02-26 15:15:05 +01:00
Daniel Eklöf
3d7207f9c5
Merge branch 'rename-_errno' 2021-02-22 09:28:53 +01:00
Daniel Eklöf
555f751f94
errno: don’t use ‘_errno’ as a variable name; _ are reserved for use as identifiers 2021-02-21 20:33:07 +01:00
Daniel Eklöf
21a355f38a
config: typo: osc8-underline=always means ALWAYS 2021-02-21 20:15:32 +01:00
Daniel Eklöf
35779ec4e5
config: osc8-underline: default to ‘url-mode’ 2021-02-21 20:15:32 +01:00
Daniel Eklöf
2074f8b656
urls: OSC-8 URLs can now optionally be underlined outside of url-mode
This patch adds a new configuration option,
‘osc8-underline=url-mode|always’.

When set to ‘url-mode’, OSC-8 URLs are only
highlighted (i.e. underlined) in url-mode, just like auto-detected
URLs.

When set to ‘always’, they are always underlined, regardless of mode,
and regardless of their other attributes.

This is implemented by tagging collected URLs with a boolean,
instructing urls_render() and urls_reset() whether they should update
the cells’ ‘url’ attribute or not.

The OSC-8 collecter sets this based on the value of ‘osc8-underline’.

Finally, when closing an OSC-8 URL, the cells are immediately tagged
with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
2021-02-21 20:15:32 +01:00
Daniel Eklöf
4ff5154cb8
config: change default key binding for toggle-url-visible to ‘t’ 2021-02-21 20:15:31 +01:00
Daniel Eklöf
06a9ffa763
urls: add key binding that toggles whether URLs are displayed on jump-label
By default, the URL isn’t shown on the jump-label. For auto-detect
URLs, doing so is virtually always useless, as the URL is already
visible in the grid.

For OSC-8 URLs however, the URL is often _not_ visible in the
grid. Many times, seeing the URL is still not needed (if you’re doing
‘ls --hyperlink’, you already know what the URIs are).

But it is still useful to have a way to show the URLs.

This patch adds a new key binding action that can be used in url-mode
to toggle the URL on and off in the jump label.

It is bound to ctrl+t by default.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
7bcab01068
config: add jump-label-letters option 2021-02-13 11:42:40 +01:00
Daniel Eklöf
94266b99d7
config: refactor: add str_to_wchars(), use it when parsing word-delimiters 2021-02-13 11:42:21 +01:00
Craig Barnes
1ec5684438 Convert some uses of xassert(false) to BUG("some error message") 2021-02-09 13:52:33 +00:00
Daniel Eklöf
79e054faff
Merge branch 'refactor-key-bindings' 2021-02-08 18:57:17 +01:00
Daniel Eklöf
4bad85b593
misc: when free:ing tll lists, prefer tll_remove() over tll_free()
In many places we have the following pattern:

  tll_foreach(list, it)
     free(it->item.thing);
  tll_free(list);

Since all tll functions are macros, and thus inlined, and since
tll_free in itself expands to a tll_foreach(), the above pattern
expands to more native code than necessary.

This is somewhat smaller:

  tll_foreach(list, it) {
      free(it->item.thing);
      tll_remove(list, it);
  }
2021-02-08 10:09:59 +01:00
Daniel Eklöf
03bac9dada
key-bindings: refactor: use a single type for all key bindings
Up until now, the various key binding modes (“normal”, “search” and
“url”) have used their own struct definitions for their key bindings.

The only reason for this was to have a properly typed “action” (using
the appropriate “action” enum).

This caused lots of duplicated code. This patch refactors this to use
a single struct definition for the “unparsed” key bindings handled by
the configuration, and another single definition for “parsed” bindings
used while handling input.

This allows us to implement configuration parsing, keymap translation
and so on using one set of functions, regardless of key binding mode.
2021-02-08 10:09:14 +01:00
Daniel Eklöf
e9c3d03837
config: add colors.jump_labels and colors.urls
* colors.jump_labels configures the foreground and background colors
  used when rendering URL jump labels. Defaults to “regular0
  regular3” (i.e. black on yellow).

* colors.urls configures the color to use when highlighting URLs in
  URL mode. Note that we aren’t currently doing any
  highlighting... Defaults to regular3 (i.e. yellow).
2021-02-07 16:33:33 +01:00
Daniel Eklöf
fcbb5a0bf7
config: use a packed bitfield for “use custom color” flags 2021-02-07 16:33:33 +01:00
Daniel Eklöf
93181649b3
config: add show-urls-copy action
This works just like show-urls-launch, except that instead of opening
the URL (typically using xdg-open), it is placed in the clipboard when
activated.
2021-02-07 16:33:32 +01:00