Commit graph

4377 commits

Author SHA1 Message Date
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
ed081f5f3c
Merge branch 'tabs'
Closes #508
2021-06-09 09:58:29 +02:00
Daniel Eklöf
fff75e082f
changelog: tabs are preserved 2021-06-09 09:57:20 +02:00
Daniel Eklöf
9929a5ce0a
csi: CHT: don’t alter the LCF flag
This makes us pass the vttest 11.5.4 (Test non-VT100 -> Test ISO-6429
cursor-movement -> CHT) test.
2021-06-08 19:53:26 +02:00
Daniel Eklöf
9d3351472d
vt: TAB: don’t print a ‘\t’ to the grid if the *current* cell isn’t empty
If the cursor is already at the right edge, our logic that checked for
non-empty cells failed; it didn’t check the current cell.

Fix by initializing ‘emit_tab_char’ to true/false, depending on the
contents of the current cell.
2021-06-08 19:53:26 +02:00
Daniel Eklöf
4d56dd430b
extract: consume spaces following a tab
That is, we choose to copy the tab character, and not the spaces it
represents. Most importantly, we don’t copy *both* the tab and the
spaces.
2021-06-08 19:53:26 +02:00
Daniel Eklöf
94b549f93e
vt: emit a tab character if all cells between cursor and tab stop are empty
TAB (\t) move the cursor to the next tab stop. That’s it, according to
the specification.

However, many terminal emulators try to keep tabs in the grid, to be
able to e.g. copy them. That is, copying a text chunk containing tabs
should result in tabs being pasted, not spaces.

In order to do that, we need to print a tab character to the grid. To
improve text reflow of tabs, we also print spaces to the subsequent
cells, up until (but not including) the next tab stop.

However, we can only do this if all the cells between the cursor and
the next tab stop are empty, since (obviously), we cannot overwrite
pre-existing characters.

Finally, while some fonts render tabs as spaces (i.e. an empty glyph),
some use a glyph representing “unprintable” characters, or
similar. Thus, we need to exclude cells with tab characters when
rendering.
2021-06-08 19:53:26 +02:00
Daniel Eklöf
e77b7d7111
Merge branch 'il-dl-reset-cursor-col' 2021-06-08 19:52:40 +02: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
a2f54c810b
Merge branch 'reverse-video-only-affects-default-fg-bg' 2021-06-08 19:52:13 +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
Craig Barnes
620fe8e764 vt: fix buggy chains of ternary expressions in action_esc_dispatch()
Only the first character in the chain was being compared with `priv`
and the rest were just being evaluated as simple expressions. This
was causing the G2 and G3 operations to erroneously use the G1 index.

Since the characters are a contiguous range, we can just subtract the
start of the range to get the appropriate index. The outer switch
statement already ensures the values are in range.
2021-06-08 16:52:00 +01:00
Craig Barnes
b34d76f711 terminal: fix compilation error when debug logging is enabled
Without this fix, setting LOG_ENABLE_DBG to 1 in terminal.c would
cause the following error:

> terminal.c:1787: 'struct terminal' has no member named 'font_scale'

The 'font_scale' member was removed in commit
2afc678236.
2021-06-08 13:10:46 +01:00
Daniel Eklöf
95c4a8ccfb
vt: \E#8: print ‘E’ using the default attributes 2021-06-07 21:35:17 +02:00
Daniel Eklöf
0de55182ac
selection: reset ‘empty_count’ after we’ve emitted the empty cells
When marking and unmarking cells, we don’t highlight trailing empty
cells. We do however highlight empty cells if they are followed by
non-empty cells.

I think this was an intentional choice. If one row ended with trailing
empty cells, but *no* hard linebreak, then we’d continue on the next
row, and emit all the empty cells once we hit a non-emtpy cell on the
second row.

But this is something that shouldn’t happen in any real-world use
cases.
2021-06-05 13:41:17 +02:00
Daniel Eklöf
dfbe8297f7
Merge branch 'scrollback-key-bindings-pass-through-alt-screen'
Closes #573
2021-06-05 10:33:55 +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
b5515a414a
Merge branch 'osc-9' 2021-06-04 07:44:07 +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
dd43afd754
Merge branch 'chunked-reflow'
Closes #504
2021-06-04 07:43:18 +02:00
Daniel Eklöf
354de2b8ee
changelog: text reflow performance 2021-06-04 07:42:53 +02:00
Daniel Eklöf
3292bb5b8e
grid: reflow: ‘amount’ has already been added to ‘from’ 2021-06-02 20:13:52 +02:00
Daniel Eklöf
cb83d60089
selection: fix bad assertion
When there are multiple multi-column characters back-to-back, the cell
before the pivot end point may in fact be a SPACER+1 cell.
2021-06-02 20:13:52 +02:00
Daniel Eklöf
a003e56fdc
grid: reflow: URI range start: take over ownership of URI string
Instead of strdup:ing the URI, take over ownership. This is ok since
the old URI range will be free:d anyway.
2021-06-02 20:13:52 +02:00
Daniel Eklöf
8a9643de67
grid: reflow: debug logging 2021-06-02 20:13:51 +02:00
Daniel Eklöf
ceab9b9367
grid: reflow: when determining row end coord, check *last* URI range 2021-06-02 20:13:51 +02:00
Daniel Eklöf
5a08ed641b
grid: reflow: when determining row end coord, check *last* tracking point 2021-06-02 20:13:51 +02:00
Daniel Eklöf
ef1fdc40c8
grid: reflow: check the *entire* row for non-empty cells 2021-06-02 20:13:51 +02:00
Daniel Eklöf
c2314d689e
grid: reflow: avoid unnecessary if-statements before chunking a row 2021-06-02 20:13:51 +02:00
Daniel Eklöf
2029d201b5
grid: disable reflow timing by default 2021-06-02 20:13:51 +02:00
Daniel Eklöf
ac97f20f99
grid: reflow: comments 2021-06-02 20:13:51 +02:00
Daniel Eklöf
5325ea042d
grid: no need to keep the tp_col/uri_col variables around 2021-06-02 20:13:51 +02:00
Daniel Eklöf
3453f091a3
grid: fix col max calculation when row contains URI ranges 2021-06-02 20:13:51 +02:00
Daniel Eklöf
a56b54ad2f
grid: set tp/uri break flags explicitly when we know them to be true 2021-06-02 20:13:51 +02:00
Daniel Eklöf
4b7e4fb885
grid: reflow: slightly simplified logic for end-coordinate calculation 2021-06-02 20:13:51 +02:00
Daniel Eklöf
315865f18c
grid: reflow: rename _range -> range 2021-06-02 20:13:51 +02:00
Daniel Eklöf
7c3a4b24d9
grid: reflow: remove dead code 2021-06-02 20:13:50 +02:00
Daniel Eklöf
40ca86b2d3
grid: reflow: memcpy() chunks of cells, instead of single cell-by-cell
Instead of walking the old grid cell-by-cell, and checking for
tracking points, OSC-8 URIs etc on each cell, memcpy() sequences of
cells.

For each row, find the end column, by scanning backward, looking for
the first non-empty cell.

Chunk the row based on tracking point coordinates. If there aren’t any
tracking coordinates, or OSC-8 URIs on the current row, the entire row
is copied in one go.

The chunk of cells is copied to the new grid. We may have to split it
up into multiple copies, since not all cells may fit on the current
“new” row.

Care must also be taken to not line break in the middle of a
multi-column character.
2021-06-02 20:13:50 +02:00
Daniel Eklöf
6671d53859
Merge branch 'restore-sighup-handler' 2021-06-02 20:13:26 +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
2f7e5aed40
Merge branch 'dont-split-multi-column-chars-when-resizing-alt-screen' 2021-06-02 20:12:01 +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
363aeea2df
Merge branch 'url-mode-off-by-one' 2021-06-02 08:11:20 +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
19429d13a3
Merge branch 'document-terminfo'
Closes #549
2021-06-02 08:10:19 +02:00
Daniel Eklöf
2ffedc7082
doc: foot{,client}: updates from feedback from @craigbarnes 2021-06-02 08:10:02 +02:00
Daniel Eklöf
1321b23567
doc: footclient.1: -t,--term: add references to ENVIRONMENT and TERMINFO sections 2021-06-02 08:10:02 +02:00
Daniel Eklöf
a1a521b81d
doc: footclient.1: add TERMINFO section 2021-06-02 08:10:02 +02:00
Daniel Eklöf
d6715625e2
doc: foot.1: -t,--term: add references to ENVIRONMENT and TERMINFO sections 2021-06-02 08:10:02 +02:00
Daniel Eklöf
dde31ffaf9
doc: foot.1: add TERMINFO section 2021-06-02 08:09:52 +02:00