Commit graph

210 commits

Author SHA1 Message Date
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
Daniel Eklöf
f9c9dd2432
config: add line-height, letter-spacing, {horizontal,vertical}-letter-offset 2021-01-11 09:31:05 +01:00
Daniel Eklöf
e14c592f39
config: add optional ‘center’ argument to ‘pad’
When set, the grid contents is centered in the window. I.e. the
left/right and top/bottom margins are equal (+- 1px).

This causes the content to “jump” while doing an interactive resize,
but may still be preferred in e.g. a tiling WM.

Closes #273
2021-01-06 11:17:29 +01:00
Peter Colberg
afc343d528 Require trailing comment to be preceded by a space or tab
Fixes `word-delimiters` option to not ignore `#` and subsequent characters.

Closes #270
2021-01-03 14:08:25 -05:00
Daniel Eklöf
0a821f2ed4
fonts: size fonts using the scaling factor when output scaling is enabled
This extends the new ‘dpi-aware’ option with a new default value,
‘auto’.

When set to ‘auto’, fonts are sized using monitors’ DPI when output
scaling is disabled. When output scaling is enabled, fonts are instead
sized using the scaling factor.

The reasoning here is that a user that has enabled output scaling is
obviously *not* relying on DPI scaling.

Output scaling can also be a way to compensate for different viewing
distances, in which case we do *not* want to break that by using DPI
scaling.

Users can still force DPI-only font sizing by setting ‘dpi-aware=yes’,
or disable it completely by setting ‘dpi-aware=no’.
2020-12-17 12:05:22 +01:00
Daniel Eklöf
0d6b5f522e
config_font_parse(): return fail/success 2020-12-15 18:55:27 +01:00
Daniel Eklöf
15d20af2a2
config: add ‘notify’ to possible values for ‘bell’ in foot.ini
When `bell=notify`, foot will trigger a desktop notification when it
receives a BEL in an unfocused window.
2020-12-10 18:22:48 +01:00
Daniel Eklöf
21cc68d49e
osc: implement urxvt’s “OSC 777;notify”
OSC 777 is URxvt’s generic escape to send commands to its perl
extensions. The first parameter is the name of the extension, followed
by its arguments.

OSC 777;notify is a, if not well established, at least a fairly well
known escape sequence to request a (desktop) notification. The syntax
is:

  \e]777;notify;<title>;<body>\e\\

Neither title nor body is escaped in any way, meaning they should not
contain a ‘;’.

Foot will split title from body at the *first* ‘;’. Any remaining ‘;’
characters are treated as part of ‘body’.

Instead of adding built-in support for the freedesktop notification
specification (which would require us to link against at least dbus),
add a new config option to foot.ini: ‘notify’.

This option specifies the command to execute when a notification is
received. ‘${title}’ and ‘${body}’ can be used anywhere, in any
combination, and as many times as you want, in any of the command
arguments.

The default value is ‘notify-send -a foot -i foot ${title} ${body}’
2020-12-09 20:54:51 +01:00
Daniel Eklöf
5020366bf5
config: remove support for scrollback-up and scrollback-down 2020-12-08 19:58:02 +01:00
Daniel Eklöf
386796cec6
config: remove support for default.geometry 2020-12-08 19:53:55 +01:00
Daniel Eklöf
6ec63eae00
config: remove support for default.scrollback 2020-12-08 19:52:28 +01:00