Commit graph

677 commits

Author SHA1 Message Date
Daniel Eklöf
628fd39098
render: scrollback indicator: improve handling of very small window sizes 2021-07-15 18:26:26 +02:00
Daniel Eklöf
654e65631d
changelog: box-drawing fixes on big-endian 2021-07-14 19:48:13 +02:00
Daniel Eklöf
f030c87ee6
url-mode: abort when running into un-allocated scrollback memory
When tagging URL cells (in preparation for rendering URL mode), we
loop the URL’s entire range, setting the `url` attribute of all cells,
and dirtying the rows.

It is possible to create URLs that are invalid, and wrap around the
scrollback, even though the scrollback hasn’t yet been filled. For
example, by starting an OSC-8 URL, moving the cursor, and then closing
the OSC-8 URL.

These URLs are invalid, but are still rendered just fine. “Fine” being
relative - they will typically fill the entire screen. But at least
that’s a very clear indication for the user that’s something is wrong.

The problem is when we hit un-allocated scrollback rows. We didn’t
check for NULL rows, and crashed.

This has now been fixed.
2021-07-11 11:31:11 +02:00
Daniel Eklöf
cf6d04f9f2
url-mode: fix crash when removing duplicate and/or overlapping URLs
Removing overlaping and duplicated URLs is done by running two nested
loops, that both iterate the same URL list.

When a duplicate is found, one of the URLs is destroyed and removed
from the list.

Deleting and removing an item *is* safe, but only as long as _no
other_ iterator has references to it.

In this case, if we remove an item from e.g. the inner iterator, we’ll
crash if the outer iterator’s *next* item is the item being removed.

Closes #627
2021-07-11 10:06:12 +02:00
Daniel Eklöf
0a6e7e6167
url-mode: purge SHM pixmaps when destroying URLs
Unlike other surface types, the SHM cookie depends on the address of
each URL instance. This means if we enable, disable, and then enable
URL mode again (thus showing exactly the same URLs as the first time),
the URLs will have new addresses, and thus the old SHM pixmaps will
not get purged automatically.

So, manually purge them when destroying the URLs.
2021-07-11 09:59:17 +02:00
Daniel Eklöf
fcb60abc13
config: add locked-title=no|yes
Closes #386
2021-07-04 17:59:40 +02:00
Daniel Eklöf
07652d3b9e
term: rows printed to now defaults to having a hard linebreak
That is, instead of requiring a ‘\n’ to be printed, non-empty lines
are now treated as having a hard linebreak by default.

The linebreak is cleared on an explicit wrap.
2021-07-03 18:05:45 +02:00
Daniel Eklöf
396a5ff79b
allow-overflowing-double-width-glyphs: take glyph offset into account
A narrow, but offset:ed glyph should still be considered double
width.

This patch also fixes a crash, when the maybe-double width glyph is in
the last column. This is a regression.
2021-07-02 16:31:14 +02:00
Daniel Eklöf
4e8db9d8b6
changelog: s/from/in 2021-07-01 20:44:53 +02:00
Daniel Eklöf
ea39496f30
changelog: add new ‘unreleased’ section 2021-07-01 20:19:28 +02:00
Daniel Eklöf
7112f24671
changelog: prepare for 1.8.1 2021-07-01 20:14:20 +02:00
Daniel Eklöf
ab8f9afa90
changelog: move grapheme cluster width entry to ‘changed’, and rewrite it 2021-07-01 20:13:03 +02:00
Daniel Eklöf
5138f02214
config: rename at-most-2 (value for grapheme-width-method) to double-width 2021-07-01 08:00:23 +02:00
Daniel Eklöf
9817e44c32
config: add tweak.grapheme-width-method=wcswidth|at-most-2 2021-07-01 07:58:06 +02:00
Daniel Eklöf
149c52bd44
config: remove replaced/removed key bindings, instead of marking as ‘unused’
Instead of keeping removed/replaced key bindings in the key binding
array (marked as ‘unused’), remove them, by compacting the array.

The invariant is thus that there should be *no* entries in the key
binding list with the `BIND_ACTION_NONE` for action.

Add code to debug builds that verifies this, plus a unit test.

Closes #614
2021-06-30 18:05:07 +02:00
Craig Barnes
3e74482d6c terminfo: add Tc, setrgbf and setrgbb capabilities
These extensions are used by tmux and neovim, in order to make use
of 24-bit colors without facing the problems that plague the `RGB`
capability.

This should allow 24-bit colors to work "out of the box" in tmux,
without the usual workaround of adding:

    set-option -ga terminal-overrides ",foot*:Tc"

...to ~/.tmux.conf.

See also:

* 18fe2e8dfa (commitcomment-31373962)
* f83c25942d/runtime/doc/term.txt (L123-L139)
* b1a8c0fe02/CHANGES (L988-L989)

Closes #615
2021-06-29 08:55:53 +01:00
Craig Barnes
5dca0458a0 log: add LOG_CLASS_NONE and use as initializer for log_level
This means that logging will be completely disabled until log_init()
has been called, which is useful to prevent log spam when running
UNITTEST{} blocks in debug builds.

Note that this doesn't change the default log level at runtime, which
was already being set to LOG_CLASS_INFO in main.c and client.c.

The new log level is also exposed to the command-line interface as
`--log-level=none`, which allows disabling logging entirely.
2021-06-26 22:15:09 +01:00
Daniel Eklöf
0ff8f72a9d
vt: don’t reset utf8proc grapheme state when we’re not at a grapheme break 2021-06-25 20:42:23 +02:00
Daniel Eklöf
2535cf51db
changelog: add new ‘unreleased’ section 2021-06-25 08:44:41 +02:00
Daniel Eklöf
8df5f90474
changelog: prepare for 1.8.0 2021-06-25 08:23:36 +02:00
Daniel Eklöf
07128ee905
changelog: spelling; add missing ‘l’ in ‘experimental’ 2021-06-24 22:55:28 +02:00
Daniel Eklöf
cf101ea300
changelog: describe what (does not) happens when grapheme-shaping=no 2021-06-24 17:36:57 +02:00
Daniel Eklöf
d5d57c1b20
changelog: composed -> combining 2021-06-24 17:36:52 +02:00
Daniel Eklöf
09c4d16232
changelog: put emphasis on ‘opt-in’ as well 2021-06-24 17:33:09 +02:00
Daniel Eklöf
f19797a5af
changelog: updates to “grapheme shaping” 2021-06-24 17:30:50 +02:00
Daniel Eklöf
fd70058795
changelog: add a “grapheme shaping” section 2021-06-24 17:30:49 +02:00
Daniel Eklöf
07bb67130a
changelog: -Dterminfo-install-location meson command line option 2021-06-23 17:04:12 +02:00
Daniel Eklöf
bac3964039
changelog: add ref to #600 (-o,--override for footclient) 2021-06-23 15:12:09 +02:00
Daniel Eklöf
2a83202fdd
wayland: apply CSD/SSD changes in the surface configure event
The configure event asks the client to change its decoration
    mode. The configured state should not be applied immediately.
    Clients must send an ack_configure in response to this event.
    See xdg_surface.configure and xdg_surface.ack_configure for
    details.

In particular, ”the configured state should *not* be applied
immediately”.

Instead, treat CSD/SSD changes like all other window dimension related
changes: store the to-be mode in win->configure, and apply it in the
surface configure event.

This fixes an issue where foot incorrectly resized the window when the
server switched between CSD/SSD at run-time.
2021-06-23 12:37:56 +02:00
Daniel Eklöf
7334b53d83
config: add csd.button-color option
This option controls the foreground color of the
minimize/maximize/close buttons. I.e. the color used to draw the
minimize/maximize/close glyphs.

It defaults to default background color.
2021-06-20 10:44:50 +02:00
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