Commit Graph

7 Commits

Author SHA1 Message Date
Christian Duerr ec42b42ce6
Use dynamic storage for zerowidth characters
The zerowidth characters were conventionally stored in a [char; 5].
This creates problems both by limiting the maximum number of zerowidth
characters and by increasing the cell size beyond what is necessary even
when no zerowidth characters are used.

Instead of storing zerowidth characters as a slice, a new CellExtra
struct is introduced which can store arbitrary optional cell data that
is rarely required. Since this is stored behind an optional pointer
(Option<Box<CellExtra>>), the initialization and dropping in the case
of no extra data are extremely cheap and the size penalty to cells
without this extra data is limited to 8 instead of 20 bytes.

The most noticible difference with this PR should be a reduction in
memory size of up to at least 30% (1.06G -> 733M, 100k scrollback, 72
lines, 280 columns). Since the zerowidth characters are now stored
dynamically, the limit of 5 per cell is also no longer present.
2020-11-05 04:45:14 +00:00
Christian Duerr e18f5a0a2f
Fix cursor reflow
This resolves three different issues with cursor reflow.

The first issue was that the cursor could reach the top of the screen
during reflow, since content was pushed into history despite viewport
space being available. Since the cursor cannot leave the viewport, this
would insert new space between the cursor and content (see #3968).

Another issue was that the wrapline flag was not set correctly with
content being available behind the cursor. Since the cursor is not
necessarily at the end of the line, it is possible that the cursor
should reflow to the next line instead of staying on the current one and
setting the wrapline flag.

The last bug fixed in this is about reflow with content available behind
the cursor. Since that might have en effect on new lines being inserted
and deleted below the cursor, the cursor needs to be reflown based on
it.

Fixes #3968.
2020-07-15 02:33:48 +00:00
Christian Duerr 5424b30d22
Fix crash on cursor resize
Fixes #3960.
2020-07-14 00:30:17 +00:00
Christian Duerr 46c0f352c4
Add regex scrollback buffer search
This adds a new regex search which allows searching the entire
scrollback and jumping between matches using the vi mode.

All visible matches should be highlighted unless their lines are
excessively long. This should help with performance since highlighting
is done during render time.

Fixes #1017.
2020-07-09 21:45:22 +00:00
Christian Duerr 9974bc8baa
Fix cursor reflow
To make sure that output is consistent even while resizing the window,
the cursor will now reflow with the content whenever the window size is
changed.

Since the saved cursor is more likely to represent a position in the
grid rather than a reference to the content below it and handling of
resize before jumping back to it is more likely than with the primary
cursor, no reflow is performed for the saved cursor

The primary cursor is unfortunately always reflowed automatically by
shells like zsh, which has always caused problems like duplicating parts
of the prompt and stretching it out "infinitely". Since the cursor is
now reflowed appropriately the duplication of the shell prompt should be
reduced, however it is possible that the shell moves the cursor up one
line after it has already been reflowed, which will cause a line of
history to be deleted if there is no duplicated prompt line above the
reflowed prompt. Since this behavior is identical in VTE and Kitty, no
attempt is made to work around it in this patch.

Fixes #3584.
2020-07-09 05:16:20 +03:00
Christian Duerr bc60782e42
Fix reflow of empty wrapped cursor line
This bug was caused by trying to grow the terminal while the cursor line
was wrapped but entirely empty. Resizing the terminal now accounts for
the position of the deleted line and moves the cursor up only when the
line deleted was above it.

The deletion of the line was caused by the shell redrawing itself
whenever the cursor is moved.

Fixes #3583.
2020-07-01 09:58:06 +03:00
Christian Duerr 1dacc99183
Refactor Term/Grid separation
This commit aims to clear up the separation between Term and Grid to
make way for implementing search.

The `cursor` and `cursor_save` have been moved to the grid, since
they're always bound to their specific grid and this makes updating
easier.

Since the selection is independent of the active grid, it has been moved
to the `Term`.
2020-05-30 20:45:44 +00:00