Commit graph

116 commits

Author SHA1 Message Date
Daniel Eklöf
20f0334e13
config: add mouse specific bind actions
This extends the "normal" bind action enum with mouse specific
actions.

When parsing key bindings, we only check up to the last valid keyboard
binding, while mouse bindings support *both* key actions and mouse
actions.

The new actions are:

* select-begin: starts an interactive selection
* select-extend: interactively extend an existing selection
* select-word: select word under cursor
* select-word-whitespace: select word under cursor, where the only
  word separating characters are whitespace characters.

The old hard-coded selection "bindings" have been converted to instead
use these actions, via default bindings added to the configuration.
2020-08-14 07:38:55 +02:00
Daniel Eklöf
d74e583089
config: mouse bindings: add support for click count
Specified by appending "-X", where X is a number.
2020-08-14 07:36:53 +02:00
Daniel Eklöf
593cad3680
config: wrap LOG_AND_NOTIFY_*() in do {} while (0)
This allows us to use these macros in if-statement without braces.
2020-08-14 07:36:53 +02:00
Daniel Eklöf
b97ef5819f
config: key/mouse bindings: refactor: less parsing in keyboard_enter()
This simplifies the handling of mouse and keyboard bindings.

Before, the bindings where parsed *both* when loading the
configuration, and then on every keyboard enter event. This was done
since keys require a keymap to be decoded. Something we don't have at
configuration time. The idea was that at config time, we used a
default keymap just to verify the key combo strings were valid.

The following has changed:

* The bindings in the config struct is now *one* key combo per
  entry. Previously, it was one *action* per entry, and each entry
  had one or more key combos.

  Doing it this way makes it easier when converting the binding in the
  keyboard enter event (which previously had to expand the combos
  anyway).

* The bindings in the config struct no longer contains any unparsed
  strings.

  A key binding contains a decoded 'modifier' struct (which specifies
  whether e.g. ctrl, or shift, or ctrl+shift must be pressed for the
  binding to be used).

  It also contains a decoded XKB keysym.

* A mouse binding in the config struct is similar to a key binding,
  except it contains the button, and click count instead of the XKB
  key sym.

* The modifiers in the user-specified key combo is decoded at config
  time, by using the pre-defined XKB constants
  XKB_MOD_NAME_<modifier>.

  The result is stored in a 'modifiers' struct, which is just a
  collection of booleans; one for each supported modifier.

  The supported modifiers are: shift, ctrl, alt and meta/super.

* The key sym is decoded at config time using
  xkb_keysym_from_name(). This call does *not* depend on a keymap.

* The mouse button is decoded at config time using a hardcoded mapping
  table (just like before).

* The click count is currently hard-coded to 1.

* In the keyboard enter event, all we need to do is pre-compute the
  xkb_mod_mask_t variable for each key/mouse binding, and find all the
  *key codes* that map to the (already decoded) symbol.

  For mouse bindings, the modifiers are the *only* reason we convert
  the mouse bindings at all.

  In fact, on button events, we check if the seat has a keyboard. If
  not, we use the mouse bindings from the configuration directly, and
  simply filter out those with a non-empty set of modifiers.
2020-08-13 18:47:19 +02:00
Daniel Eklöf
544c1b1976
config: wip: add support for modifiers in mouse bindings
Mouse bindings can now include modifiers. They are specified in pretty
much the same way as in keyboard bindings:

  Control+BTN_LEFT
2020-08-13 18:47:19 +02:00
Daniel Eklöf
17070a0d54
config: add tweak.render-timer option
This can be set to 'none' (the default), 'osd', 'log' or 'both'.

When 'osd' is enabled, we'll render the frame rendering time to a
sub-surface after each frame.

When 'log' is enabled, the frame rendering time is logged on stderr.
2020-08-13 18:35:17 +02:00
Daniel Eklöf
5e36ebdef8
config: make selection foreground/background colors configurable
The default is still to inverse the regular foreground/background
colors.

If the user sets *both* of the new options, selection-foreground and
selection-background, those colors will *always* be used for selected
cells, instead of inverting the regular foreground/background colors.
2020-08-12 19:41:50 +02:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Craig Barnes
7eb70a453b Replace GCC "unused" and "format" attributes with portable macros 2020-08-07 20:42:34 +01:00
Daniel Eklöf
019b6bc039
fix printf-format errors in 32-bit builds 2020-08-06 23:20:46 +02:00
Craig Barnes
f1fce96a1d config: handle allocation failure explicitly 2020-08-04 23:28:16 +01:00
Daniel Eklöf
d929862245
config: move cursor.hide-when-typing to mouse.hide-when-typing 2020-08-04 07:33:15 +02:00
Daniel Eklöf
36468b0406
config: add scrollback.multiplier option
This option is used to multiply the mouse scroll amount for mouse and
trackpad based scrollback scrolling.

Closes #54.
2020-08-03 20:08:39 +02:00
Craig Barnes
11a1d99da7 Replace non-portable "\e" escape in string literals with "\033" 2020-08-02 23:54:04 +01:00
Daniel Eklöf
91da76656c
config: clean up
Better parsing means we catch syntax errors earlier, meaning we can
remove some of the checks.
2020-08-02 20:01:07 +02:00
Daniel Eklöf
5e26d3ef47
server/client: use $WAYLAND_DISPLAY instead of $XDG_SESSION_ID in default socket path
Foot is a Wayland client and cannot be run outside of a Wayland
session. As such, it makes more sense to use $WAYLAND_SESSION instead
of $XDG_SESSION_ID in the default socket path since this makes it
clearer which Wayland session we belong to.

Closes #55.
2020-08-02 13:10:31 +02:00
Daniel Eklöf
f3c301ee8b
doc: foot.1: fix default path in -s,--server
The documentation incorrectly stated that the default path is
$XDG_RUNTIME_DIR/foot.sock.

The correct default path is

* $XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock
* $XDG_RUNTIME_DIR/foot-no-session.sock
* /tmp/foot.sock

Depending on whether XDG_RUNTIME_DIR and XDG_SESSION_ID has been set
or not.

This also removes the '<>' from the default when XDG_SESSION_ID is not
set.

Closes #53.
2020-08-02 12:32:10 +02:00
Daniel Eklöf
9b0376efc3
config: pipe-*: fix length calculation of the pipe command substring 2020-07-31 17:10:12 +02:00
Daniel Eklöf
d4ee9be4d7
config: add 'hide-when-typing'
When enabled, the mouse cursor is hidden when the user types in the
terminal. It is un-hidden when the user moves the mouse, or when the
window loses keyboard focus.
2020-07-31 17:09:06 +02:00
Daniel Eklöf
b00dfcf7b6
config: configuration errors are no longer fatal
Instead of refusing to start foot on configuration errors, we start
and print a user-notification.
2020-07-31 17:07:14 +02:00
Daniel Eklöf
639a61abd8
config: add 'pipe-selected' key binding
This works just like pipe-visible and pipe-scrollback, but pipes the
user-selected text, if any, to the external tool.

Closes #51
2020-07-31 17:04:30 +02:00
Daniel Eklöf
f6533a71e4
user-notification: 'productify' the user-warning system
* Rename user_warning to user_notification
* Add warning and error types (in addition to the existing deprecated)
* Simplify logic when emitting a user notification after forking; we
  don't need to copy the notification data since we're in a new
  process and have total control over that memory.
2020-07-30 18:58:54 +02:00
Daniel Eklöf
7767041c2c
config: tokenize key bindings' pipe command when loading the configuration
This allows us to detect syntax errors early on, and is also more
efficient since we don't have to re-tokenize the command line every
time the binding is executed.
2020-07-30 18:53:51 +02:00
Daniel Eklöf
aed5b9e539
config: emit a user-warning for deprecated option 'scrollback' 2020-07-29 19:43:11 +02:00
Daniel Eklöf
b3d0215c38
term: add capability to print warnings *inside* the terminal
This is intended to be used to print e.g. deprecation warnings inside
the terminal, *before* the shell is started.
2020-07-29 19:42:12 +02:00
Daniel Eklöf
d11d374252
config: add scrollback section
* Move 'scrollback' to 'scrollback.lines'
* Move (the new) 'scrollback-indicator-*' options to
  'scrollback.indicator-*'

Log a deprecation warning when the old 'scrollback' option is used,
but don't remove it, yet.
2020-07-29 17:41:24 +02:00
Daniel Eklöf
919f31ffcb
search/config: configurable key bindings for (scrollback) search mode 2020-07-29 17:27:01 +02:00
Daniel Eklöf
47d9b947f0
config: fix check for scrollback-indicator-format=percentage 2020-07-28 19:57:26 +02:00
Daniel Eklöf
2882fbb537
config: add free-form text variant to 'scrollback-indicator-format'
And make the empty string the new default.
2020-07-28 19:56:53 +02:00
Daniel Eklöf
eadb5a4a88
config: handle trailing comments and empty values 2020-07-28 19:55:09 +02:00
Daniel Eklöf
718e5b4a77
config: rename scrollback-indicator-style to scrollback-indicator-position 2020-07-27 20:09:36 +02:00
Daniel Eklöf
50d116dcb9
config: scrollback-indicator-format: percent -> percentage 2020-07-26 11:39:02 +02:00
Daniel Eklöf
d180de00a9
config: fix error message for 'scrollback-indicator-style' 2020-07-26 09:44:16 +02:00
Daniel Eklöf
be7d0a5615
config: fix key check for 'scrollback-indicator-style' 2020-07-26 09:43:58 +02:00
Daniel Eklöf
9edd71a741
config: rename scrollback-indicator-style value 'static' to 'fixed' 2020-07-25 14:40:46 +02:00
Daniel Eklöf
e3be2cbd6f
config: rename scrollback-indicator-style value 'moving' to 'relative' 2020-07-25 14:38:36 +02:00
Daniel Eklöf
c4679e474e
config: rename scrollback-indicator to scrollback-indicator-style
And turn it from a boolean to an enum. It can be set to:

* `none` - disables the indicator
* `static` - always rendered near the top of the window
* `moving` - position reflects the scrollback position
2020-07-25 14:31:45 +02:00
Daniel Eklöf
5b868fd0c9
config: add 'scrollback-indicator-format' option
The value of this option must be either 'percent', or 'line', and
determines _how_ we render the scrollback indicator.
2020-07-24 18:35:34 +02:00
Daniel Eklöf
e945063620
config: rename show-scrollback-position to scrollback-indicator 2020-07-24 18:26:44 +02:00
Daniel Eklöf
2c6f7adc17
config: add 'show-scrollback-position' option to footrc 2020-07-24 18:20:26 +02:00
Daniel Eklöf
94bb313282
config: oopsie, need to use strndup() on the pipe command
Since it isn't NULL-terminated.
2020-07-15 17:48:02 +02:00
Daniel Eklöf
65a46be822
config: change syntax for pipe-command in key binding
The pipe command can contain almost all printable characters. In
particular, we can expect it to contain '='.

Having the pipe command as part of the key breaks the key/value
splitting.

Change it so that it is instead an optional initial part of the value,
enclosed in '[]'.

I.e. instead of

    pipe-visible:cmd=binding

we now need to write

    pipe-visible=[cmd] binding
2020-07-15 17:28:09 +02:00
Daniel Eklöf
1541531765
conf: bindings: allow several mappings for the same action
If the bindings has different pipe command associated with them, treat
them as different actions.
2020-07-15 16:43:11 +02:00
Daniel Eklöf
57f5cc1bf2
config: add support for appending a 'spawn' argument to key bindings
A key binding may now have an optional ':<cmd>' string appended to the
key.

This is intended to be used like so:

  pipe-scrollback:sh -c "cat > file"=Print

TODO: we still only allow one *action*. Meaning you still cannot
specify multiple pipe-scrollback bindings, for example.
2020-07-15 13:32:31 +02:00
Daniel Eklöf
85c50099af
conf: add definitions for pipe-{scrollback,view} bindings 2020-07-15 09:46:13 +02:00
Daniel Eklöf
69e4213e4a
term: don't use deprecated fcft_size_adjust()
When resizing the font on-the-fly, we now do a complete
font-reload (this is basically what fcft_size_adjust() did anyway).

To get the correct size, we maintain the current size ourselves.

We get the initial size from the user-provided font pattern, by
converting the string to an FcPattern, and using FcPatternGet() to
retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These
attributes are then removed from the pattern, and the pattern is
converted back to a string.

The terminal struct maintains a copy of the font sizes. These are
initially set to the sizes from the config.

When the user resizes the font, the terminal-local sizes are
adjusted. To ensure the primary and user-configured fallback fonts are
resizes equally much, convert any pixel sizes to point sizes at this
point.

When the font size is reset, we reload the font sizes from the
config (thus once again returning actual pixel-sizes, if that's what
the user has configured).
2020-07-07 10:44:55 +02:00
Daniel Eklöf
a259eda535
config: add 'blink' option to cursor section in footrc
This option controls whether the default cursor should blink or
not. The default is to *not* blink.
2020-06-30 17:45:34 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
c96a0b3b3c
misc: replace all explicit zero-initializers with empty initializers 2020-04-13 12:03:11 +02:00
Daniel Eklöf
1f264b165d
config: use an unsigned constant, since we're shifting 31 bits 2020-04-09 13:35:02 +02:00