Commit graph

647 commits

Author SHA1 Message Date
Daniel Eklöf
1a755d0da2
uri: hostname_is_localhost(): don’t crash if hostname == NULL 2021-06-19 15:56:39 +02:00
Daniel Eklöf
535c82d628
render: use a timer instead of relying on the frame callback for title update throttling
Using the frame callback works most of the time, but e.g. Sway doesn’t
call it while the window is hidden, and thus prevents us from updating
the title in e.g. stacked views.

This patch uses a timer FD instead. We store a timestamp from when the
title was last updated. When the application wants to update the
title, we first check if we already have a timer running, and if so,
does nothing.

If no timer is running, check the timestamp. If enough time has
passed, update the title immediately.

If not, instantiate a timer and wait for it to trigger.

Set the minimum time between two updates to ~8ms (twice per frame, for
a 60Hz output, and ~once per frame on a 120Hz output).

Closes #591
2021-06-18 15:36:58 +02:00
Daniel Eklöf
cf81fff062
config: add underline-offset option
This option allows the user to configure a custom underline
offset. That is, use the user provided offset instead of the font
provided one.

Closes #490
2021-06-17 17:54:21 +02:00
Daniel Eklöf
11829931a7
search: don’t crash when we don’t have any XKB compose state 2021-06-16 17:44:14 +02:00
Daniel Eklöf
3adc3367e6
csi: implement XTVERSION (CSI > 0q)
This is a fairly new XTerm extension. The reply is on the format:

  DCS > | text ST

XTerm replies with ‘text’ = “XTerm(366)”.

Foot replies with ‘text’ = “foot(1.6.4)”

Closes #359
2021-06-13 17:19:41 +02:00
Ryan Farley
f379ffb8ed Override options from command line
Allow any configuration option to be overridden with -o/--override
'section.key=value' arguments, as suggested in #554

update completitions for override

slight refactoring to ease footclient support
2021-06-12 03:05:15 -05:00
Daniel Eklöf
955ecbd19a
config: demote “no configuration found, using defaults” to a mere warning
And don’t notify the user in the terminal window, only log it on
stderr.
2021-06-10 20:40:01 +02:00
Daniel Eklöf
cd37cdc940
term: free the data associated with the pixman image when destroying box-drawing glyphs
Closes #586
2021-06-09 11:27:08 +02:00
Daniel Eklöf
49bb00fb64
selection: add support for TEXT/STRING/UTF8_STRING mime-types in incoming offers
We were already offering these mime types for our own clipboard data,
but ignored them in incoming offers.

Fixes paste issues from Geany.

Closes #583
2021-06-09 11:23:55 +02:00
Craig Barnes
2a75da4143 Merge branch 'charset-shift-fixes' 2021-06-09 10:18:52 +01:00
Craig Barnes
3c609771c5 changelog: add issue links for previous 2 entries 2021-06-09 09:30:34 +01:00
Daniel Eklöf
6d336fcadd
sixel: add support for overlapping sixels
Writing a sixel on top of an already existing sixel currently has the
following limitations in foot:

* The parts of the first sixel that is covered by the new sixel are
  removed, completely. Even if the new sixel has transparent
  areas. I.e. writing a transparent sixel on top of another
  sixel *replaces* the first sixel with the new sixel, instead of
  layering them on top of each other.

* The second sixel erases the first sixel cell-wise. That is, a sixel
  whose size isn’t a multiple of the cell dimensions will leave
  unsightly holes in the first sixel.

This patch takes care of both issues.

The first one is actually the easiest one: all we need to do is
calculate the intersection, and blend the two images. To keep things
relatively simple, we use the pixman image from the *new* image, and
use the ‘OVER_REVERSE’ operation to blend the new image over the old
one.

That is, the old image is still split into four tiles (top, left,
right, bottom), just like before. But instead of throwing away the
fifth middle tile, we blend it with the new image. As an optimization,
this is only done if the new image has transparency (P1=1).

The second problem is solved by detecting when we’re erasing an area
from the second image that is larger than the new image. In this case,
we enlarge the new image, and copy the old image into the new one.

Finally, when we enlarge the new image, there may be areas in the new
image that is *not* covered by the old image. These areas are made
transparent.

The end result is:

* Each cell is covered by at *most* 1 sixel image. I.e. the total
  numbers of sixels are finite. This is important for the ‘mpv
  --vo=sixel’ use case - we don’t want to end up with thousands of
  sixels layered on top of each other.

* Writing an opaque sixel on top of another sixel has _almost_ zero
  performance impact. Especially if the two sixels have the same size,
  so that we don’t have to resize the new image. Again, important for
  the ‘mpv --vo=sixel’ use case.

Closes #562
2021-06-09 10:00:19 +02:00
Daniel Eklöf
fff75e082f
changelog: tabs are preserved 2021-06-09 09:57:20 +02:00
Craig Barnes
a2c9c56f19 vt: fix SS2/SS3 escape sequences to act correctly as single shifts
These sequences are supposed to affect the next printable ASCII
character and then reset to the previous character set, but before
this commit they were behaving like locking shifts.
2021-06-08 21:09:40 +01:00
Craig Barnes
e72e8b1b8e vt: add support for LS2 and LS3 locking shifts 2021-06-08 21:06:18 +01:00
Daniel Eklöf
0febce9007
csi: IL+DL: move cursor to column 0
This fixes vttest 11.6.6.3

Test non-VT100 ->
Test ISO-6429 colors ->
Test of VT102-style features with BCE ->
Test Insert/Delete Char/Line
2021-06-08 19:52:35 +02:00
Daniel Eklöf
39560a6ff1
render: reverse video only swaps *default* fg/bg
This matches XTerm behavior, and fixes vttest 11.6.6.2:

Test non-VT100 ->
Test ISO-6429 colors ->
Test of VT102-style features with BCE ->
Test of screen features
2021-06-08 19:51:13 +02:00
Daniel Eklöf
a7e2e4bfa9
input: pass through scrollback-* key bindings when alt screen is activw
Since the alt screen have no scrollback, all scrollback-* actions are
effectively no-ops when the alt screen is active.

Make them available to the client application instead.

Closes #573
2021-06-04 23:25:45 +02:00
Daniel Eklöf
405b887a82
osc: implement iTerm2’s OSC-9 - desktop notifications 2021-06-04 07:44:00 +02:00
Daniel Eklöf
354de2b8ee
changelog: text reflow performance 2021-06-04 07:42:53 +02:00
Daniel Eklöf
a72b2688bd
slave/spawn: restore SIGHUP handler after fork(), before exec()
Foot installs a SIG_IGN handler for SIGHUP. Ignored signals are
inherited in sub-processes. Thus, we need to restore it to SIG_DFL
before exec:ing.
2021-06-02 20:13:14 +02:00
Daniel Eklöf
b7709cc013
grid: don’t cut multi-column chars in half when resizing the alt screen
When we resize the alt screen, we don’t reflow the text, we simply
truncate all the lines.

When doing this, make sure we don’t truncate in the middle of a
multi-column character.
2021-06-02 19:32:05 +02:00
Daniel Eklöf
974c3acd78
url-mode: off-by-one error in end-point column of auto-detected URLs
When an auto-detected URL ended *on* the right-most column, the URL
endpoint was off by one, resulting in the underline in URL mode being
one character short.
2021-06-02 08:11:14 +02:00
Daniel Eklöf
4c954be7a6
config: add boolean option tweak.pua-double-width
When enabled, PUA (Private Usage Area) codepoints are always treated
as double-width glyphs, regardless of the actual glyph width.

Requires allow-overflowing-double-width-glyphs=yes
2021-06-01 17:51:09 +02:00
Daniel Eklöf
f0041882f1
selection: pay attention to hard linebreaks when search for word boundaries
Double-clicking on a word in the left or right margin, would line-wrap
the selection if there was a non-empty cell in the corresponding
right/left margin on the prev/next line. Regardless of whether there
was a hard linebreak or not.

Script to reprouce:

  !/bin/bash

  cols=$(tput cols)
  printf "%*coo\nbar\n" $((${cols} - 2)) f

Run, then double click either “foo” or “bar”. Neither should select
the other part.

Closes #565
2021-05-31 17:15:20 +02:00
Daniel Eklöf
4e3fdaa8f2
changelog: add bug ref to ‘environment section added to foot/footclient’ 2021-05-30 10:21:24 +02:00
Craig Barnes
d08096b201
doc: add ENVIRONMENT section to foot(1) and footclient(1) man pages
Closes #556
2021-05-30 10:20:48 +02:00
Daniel Eklöf
9055d3d921
config: add ‘include’ directive
This allows you to include sub-configurations. For example, theme
files.

The ‘include’ directive is a top-level keyword. I.e. it cannot be used
inside sections.

* The included file must be specified with an absolute path
* The included file is parsed in its own scope
* Nested includes are allowed
* Multiple include directives are allowed

Closes #555
2021-05-28 17:44:13 +02:00
Daniel Eklöf
f1d75a1e1f
notify: add ${window-title} 2021-05-27 12:11:47 +02:00
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
Daniel Eklöf
a012c2fb3e
term: fix crash when an OSC-8 URI wraps around the scrollback
Long OSC-8 URIs, that are split up over multiple rows, are handled by
emitting one URI range on each row the URL touches.

This was done by initializing a row index variable, and then
incrementing it each loop iteration.

This caused an out-of-bounds array access when the row index reached
the maximum number of scrollback lines.

The fix is simple: make sure the row index variable wraps around,
instead of incrementing without any bounds.

Closes #552
2021-05-26 14:11:03 +02:00
Daniel Eklöf
fbb809af3b
changelog: fixed mod+shift+tab regression 2021-05-26 09:13:58 +02:00
Craig Barnes
3eaf6ead2c Merge branch 'ctrl-c-cancel' 2021-05-25 17:03:26 +01: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
7bdecaae3b
wayland: roundtrip: log error and abort when wl_display_roundtrip() fails
ayl_roundtrip() has the following code:

    wl_display_roundtrip(wayl->display);

    while (wl_display_prepare_read(wayl->display) != 0)
        wl_display_dispatch_pending(wayl->display);
    wayl_flush(wayl);

If the first wl_display_roundtrip() fails, for example because the
Wayland socket has been closed, we may get stuck in the while-loop.

This happens if the read queue isn’t empty, in which case
wl_display_prepare_read() will return -1 and we’ll continue trying to
dispatch the pending events forever, never succeeding since the socket
is gone.

Closes #542
2021-05-25 17:50:17 +02:00
Daniel Eklöf
5605eb9040
url-mode: remove overlapping URLs, not just duplicates
echo -e '\e]8;;https://www.foo.bar\e\\https://www.foo\e]8;;\e\\.bar'

will produce an OSC-8 URL (https://www.foo) that is slightly shorter
than the auto-detected one (https://www.foo.bar).

This produces strange results in URL mode. For example, if
url.osc8-underline=always, the OSC8 underline will be removed when
url-mode is exited.

This patch changes the behavior so that auto-detected URLs that
overlap OSC-8 URLs are removed.

Note that OSC-8 URLs cannot overlap with each other, and that
auto-detected URLs also cannot overlap with each other.
2021-05-22 16:42:43 +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
890dbc49cf
fdm: always check for signals after epoll_pwait(), not only on EINTR
This fixes an issue where we, at least on FreeBSD, sometimes get stuck
in epoll_pwait() after the shell has exited.

It turned out to be because the SIGCHLD signal was delivered at the
same time FDs were made readable/writeable. I.e. epoll_pwait()
returned a non-zero value even though it should have been interrupted
by the SIGCHLD.

To avoid having to search the entire signal array *every time*
epoll_pwait() returns, add a flag that is set in the signal
handler. This tells the FDM to scan the signal array after returning
from epoll_pwait().
2021-05-21 20:00:45 +02:00
Craig Barnes
74f740c975 vt: limit maximum value of params in vt_param_get()
So that the value is clamped to the range [0, 0x7fffffff] and retains
the same value, regardless of whether it's interpreted as a signed or
unsigned integer.

Closes #522
2021-05-17 18:15:34 +01:00
Daniel Eklöf
48cc9596f1
changelog: ctrl+w can now be used across lines 2021-05-17 18:19:55 +02:00
Daniel Eklöf
e415f85829
search: find_next(): proper check for scrollback wrap around
Besides disallowing matches that crosses the scrollback wrap-around,
this also fixes a crash when the trying to search beyond the last
output, when the scrollback history hasn’t yet been completely filled.
2021-05-17 18:14:09 +02:00
Daniel Eklöf
e7c01f3e52
changelog: fonts sometimes not being reloaded with the correct scaling factor 2021-05-17 17:55:49 +02:00
Daniel Eklöf
e0f1a4ae33
sixel: don’t *ever* shrink image below its SRA size
If the image was accompanied with a “Set Raster Attributes” (SRA)
command, make sure we *never* shrink the image below the size
specified in the SRA.

Images are normally shrunk when their bottom rows are fully
transparent. This enables sixels that aren’t a multiple of 6 to be
emitted, without also emitting an SRA command.

But if there *is* an SRA command, obey it.

Verified against XTerm-367
2021-05-16 11:00:32 +02:00
Daniel Eklöf
8211484185
changeloge: xdg-activation support 2021-05-14 14:22:43 +02:00
Daniel Eklöf
2ac8509c82
render: force underlines to be visible
In some cases, the underline position (typically provided by the font,
mind you), end up below the cell, making it visible.

Note that below the cell here means below the line. I.e. the font
provided underline position is below the font provided line height...

Oh well.

Doing this in foot rather than fcft, since other applications
typically don’t have to clip the rendered text.

Closes #503
2021-05-12 20:10:04 +02:00
Daniel Eklöf
29776dbd1f
quirk: remove plasma/kwin quirk
Older version of Plasma/KWin had an issue where buffer damage recorded
before the buffer was attached were ignored. This appears to have been
fixed now.
2021-05-12 20:08:40 +02:00
Daniel Eklöf
07d0acbabf
changelog: improved performance when double buffering 2021-05-12 20:07:18 +02:00
Daniel Eklöf
aada44bc7e
changelog: sixel assertion hit when a sixel fills the scrollback 2021-05-08 20:29:35 +02:00