Commit graph

3980 commits

Author SHA1 Message Date
Daniel Eklöf
ee75e10e71
term: term_print(): clear line break flag
The line break flag is used by the text reflow and text
extraction (i.e. copy-paste) logic, to determine whether or not to
insert a newline between two lines.

There’s some amount of heuristics involved in this. For example, the
client application could emit a newline, move the cursor back up, and
print text. What does that mean for us?

Foot’s behavior up until now has been this:

The line break flag is set on the row, when the application emits an
explicit linefeed. The flag is cleared when the line is erased. But
otherwise not.

This meant that emitting a linefeed and then moving the cursor back up
and printing text, did not clear the line break flag. This in turn
meant that text copied always had newlines inserted, even though that
was not the client applications intention.

By clearing the line break flag whenever _anything_ is printed to a
row, the new behavior is, in practice, that the line break flag is
only set on a row if a linefeed was that *last* thing printed to that
row.

Closes #410
2021-03-23 11:02:51 +01:00
Daniel Eklöf
deaf17e01d
Merge branch 'zoom-line-height' 2021-03-21 16:29:51 +01:00
Daniel Eklöf
7609fbba47
term: increase/decrease custom line-height with font size changes
When the user has set a custom line-height, we now adjust it when
increasing/decreasing (“zooming”) the font size at run-time.

Previously, the line-height was fixed at the size specified in
foot.ini.
2021-03-21 16:29:35 +01:00
Daniel Eklöf
57a663a0c7
Merge branch 'match-all-required-modifiers-before-unshifting-symbol'
Closes #407
2021-03-21 16:22:44 +01:00
Daniel Eklöf
0c85905972
input: must have all required modifiers to un-shift a symbol
When detecting, and repairing, “broken” key bindings (where the key
binding itself explicitly lists a modifier that is consumed by the
final symbol - e.g “Shift+W”), don’t just look for an intersection
between the set of modifiers needed to produce the final symbol, and
the modifiers listed in the key combo. Instead, check if the key combo
has *all* the required modifiers.

Example: Shift+AltGr+w produces Page_Down. I.e. Page_Down is the
_shifted_ symbol, ‘w’ is the un-shifted symbol, and Shift+AltGr are
the modifiers required to shift ‘w’ to Page_Down.

If we have the key combo Shift+Page_Down, foot would, correctly,
determine that Page_Down is a shifted symbol. It would find the
Shift+AltGr modifier set, and since the intersection of “Shift+AltGr”
and “Shift” (from our key combo) is non-empty, foot
would (incorrectly) determine that we can, and should, replace
Page_Down with its un-shifted symbol ‘w’.

This is completely wrong, since Shift+w does _not_ produce Page_Down.

Closes #407
2021-03-21 16:22:08 +01:00
Daniel Eklöf
eccf2b674e
doc: benchmark: update "workstation" benchmarks with 1.7.0 results 2021-03-21 00:01:17 +01:00
Daniel Eklöf
5f1d56bccc
doc: benchmark: updated “laptop” benchmark with 1.7.0 results 2021-03-20 23:58:22 +01:00
Daniel Eklöf
3fbbf5f81f
changelog: add new ‘unreleased’ section 2021-03-20 14:14:58 +01:00
Daniel Eklöf
d104bc01b0
Merge branch 'releases/1.7' 2021-03-20 14:13:41 +01:00
Daniel Eklöf
be6f7ff934
changelog: 1.7.0 2021-03-20 14:02:12 +01:00
Daniel Eklöf
c1a64bfb14
meson/pkgbuild: bump version to 1.7.0 2021-03-20 14:01:29 +01:00
Daniel Eklöf
207d9045ca
Merge branch 'add-bash-completions'
Closes #10
2021-03-17 19:45:11 +01:00
Simon Schricker
b169623b64
Add: Bash completion for foot and footclient
* use toe for terminfo, thanks Craig.
* adds optional dependency on bash-completion for positional arguments

Co-authored-by: Craig Barnes <craigbarnes@protonmail.com>
2021-03-17 13:10:28 +01:00
Daniel Eklöf
749ae49c48
Merge branch 'optimized-print-function' 2021-03-16 21:59:06 +01:00
Daniel Eklöf
d271119032
csi: update ASCII printer function pointer when switching to/from alt screen
This is necessary since switching screen may change how many sixels we
have in the scrollback.
2021-03-16 13:07:09 +01:00
Daniel Eklöf
b601307fae
term: update_ascii_printer(): log when we (actually) switch printer 2021-03-16 12:57:25 +01:00
Daniel Eklöf
11f2c85acf
config: open_config(): remove unused argument ‘conf’ 2021-03-16 09:54:32 +01:00
Daniel Eklöf
60b3ccc641
term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print function
term_print() is called whenever the client application “prints”
something to the grid. It is called for both ASCII and UTF-8
characters, and needs to handle sixels, insert mode and ASCII
vs. graphical charsets.

Since it’s on the hot path, this becomes unnecessarily slow.

This patch adds a “fast” version of term_print(), tailored for the
common case: ASCII characters in non-insert mode, without any sixels
and non-graphical charsets.

A new function, term_update_ascii_printer(), has been added, and must
be called whenever:

* The currently selected charset *index* changes
* The currently selected charset changes (from ASCII to graphical, or
  vice verse)
* Sixels are added to the grid
* Sixels are removed from the grid
* Insert mode is enabled/disabled
2021-03-16 08:45:18 +01:00
Daniel Eklöf
d8f0e701b5
Merge branch 'term-print-assume-col-can-be-incremented' 2021-03-16 08:44:25 +01:00
Daniel Eklöf
2451699c35
term: term_print(): assume we’re *not* at the right margin
That is, assume we can, and should, increment the cursor column.

This changes the emitted assembly from:

   518fb:       8b 8b f8 05 00 00       mov    0x5f8(%rbx),%ecx
   51901:       ff c9                   dec    %ecx
   51903:       39 d1                   cmp    %edx,%ecx
   51905:       7e 11                   jle    51918 <term_print.constprop.0+0x78>
   51907:       ff c2                   inc    %edx
   51909:       89 50 10                mov    %edx,0x10(%rax)
   5190c:       5b                      pop    %rbx
   5190d:       5d                      pop    %rbp
   5190e:       41 5c                   pop    %r12
   51910:       c3                      ret
   51911:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)
   51918:       c6 40 18 01             movb   $0x1,0x18(%rax)
   5191c:       5b                      pop    %rbx
   5191d:       5d                      pop    %rbp
   5191e:       41 5c                   pop    %r12
   51920:       c3                      ret

To:

   5191c:       41 8d 50 01             lea    0x1(%r8),%edx
   51920:       89 50 10                mov    %edx,0x10(%rax)
   51923:       3b 93 f8 05 00 00       cmp    0x5f8(%rbx),%edx
   51929:       0f 8d 21 01 00 00       jge    51a50 <term_print.constprop.0+0x190>
   5192f:       5b                      pop    %rbx
   51930:       5d                      pop    %rbp
   51931:       41 5c                   pop    %r12
   51933:       c3                      ret
   ...
   51a50:       c6 40 18 01             movb   $0x1,0x18(%rax)
   51a54:       44 89 40 10             mov    %r8d,0x10(%rax)
   51a58:       5b                      pop    %rbx
   51a59:       5d                      pop    %rbp
   51a5a:       41 5c                   pop    %r12
   51a5c:       c3                      ret

I.e. it cuts the normal path from 10 instructions down to 8. It
increases the "bad" path with one extra instruction.
2021-03-14 20:47:44 +01:00
Daniel Eklöf
c5c3447ca8
sixel: sixel_overwrite_at_cursor(): early exit when the image list is empty
This avoids a call to sixel_overwrite_by_row() (where we also exit
early if the image list is empty).

This saves a couple of instructions to set up the arguments for
sixel_overwrite_by_row().
2021-03-14 14:19:12 +01:00
Daniel Eklöf
2a723e1c4c
Merge branch 'sixel-fix-max-geometry' 2021-03-14 13:07:13 +01:00
Daniel Eklöf
e7a4378f18
Merge branch 'option-no-wait'
Closes #395
2021-03-14 13:05:41 +01:00
Daniel Eklöf
6eb68ffbd9
sixel: max geometry should be max geometry, not current window size
“current geometry” will report whatever value is the smallest; the max
geometry or the current window size.

But “max geometry” always returns the configured max geometry.

This aligns foot’s behavior with XTerm.
2021-03-14 10:58:13 +01:00
Daniel Eklöf
29709c6966
scripts: generate-alt-random: reduce number of emitted sixels
After emitting multiple color bands for each sixel row, the increased
amount of sixel data shifted the balance in the profiling data,
causing a performance regression in regular ASCII handling.
2021-03-14 10:40:29 +01:00
Daniel Eklöf
4fca142f71
Merge branch 'drain-pty-when-client-terminates' 2021-03-13 21:36:30 +01:00
Felipe Trzaskowski
452830bd08 add changelog entry, completions and man entry for -N, --no-wait 2021-03-13 08:07:08 -03:00
Felipe Trzaskowski
2dc13cc13b fix code style issues and memory leak 2021-03-13 08:01:38 -03:00
Felipe Trzaskowski
3ed9314266 add option to detach the client process from the terminal instance 2021-03-13 05:48:55 -03:00
Daniel Eklöf
329f2a488c
term: don’t close PTY when client application dies
Closing it as soon as we detect that the client has died, means we may
not have drained it completely.

The PTY is either closed _by_ the client application, or by us when we
shutdown the terminal. Thus, leaving it open (until we call
term_shutdown()) is fine.
2021-03-12 22:06:50 +01:00
Daniel Eklöf
464851fac1
client: repair usage output 2021-03-12 21:53:11 +01:00
Daniel Eklöf
84f840a197
client: remove excess ‘-’ from ‘--log-level’ in usage 2021-03-12 21:51:07 +01:00
Daniel Eklöf
ebc57d1a80
changelog: sixel decoding performance improvements 2021-03-12 21:43:35 +01:00
Daniel Eklöf
f19e1e4c36
Merge branch 'sixel-background-and-transparency'
Closes #391
2021-03-12 21:42:17 +01:00
Daniel Eklöf
5a9ae07167
changelog: implemented DCS parameter P2 2021-03-11 17:37:56 +01:00
Daniel Eklöf
655e756f58
render: sixels: render cursor, if it’s partially covered by an opaque sixel 2021-03-11 17:34:19 +01:00
Daniel Eklöf
7d315d7bf9
sixel: implement P2=1 - transparent pixels
When P2=1, empty pixels are transparent.

This patch also changes the behavior of P2=0|2, from setting empty
pixels to the default background color, to instead use the *current*
background color.

To implement this, a couple of changes are needed:

* Sixel pixels always use alpha=1.0, except for *empty* cells when
  P2=1 (i.e. transparent pixels).
* The renderer draws sixels with the OVER operator, instead of the SRC
  operator.
* The renderer *must* now render the cells beneath the sixel. As an
  optimization, this is only done for sixels where P2=1. I.e. for
  fully opaque sixels, there’s no need to render the cells beneath.

The sixel renderer isn’t yet hooked into the multi-threaded
renderer. This means *rows* (not just the cells) beneath
maybe-transparent sixels are rendered single-threaded.

Closes #391.
2021-03-11 17:34:19 +01:00
Daniel Eklöf
5650120e08
Merge branch 'sixel-optimize' 2021-03-11 17:33:41 +01:00
Daniel Eklöf
5e852f148e
changelog: empty pixel rows at the bottom of a sixel is now trimmed 2021-03-11 17:33:01 +01:00
Daniel Eklöf
6f6bcbc1bc
sixel: decgra: set max-non-empty-row-no when resizing the image
This ensures we don’t trim off bottom rows in unhook().

This could happen either because the application used “Set Raster
Attributes” to configure an image size larger than the sixels later
emitted.

Or, the last sixel row contains empty pixel rows.

In either case, the size set with “Set Raster Attributes” defines
the *minimum* image size; the image may still end up being larger.
2021-03-11 17:33:01 +01:00
Daniel Eklöf
a8186351d1
generate-alt-random: sixel: emit at least 4 color bands
This fixes an issue where there was a relatively high chance of not
emitting any color bands at all, causing the final image size to be
too small.
2021-03-11 17:33:01 +01:00
Daniel Eklöf
f3bc5a95b5
generate-alt-random: DECGRI: don’t emit zero-length repeat sequences 2021-03-11 17:33:00 +01:00
Daniel Eklöf
8ba455f70e
generate-alt-random: DECGRI: random repeat lengths 2021-03-11 17:33:00 +01:00
Daniel Eklöf
660a7f9345
generate-alt-random: don’t skip that last partial row 2021-03-11 17:33:00 +01:00
Daniel Eklöf
0bc98877f3
generate-alt-random: emit “Set Raster Attributes” before color definitions 2021-03-11 17:33:00 +01:00
Daniel Eklöf
a3f2e2220a
generate-alt-random: 50% chance of overwriting the last sixel 2021-03-11 17:33:00 +01:00
Daniel Eklöf
4a86cd7475
generate-alt-random: emit sixels on the alt screen 2021-03-11 17:32:59 +01:00
Daniel Eklöf
f8e51fcb17
generate-alt-random: emit multiple sixel bands
This ensures we’re getting the ‘$’ command PGO:d
2021-03-11 17:32:59 +01:00
Daniel Eklöf
ae86043780
sixel: decgri: handle a repeat count of 0, by ignoring it 2021-03-11 17:32:59 +01:00
Daniel Eklöf
eee216f5fe
generate-alt-random: sixel: pan/pad must not be 0 2021-03-11 17:32:59 +01:00