Commit graph

220 commits

Author SHA1 Message Date
Daniel Eklöf
1df48fcb33
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-18 20:09:10 +02:00
Daniel Eklöf
ce321e663e
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-18 20:08:30 +02:00
Daniel Eklöf
292a7c5686
config/terminal: refactor: remove “default_*” color members from terminal struct
Access the original colors in the configuration instead.
2021-04-18 20:07:29 +02:00
Daniel Eklöf
937ee8a509
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-18 20:07:13 +02:00
Daniel Eklöf
5dbeb5ce27
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-18 20:07:05 +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
Daniel Eklöf
b17a392b8c
config: show-urls-launch: change default key binding to ctrl+shift+u 2021-02-07 16:33:32 +01:00
Daniel Eklöf
0a1c5e44c4
config: rename ‘show-urls’ to ‘show-urls-launch’ 2021-02-07 16:33:32 +01:00
Daniel Eklöf
82e2541760
config: add ctrl+d as (yet another) default binding url-bindings.cancel 2021-02-07 16:33:32 +01:00
Daniel Eklöf
4233c806c3
config: add ‘url-launch’ option, defaulting to “xdg-open ${url}” 2021-02-07 16:33:31 +01:00
Daniel Eklöf
b255aea3ed
config: free URL bindings 2021-02-07 16:33:31 +01:00
Daniel Eklöf
ee39966ded
config: add infrastructure to handle URL mode specific key bindings
* Add “show-urls” action to regular key bindings
* Add url-bindings section to foot.ini
* Add “cancel” action to URL mode key bindings
2021-02-07 16:33:31 +01:00
Daniel Eklöf
3a7588bc99
config: promote tweak.resize-delay-ms to a real, supported option 2021-01-26 19:32:21 +01:00
Daniel Eklöf
9a1df7bb03
render: delay TIOCSWINSZ while doing an interactive resize
Instead of disabling content centering, delay the TIOCSWINSZ (a.k.a
delay sending the new dimensions to the client) by a small amount
while doing an interactive resize.

Non-interactive resizes are still immediate.

For now, force a resize when the user stops the interactive
resize. This ensures the client application receives the new
dimensions immediately.

It still works without the last, forced, resize, but there typically
be a small delay until the client application receives the final
dimensions.

Closes #301
Closes #283
2021-01-26 19:32:06 +01:00
Daniel Eklöf
3d60600897
config: selection-target: space-optimize the static ‘value’ array 2021-01-23 10:44:19 +01:00
Daniel Eklöf
4f578189cc
config: add ‘none’ as a possible value for ‘selection-target’
When ‘selection-target’ is set to ‘none’, selecting text does not copy
the text to _any_ clipboard.

This patch also refactors the value parsing to be data driven.
2021-01-23 10:43:59 +01:00
Daniel Eklöf
e69ca255b0
config: add new option ‘selection-target’
This option controls the clipboard target that selected text should be
copied to.
2021-01-23 10:43:59 +01:00
Jan Beich
15f2bebdcb
meson: optionalize terminfo dependency
ncurses on FreeBSD still uses termcap(5) while foot works fine with
xterm-256color sans status line and visible bell. Having more than
one ncurses version installed may break other applications.

Document -Dterminfo=false uses --term=xterm-256color by default
2021-01-23 09:52:42 +01:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Craig Barnes
22f25a9e4f Print stack trace on assert() failure or when calling fatal_error()
Note: this uses the __sanitizer_print_stack_trace() function from the
AddressSanitizer runtime, so it only works when AddressSanitizer is
in use.
2021-01-16 19:56:33 +00:00
Daniel Eklöf
767bd4f1db
config: add ‘select-extend-character-wise’ bind action
This forces the (new) selection mode to be character-wise when
extending a word- or line-wise selection.

Default key binding is ctrl+RMB.
2021-01-14 16:29:29 +01:00
Daniel Eklöf
f178de4c25
config: change default box drawing line thickness from 0.02 -> 0.04 2021-01-12 17:31:55 +01:00
Daniel Eklöf
cbe896f694
config: add temporary(?) tweak option for box drawing line thickness 2021-01-12 17:31:55 +01:00
Daniel Eklöf
dce402ae42
config: pt_or_px cannot be a union 2021-01-11 19:37:05 +01:00
Daniel Eklöf
a6fc8b5da4
config: line-height, letter-spacing: values are in pt by default, but we allow px
If the value is specified without a unit, then the value is assumed to
be in points, subject to DPI scaling.

The value can optionally have a ‘px’ suffix, in which case the value
is treated as a raw pixel count.
2021-01-11 09:31:08 +01:00
Daniel Eklöf
4c9f593d91
config: str_to_color(): use LOG_AND_NOTIFY(), not just LOG() 2021-01-11 09:31:08 +01:00
Daniel Eklöf
c2be3408ed
config; {horizontal,vertical}-letter-offsets may be negative 2021-01-11 09:31:07 +01:00
Daniel Eklöf
70cfcf11fb
config: letter-spacing: make this a relative value
0, the default, means no additional spacing; the cell width is defined
by the font metrics.

A positive value *adds* to the width from the font metrics, while a
negative value *subtracts*.
2021-01-11 09:31:06 +01:00