Commit graph

425 commits

Author SHA1 Message Date
Daniel Eklöf
e271027c0c
config: notify-send: it's "action=label", not "action,label" 2024-07-24 16:01:42 +02:00
Daniel Eklöf
ecbec57a47
notify: split up the ${action} template parameter
Split it up into two, ${action-name} and ${action-label}.

Dunstify, for example, has a different syntax compared to notify-send:

notify-send: default=foobar
dunstify: default,foobar
2024-07-23 19:08:21 +02:00
Daniel Eklöf
045ead985c
notify: don't focus/report on notification dismissal
Only do it when the notification was activated.

Here, activated means the 'click to activate' notification action was
triggered.

How do we tie everything together?

First, we add a new template parameter, ${action}. It's intended to be
used with e.g. notify-send's --action option.

When the action is triggered, notify-send prints its name on stdout,
on a separate line. Look for this in stdout. Only if we've seen it do
we focus/report the notification.
2024-07-23 16:41:52 +02:00
Daniel Eklöf
5905ea0d84
osc: kitty notifications: implement focus|report
This patch adds support for window focusing, and sending events back
to the client application when a notification is closed.

* Refactor notification related configuration options:
    - add desktop-notifications sub-section
    - deprecate 'notify' in favor of 'desktop-notifications.command'
    - deprecate 'notify-focus-inhibit' in favor of
      'desktop-notifications.inhibit-when-focused'
* Refactor: rename 'struct kitty_notification' to 'struct
  notification'
* Pass a 'struct notification' to notify_notify(), instead of many
  arguments.
* notify_notify() now registers a reaper callback. When the notifier
  process has terminated, the notification is considered closed, and we
  either try to focus (activate) the window, or send an event to the
  client application, depending on the notification setting.
* For the window activation, we need an XDG activation token. For now,
  assume *everything* written on stdout is part of the token.
* Refactor: remove much of the warnings from OSC-99; we don't
  typically log anything when an OSC/CSI has invalid values.
* Add icon support to OSC-99. This isn't part of the upstream
  spec. Foot's implementation:
    - uses the 'I' parameter
    - the value is expected to be a symbolic icon name
    - a quick check for absolute paths is done, and such icon requests
      are ignored.
* Added ${icon} to the 'desktop-notifications.command' template. Uses
  the icon specified in the notification, or ${app-id} if not set.
2024-07-23 07:17:21 +02:00
Daniel Eklöf
b0bf8ca5f7
osc/notify: add support for OSC-99, kitty desktop notifications
This adds limited support for OSC-99, kitty desktop notifications[^1]. We
support everything defined by the "protocol", except:

* 'a': action to perform on notification activation. Since we don't
  trigger the notification ourselves (over D-Bus), we don't know a)
  which ID the notification got, or b) when it is clicked.
* ... and that's it. Everything else is supported

To be explicit, we *do* support:

* Chunked notifications (d=0|1), allowing the application to append
  data to a notification in chunks, before it's finally displayed.
* Plain UTF-8, or base64-encoded UTF-8 payload (e=0|1).
* Notification identifier (i=xyz).
* Payload type (p=title|body).
* When to honor the notification (o=always|unfocused|invisible), with
  the following quirks:
    - we don't know when the window is invisible, thus it's treated as
      'unfocused'.
    - the foot option 'notify-focus-inhibit' overrides 'always'
* Urgency (u=0|1|2)

[^1]: https://sw.kovidgoyal.net/kitty/desktop-notifications/
2024-07-23 07:17:21 +02:00
Daniel Eklöf
1136108c97
input: don't map wheel events to BTN_{BACK,FORWARD}
BTN_BACK and BTN_FORWARD are separate buttons. The scroll wheel don't
have any button mappings in libinput/wayland, so make up our own
defines.

This allows us to map them in mouse bindings.

Also expose BTN_WHEEL_{LEFT,RIGHT}. These were already defined, and
used, internally, to handle wheel tilt events. With this, they can
also be used in mouse bindings.

Finally, fix encoding used for BTN_{BACK,FORWARD} when sending mouse
button events to the client application. Before this, they were mapped
to buttons 4/5. But, button 4/5 are for the scroll wheel, and as
mentioned above, BTN_{BACK,FORWARD} are not the same as scroll wheel
"buttons".

Closes #1763
2024-07-13 10:41:10 +02:00
Daniel Eklöf
c4f1380943
config: add cursor.blink-rate option
The default is 500ms, which corresponds to the old, hardcoded default.

Closes #1707
2024-05-20 09:17:42 +02:00
Daniel Eklöf
b400903e25
config: add new key-binding 'quit', unbound by default
Closes #1475
2024-04-11 15:12:45 +02:00
Daniel Eklöf
e5a2ac4b57
config: add cursor.unfocused-style
This option controls how we render the cursor when the terminal window
is unfocused.

Possible values are:

* hollow: the default, and how we rendered the cursor before this
  patch.
* unchanged: render the cursor exactly the same way as when the window
  is focused.
* none: do not render any cursor at all

Closes #1582
2024-04-10 16:24:10 +02:00
Craig Barnes
e8b04e0e2c
xmalloc: add xmemdup() and use to replace some uses of xmalloc+memcpy 2024-03-17 12:31:02 +01:00
Craig Barnes
853be450bb main/config: replace some uses of xasprintf() with xstrjoin() 2024-03-16 20:17:53 +00:00
Daniel Eklöf
3d9aa1c29c
config: don't try to free key combos we haven't allocated
When erroring out due to a key combo being "empty", we incorrectly
tried to free one key binding. This is because 'used_combos' is
initialized to '1'. And it should, but an empty key binding is a
special case.

Fixes a test failure, and closes #1620
2024-02-24 09:58:04 +01:00
Daniel Eklöf
678bdb7c3f
config: on error, correctly free partially parsed key combos 2024-02-23 17:49:24 +01:00
Daniel Eklöf
9ca84e6b48
config: map Control+wheel to font increase/decrease
This is in addition to the already existing keyboard shortcuts.

Also add missing default keyboard/mouse bindings to readme + foot(1).
2024-02-15 16:55:40 +01:00
Daniel Eklöf
7999975016
Don't use fancy Unicode quotes, stick to ASCII 2024-02-06 12:36:45 +01:00
Daniel Eklöf
1c70a84fde
config: add pipe-command-output key-binding 2024-02-06 12:12:57 +01:00
Daniel Eklöf
4730ff8d08
input/config: support *all* modifier names
That is, allow custom modifiers (i.e. other than ctrl/shift/alt etc)
in key bindings.

This is done by no longer validating/translating modifier names to
booleans for a pre-configured set of modifiers (ctrl, shift, alt,
super).

Instead, we keep the modifier *names* in a list, in the key binding
struct.

When a keymap is loaded, and we "convert" the key binding, _then_ we
do modifier translation. For invalid modifier names, we print an
error, and then ignore it. I.e. we no longer fail to load a config due
to invalid modifier names.

We also need to update how we determine the set of significant
modifiers. Any modifier not in this list will be ignored when matching
key bindings.

Before this patch, we hardcoded this to shift/alt/ctrl/super. Now, to
handle custom modifiers as well, we simply treat *all* modifiers
defined by the current layout as significant.

Typically, the only unwanted modifiers are "locked" modifiers. We are
already filtering these out.
2024-02-06 11:05:20 +01:00
Andrew J. Hesford
21a8d832ce
feature: add resize-by-cells option to constrain window sizes...
...to multiples of the cell size, and preserve grid size when changing
fonts or display scales in floating windows.
2024-02-05 12:14:53 +01:00
Craig Barnes
e0f3703ae6
util: add streq() function and use in place of strcmp(...) == 0 2024-02-05 12:09:52 +01:00
Craig Barnes
91b22ae21a Replace unchecked allocations with calls to xmalloc.h functions 2024-01-25 07:03:50 +00:00
Daniel Eklöf
208008d717
config: fix cloning of env_vars tllist
When cloning a config struct, the env_vars tllist wasn't correctly
copied. We did correctly iterate and duplicate all old entries, but we
did *not* reset the list in the cloned struct before doing so.

This meant the list contained entries shared with the original list,
causing double free:s in --server mode.
2024-01-10 16:41:03 +01:00
Jan Palus
8e1b51be10
config: reset conf file descriptor after closing file stream
conf file descriptor is closed once again during cleanup at the end of
config_load() if descriptor >= 0. avoid double closing by assigning
negative value to fd after first close.

by the time second close happens some other descriptor might be opened
reusing previous number ie it might happen during foot server startup
when syslog message is logged between one close and the other. in this
particular situation, as of this writing, it considers fd=3 for which
following events apply:

1. conf file is opened and fclosed()
2. warning is logged with syslog which leads to opening socket to
   /dev/log which is kept open by glibc (gets fd=3)
3. second close during config_load() closes /dev/log socket descriptor
4. epoll_create() in fdm.c reuses fd=3 again
5. another message is being logged with syslog. glibc notices sendto()
   failure on saved /dev/log descriptor hence it closes it and opens
   new one

Due to epoll descriptor closure foot starts a chain of errors that
lead to startup failure.

Fixes #1531
2023-10-27 16:21:46 +02:00
Daniel Eklöf
02fff24b4f
config: improve validation of color values, default alpha to 0xff
Reject color values that aren't in either RGB, or ARGB format. That
is, color values that aren't hexadecimal numbers with either 6 or 8
digits.

Also, if a color value is allowed to have an alpha component, and the
user left it out, default to 0xff (opaque) rather than 0x00 (fully
transparent).

Closes #1526
2023-10-26 16:25:57 +02:00
Raimund Sacherer
8273962372
Enable the use of flash as visual bell
With this patch we can configure flash in the bell section. The colors
section allow now to configure the color and translucency of the
flash.
2023-10-10 08:12:48 +02:00
Daniel Eklöf
1c9d98d57e
config: log_contextual_errno(): sync with log_contextual()
... in terms of whether to print section/value separators
2023-10-08 16:52:21 +02:00
Daniel Eklöf
3e67415e3e
config: add remaining search.scrollback key bindings
All scrollback up/down key bindings are now available in search mode.
2023-10-08 10:38:39 +02:00
Daniel Eklöf
419f0be441
config: map ctrl+shift+right to extend-to-word-boundary 2023-10-08 10:38:39 +02:00
Daniel Eklöf
78665a7e80
search: add more key bindings to extend the current match
This patch adds the following new search key bindings:

* extend-char (shift+right)
* extend-line-down (shift+down)
* extend-backward-char (shift+left)
* extend-backward-to-word-boundary (ctrl+shift+left)
* extend-backward-to-next-whitespace (ctrl+shift+alt+left)
* extend-line-up (shift+up)

They can be used to extend the search match (i.e. the selection).

This patch also adds an initial set of key bindings to scroll in the
scrollback history:

* scrollback-up-page
* scrollback-down-page

These work just like the key bindings for the normal mode. Also note
that it was already possible to scroll using the mouse.

This patch also fixes a couple of search mode bugs:

* crashing when a search match ends in the last column
* grapheme clusters not being matched correctly
* Search match not being "extendable" after a pointer leave event
* A few others, related to either large matches, or extending matches
  after moving the viewport.

There are still a couple of (known) issues:

* A search match isn't correctly highlighted if its *starting* point
  is outside the viewport.
* Extending the match to end of the scrollback (i.e. the most recent
  output) is simply buggy.

Related to #419
2023-10-08 10:38:37 +02:00
Alyssa Ross
400a3f5ad2
config: apply overrides even if there's no file
Previously, foot -a test wouldn't actually set the app ID if there was
no config file and the defaults were used, which was very
counterintuitive.

Now, load_config() will carry on until the end, even if there's no
config file, so overrides still work.
2023-09-25 18:15:46 +02:00
Daniel Eklöf
1719ff93a7
selection: add support for selecting the contents of a quote
This patch changes the default of triple clicking, from selecting the
current logical row, to first trying to select the contents of the
quote under the cursor, and if failing to find a quote, selecting the
current row (like before).

This is implemented by adding a new key binding, 'select-quote'.

It will search for surrounding quote characters, and if one is found
on each side of the cursor, the quote is selected. If not, the entire
row is selected instead.

Subsequent selection operations will behave as if the selection is
either a word selection (a quote was found), or a row selection (no
quote found).

Escaped quote characters are not supported: "foo \" bar" will match
'foo \', and not 'foo " bar'.

Mismatched quotes are not custom handled. They will simply not match.

Nested quotes ("123 'abc def' 456") are supported.

Closes #1364
2023-09-19 16:23:34 +02:00
Daniel Eklöf
fe7aa25ad8
input: make wheel events mappable
Un-grabbed wheel events are now passed through the mouse binding
matching logic, instead of being hardcoded to scrolling the terminal
contents.

They are mappable through the BTN_BACK and BTN_FORWARD buttons.

Since they're not actually button *presses*, they never generate a
click count other than 1. This limitation is documented, but not
checked in the config. This means it's possible to create bindings
like "BTN_BACK+3" (i.e. triple "click"). They will however never
trigger.

The old, hardcoded logic is now accessible through the new
scrollback-up-mouse and scrollback-down-mouse mouse
bindings. They (obiously) default to BTN_BACK and BTN_FORWARD,
respectively.

Example usage: keep the default of scrolling terminal contents with
the wheel, when used without modifiers, but map Control+wheel to font
zoom in/out:

  [mouse-bindings]
  font-increase=Control+BTN_FORWARD
  font-decrease=Control+BTN_BACK

(this also keeps the default key bindings to zoom in/out; ctrl-+ and
ctrl+-)

Closes #1077
2023-09-18 16:36:39 +02:00
Daniel Eklöf
ddcbf2a7b4
config: remove deprecated option 'utempter' 2023-07-31 16:47:51 +02:00
Daniel Eklöf
f3c5b82c82
config: add tweak.bold-text-in-bright-amount
By how much to increase the luminance when brightening bold
fonts. This was previously hard-coded to a factor of 1.3, which is now
the default value of the new config option.

Closes #1434
2023-07-28 15:40:07 +02:00
Daniel Eklöf
27b4c2ac2d
themes: starlight: update to V4
This also updates the default theme in foot, as well as the
documentation.

Closes #1409
2023-07-18 16:20:33 +02:00
Daniel Eklöf
3f7be59062
config: add csd.double-click-to-maximize=no|yes option
When enabled, double-clicking the CSD titlebar will (un)maximize the
window.

Defaults to ‘yes’ (since this is the old hard-coded behavior).

Closes #1293
2023-07-14 12:03:35 +02:00
Daniel Eklöf
efc619b0af
config: make ‘starlight’ the default color theme
Closes #1321
2023-07-14 10:11:43 +02:00
Antoine Beaupré
080a11eb73
bind control-shift-u to unicode-input, move urls to o
Having a keybinding to invoke arbitrary unicode characters is very
useful. It's often used as a method of last resort to communicate with
people outside of your main language. For example, if you want to type
the last letter of my real name, you can invoke the latin-1 character
0xe9 or unicode 0x00e9.

You can also use this to type special characters, for example, unicode
U+1F4A9 is of course, the infamous PILE OF POO, which is sure to
produce million laughs everywhere you go.

In foot, there's no keybinding by default to invoke the very useful
unicode-input command. There is no "standard" (as in "ISO") keybinding
this either. But there *is* a de-facto standard currently deployed
by *both* GTK and Qt (a rare feat) *and* Chrome OS (an even rarer
feat) and it's control-shift-u.

Alternatives include Control-x 8 (emacs), Control V u (vim),
Alt (Windows, LibreOffice), or Option (Mac). I doubt we want to adopt
any of those.

So let's use control-shift-u for this. Unfortunately, it's currently
assigned to show-urls-launch, which is unfortunate, but
insurmountable. We can reassign this keybinding elsewhere. I have
picked control-shift-o in my configuration, because "o" is a good
mnemonic for "open URLs". Others have suggested "m" instead.

Closes: #1183
2023-07-10 12:31:51 +02:00
CismonX
d2fcb5343f
input: add basic support for touchscreen input
Closes #517
2023-07-05 16:22:28 +02:00
Daniel Eklöf
64b6b5d2a7
config: dpi-aware: remove ‘auto’ value, and default to ‘no’
We now default to scaling fonts using the scaling factor, not monitor
DPI.

The ‘auto’ value for dpi-aware has been removed.

Documentation (man pages and README) have been updated to reflect the
new default.
2023-06-29 15:38:23 +02:00
Daniel Eklöf
d63a00a649
config: unittest: explicitly call fcft_init() + fcft_fini()
This plugs a memory leak, caused by fontconfig functions being called
as part of the unit test implicitly allocating global objects.
2023-06-26 20:15:36 +02:00
jdevdevdev
134b54dfe0
.desktop: remove StartupWMClass from server, use distinct StartupWMClass for foot and footclient
For this to work, the default app-id of footclient has been changed
from ‘foot’ to ‘footclient’.

By using distinct StartupWMClasses, the compositor can connect a
running foot/footclient instance to the correct .desktop-file. This
ensures the correct icon is being used in e.g. docks, and that actions
like “open another window” works correctly.

Note that the user can override the app-id, either by setting app-id
in foot.ini, or with the -a,--app-id command line option.

Closes #1355
2023-05-22 18:57:54 +02:00
Daniel Eklöf
e78319fccd
utmp: rewrite utmp logging
This patch generalizes the utmp support, to not only support
libutempter, but also ulog (and in the future, even more interfaces).

* Rename config option main.utempter to main.utmp-helper
* Add meson option -Dutmp-backend=none|libutempter|ulog|auto
* Rename meson option -Ddefault-utempter-path to -Dutmp-default-helper-path
* utmp is no longer detected at compile time, but at runtime instead.

Meson will configure the following pre-processor macros, based on the
selected utmp backend:

* UTMP_ADD - argument to pass to utmp helper when adding a record (starting foot)
* UTMP_DEL - argument to pass to utmp helper when removing a record (exiting foot)
* UTMP_DEL_HAVE_ARGUMENT - if defined, UTMP_DEL expects an extra argument ($WAYLAND_DISPLAY)
* UTMP_DEFAULT_HELPER_PATH - path to the default utmp helper binary

The documentation has been updated to mention which arguments are
passed to the helper binary.

Closes #1314
2023-05-22 18:47:25 +02:00
Daniel Eklöf
9f3ce9236f
config: apply fontconfig rules if user didn’t set an explicit font size
If the user didn’t explicitly set the font size (e.g. font=monospace,
instead of font=monospace:size=12), our initial attempt to read the
FC_SIZE and FC_PIXEL_SIZE attributes will fail, and we used to
fallback to setting the size to 8pt.

Change this slightly, so that when we fail to read the FC_*_SIZE
attributes, apply the fontconfig rules, but *without expanding*
them (i.e. without calling FcDefaultSubstitute()).

Then try reading FC_*_SIZE again.

If that too fails, _then_ set size to 8pt. This allows us to pick up
rules that set a default {pixel}size:

    <fontconfig>
      <match>
        <edit name="pixelsize" mode="append"><double>14</double></edit>
    </fontconfig>

Closes #1287
2023-03-06 18:02:10 +01:00
Daniel Eklöf
09f3475ad1
config: don’t double-free key binding auxiliary data
Key bindings with multiple key mappings share auxiliary data (e.g. the
command to execute in pipe-* bindings, or the escape sequence in
text-bindings).

The first one is the designated “master” copy. Only that one should be
freed.

This fixed a double-free on exit, with e.g.

  [text-bindings]
  \x1b\x23=Mod4+space Mod4+equal

Closes #1259
2023-01-15 10:24:01 +01:00
Daniel Eklöf
6259d59b4d
config: change default grapheme-width-method from wcswidth to double-width
The old default, wcswidth, simply calls wcswidth() on the grapheme
cluster. This was supposedly the implementation with the highest
application compatibility. Except we never even tried to measure
it. It was just assumed.

A lot of modern applications have better implementations. Let’s try to
push support for better emoji support by changing our default method
from wcswith to double-width.

While far from correct (it’s not based on the Unicode tables), the
‘double-width’ method produces accurate results anyway.

double-width is like wcswidth(), in that it adds together the
individual wcwidths of all codepoints in the grapheme cluster. But, it
limits the maximum width to 2.
2023-01-01 10:29:27 +01:00
Daniel Eklöf
4ee0b28b02
config: font-size-adjustment: don’t allow empty %-values (key=%) 2022-12-17 11:00:05 +01:00
Daniel Eklöf
7bf150c11a
config: value_to_pt_or_px(): don’t allow empty px values (key=px) 2022-12-17 11:00:05 +01:00
Daniel Eklöf
f6ca8c90e1
config: add ‘font-size-adjustment=N[px|%]’ option
This patch adds a new config option, font-size-adjustment.

It lets you configure how much the font size should be
incremented/decremented when zooming in or out (ctrl-+, ctrl+-).

Values can be specified in points, pixels or percent.

Closes #1188
2022-12-17 10:59:17 +01:00
Daniel Eklöf
ccfb953bb0
slave: unsetenv() env vars that have been set to the empty string
That is, users can now *clear* environment variables by doing:

  [environment]
  VAR=””

Note that the quotes are required.

Closes #1225
2022-12-06 19:36:15 +01:00
Daniel Eklöf
051e862420
config: allow string values to be quoted
* Both double and single quotes are recognized. There’s no difference
  in how they are handled.
* The entire string must be quoted:
  - “a quoted string” - OK
  - quotes “in the middle” of a string - NOT ok
* Two escape characters are regonized:
  - Backslash
  - The quote character itself
2022-12-06 19:35:58 +01:00