Commit graph

2020 commits

Author SHA1 Message Date
Daniel Eklöf
483ea4ae73
scrolling: fix crash when offset was exactly at the wrap-around
When making sure we don't scroll past the scrollback history, and the
current offset was exactly at the wrap around, the new view port was
set to offset+1, which in this particular case meant outside the valid
row numbers.
2020-05-19 18:51:56 +02:00
Daniel Eklöf
8ad3b9c172
selection: performance: check for < 0 or >= 0 instead of == -1 2020-05-19 18:51:30 +02:00
Daniel Eklöf
08588cd0fc
selection: handle viewport wrap around correctly
When the viewport wraps around, the selection points may be
"incorrect".
2020-05-19 18:49:42 +02:00
Daniel Eklöf
550667a9ea
term: scrolling: calling function must clamp scroll amount 2020-05-19 18:47:38 +02:00
Daniel Eklöf
dea36de7e3
readme: add suggested cflags for a release build 2020-05-18 19:01:22 +02:00
Daniel Eklöf
33346ba02d
term: erase_cell_range: set row->dirty before calling memset() 2020-05-17 16:29:09 +02:00
Daniel Eklöf
52e6a751b3
term: scrolling: mark selection top if-statement as 'unlikely' 2020-05-17 15:48:58 +02:00
Daniel Eklöf
96a4f1b993
term: scrolling: hopefully fix all selection/scrolling related crashes
When scrolling, there are a couple of cases where an existing
selection must be canceled because we cannot meaningfully represent it
after scrolling.

These are when the selection is (partly) inside:

* The top scrolling region
* The bottom scrolling region
* The new lines scrolled in. I.e. re-used lines

For the scrolling regions, the real problem is when the selection
crosses the scrolling region boundary; a selection that is completely
inside a scrolling regions _might_ be possible to keep, but we would
need to translate the selection coordinates to the new scrolling
region lines.

For simplicity, we cancel the selection if it touches the scrolling
region. Period.

The last item, newly scrolled in lines is when the selection covers
very old lines and we're now wrapping around the scrollback history.

Then there's a fourth problem case: when the user has started a
selection, but hasn't yet moved the cursor. In this case, we have no
end point.

What's more problematic is that when the user (after scrolling) moves
the cursor, we try to create a huge selection that covers mostly
empty (NULL) rows, causing us to crash.

This can happen e.g. when reverse scrolling in such a way that we wrap
around the scrollback history.

The actual viewport in this case is something like `-n - m`. But the
selection we'll end up trying to create will be `m - (rows - n)`. This
range may very well contain NULL rows.

To deal with this, we simply cancel the selection.
2020-05-17 15:34:49 +02:00
Daniel Eklöf
5d643e63fe
selection: on_rows_in_view: fix range check 2020-05-17 12:04:08 +02:00
Daniel Eklöf
8f9e6127da
term: scrolling: sixel: simplify now that row count is clamped 2020-05-17 11:46:44 +02:00
Daniel Eklöf
cfd0b5d2d8
term: scrolling: in debug builds, verify all rows are allocated 2020-05-16 23:53:23 +02:00
Daniel Eklöf
ebd867372a
term: scrolling: simplify, now that scroll row count is clamped 2020-05-16 23:53:03 +02:00
Daniel Eklöf
a4f5938123
term: scrolling: clamp number of rows to number of rows in scrolling region 2020-05-16 23:44:54 +02:00
Daniel Eklöf
57e04a1320
grid: swap_row: remove unused parameter 'initialize' 2020-05-16 23:43:05 +02:00
Daniel Eklöf
6902c22a77
selection: copy: insert line break if either cell is empty 2020-05-16 22:29:53 +02:00
Daniel Eklöf
1a8ccb0ffa
selection/render: sync cells' 'selected' bit before rendering
For performance reasons, we track whether a cell is selected or not
using a bit in a cell's attributes.

This makes it easy for the renderer to determine if the cells should
be rendered as selected or not - it just have to look at the
'selected' bit instead of doing a complex range check against the
current selection.

This works nicely in most cases. But, if the cell is updated, the
'selected' bit is cleared. This results in the renderer rendering the
cell normally, i.e. _not_ selected.

Checking for this, and re-setting the 'selected' bit when the cell is
updated (printed to) is way too expensive as it is in the hot path.

Instead, sync the 'selected' bits just before rendering. This isn't so
bad as it may sound; if there is no selection this is a no-op. Even if
there is a selection, only those cells whose 'selected' bit have been
cleared are dirtied (and thus re-rendered) - these cells would have
been re-rendered anyway.
2020-05-16 21:36:08 +02:00
Daniel Eklöf
a1c95562fb
term: scrolling: clear selection *before* scrolling
We normally don't clear the selection when scrolling. The exception is
when the selection covers re-used rows. I.e. rows that we scroll in
and clear.

In this case we cancel the selection (we _could_ modify it and keep as
much as possible and only remove the re-used rows...). We must do
this *before* scrolling, since scrolling will swap rows (when there's
a scrolling region). When this happens, the selection is "corrupted",
and canceling it afterwards will not work.
2020-05-16 21:27:56 +02:00
Daniel Eklöf
e3992b8379
selection: update: don't assert on 'start' being set 2020-05-16 21:16:35 +02:00
Daniel Eklöf
e4a2d41f51
selection: don't automatically no-op operations if selection isn't enabled
When the client is capturing the mouse, selection can only be done by
holding done shift.

This is why a lot of selection functions are no-ops if selection isn't
currently enabled.

However, there are many cases where we actually need to modify the
selection. In particular, selection_cancel().

Thus, only check for enabled selection when we're dealing with user
input.

Bonus: this also fixes a bug where an ongoing selection were finalized
as soon as the user released shift, even if he was still holding down
the mouse button.
2020-05-16 21:16:11 +02:00
Daniel Eklöf
38c050746d
selection: on_row_in_view() -> on_rows_in_view(), and now takes a range
This allows us to check the selection once when scrolling, instead of
once for each scrolled in line.
2020-05-16 21:16:11 +02:00
Daniel Eklöf
b647aa447b
render: only apply transparency to the default background color 2020-05-16 16:26:52 +02:00
Daniel Eklöf
0c9b679958
readme: add 'synchronized updates' to feature list
The support in foot isn't new, but let's make it more visible.
2020-05-16 14:16:38 +02:00
Daniel Eklöf
6deae0b07a
terminfo: add tmux extension 'Sync' - indicates 'Synchronized Updates' support 2020-05-16 14:13:45 +02:00
Daniel Eklöf
0955cee902
changelog: prepare for the next, unreleased version 2020-05-13 13:22:19 +02:00
Daniel Eklöf
8bea5855b1
Merge branch 'releases/1.3' 2020-05-13 13:21:34 +02:00
Daniel Eklöf
3ed177bb39
meson/PKGBUILD: bump version to 1.3.0 2020-05-13 13:10:08 +02:00
Daniel Eklöf
9b7b4878f1
changelog 1.3.0 2020-05-13 13:09:12 +02:00
Daniel Eklöf
e654cf3880
slave: configure pts to be the controlling terminal of the forked process 2020-05-13 13:07:44 +02:00
Daniel Eklöf
980606233b
Merge branch 'fcft-precompose' 2020-05-13 13:03:20 +02:00
Daniel Eklöf
6d0f8e52cb
wayland: force-trigger a resize on 'configured' event
This ensures we _always_ commit a **new** buffer in response to a
configured event.

This fixes an issue in Gnome where e.g. tiling the window (on the
left/right side) only worked if that caused the windows size to
change.
2020-05-12 18:35:28 +02:00
Daniel Eklöf
f156f3f4bd
readme: use unicode RIGHT ARROW instead of '->' 2020-05-10 17:36:15 +02:00
Daniel Eklöf
8d7eab9fb9
readme: short section describing the origins of the name 'foot' 2020-05-10 17:33:48 +02:00
Daniel Eklöf
00df12f1a3
unicode-combine: simplify - remove -Dunicode-precompose option
Since the pre-composing functionality is now part of fcft, it makes
little sense to have a compile time option - there's no size benefit
to be had.

Furthermore, virtually all terminal emulators do
pre-composing (alacritty being an exception), this really isn't that
controversial.
2020-05-10 17:10:33 +02:00
Daniel Eklöf
c7b031e177
generate-unicode-precompose: /bin/sh is more standard than /usr/bin/sh
At the same time, fix `cut` command to pass filename last, as this is
also more portable.

Fixes build issues on e.g. Alpine Linux
2020-05-09 12:42:40 +02:00
Daniel Eklöf
77e256763c
readme: unicode-combining: mention when we render the decomposed version 2020-05-09 12:06:11 +02:00
Daniel Eklöf
cce76909c4
meson/PKGBUILD: we now require fcft-2.1.0 2020-05-09 12:06:11 +02:00
Daniel Eklöf
718ba1602a
meson: explicitly define _POSIX_C_SOURCE 2020-05-09 12:06:11 +02:00
Daniel Eklöf
b1b32152c1
unicode-precompose: use fcft's precompose functionality
This allows us more options when determining whether to use a
pre-composed character or not:

We now only use the pre-composed character if it's from the primary
font, or if at least one of the base or combining characters are from
a fallback font.

I.e. use glyphs from the primary font if possible. But, if one or more
of the decomposed glyphs are from a fallback font, use the
pre-composed character anyway.
2020-05-09 12:06:11 +02:00
Daniel Eklöf
c090a0664f
Revert "term: print: line-wrap multi-column characters instead of cutting them in half"
This reverts commit 8448296bb3.

Applications need to be multi-column character aware anyway, and they
should deal with this.
2020-05-09 12:04:55 +02:00
Daniel Eklöf
8448296bb3
term: print: line-wrap multi-column characters instead of cutting them in half 2020-05-09 11:57:19 +02:00
Daniel Eklöf
2e7ead42de
completions: zsh: complete command/shell, and its arguments 2020-05-08 18:45:05 +02:00
Daniel Eklöf
5b70f94827
main/client: be POSIXLY_CORRECT when parsing command line
This means command line parsing stops when it encounters the first
nonoption argument.

The result is that one no longer need to use '--' to ensure arguments
are passed to the shell/command, instead of parsed by foot.

That is, instead of

  foot -- sh -c true

one can now do

  foot sh -c true

Arguments to foot *must* go before the command:

  foot --fullscreen sh -c true
2020-05-08 18:43:03 +02:00
Daniel Eklöf
56d53ec2a1
term: don't register ptmx with FDM if we're shutting down
This can happen when there's an error instantiating the
terminal *after* we've spawned the slave process.
2020-05-04 20:49:28 +02:00
Daniel Eklöf
9864d91975
term: set 'is_shutting_down' before calling term_destroy() on error 2020-05-04 20:46:27 +02:00
Daniel Eklöf
af9e5aef2b
csi: ignore invalid parameters in 'CSI Ps <space> q'
Before this patch, an invalid parameter would not change the cursor
style, but could cause the cursor to start (or stop) blinking.
2020-05-04 20:19:24 +02:00
Daniel Eklöf
921331854a
term: check return value when instantiating thread synchronization primitives 2020-05-04 20:11:45 +02:00
Daniel Eklöf
728db1df0e
meson: use find_program() to find 'tic' 2020-05-03 16:39:10 +02:00
Daniel Eklöf
6bac1bd257
term: thrd_success isn't necessarily 0 2020-05-03 14:17:54 +02:00
Daniel Eklöf
729a57d3a8
util: thrd_err_as_string: fix alignment 2020-05-03 12:40:40 +02:00
Daniel Eklöf
7525fa20c2
thrd_create(): handle errors correctly
* Detect thrd_create() failures in all places where we instantiate
  threads
* Log error correctl; thrd_create() does not return an errno value
2020-05-03 12:25:04 +02:00