Commit Graph

18 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
ii41 a754d06b44
Add support for single line terminals
This changes the minimum terminal dimensions from 2 lines and 2 columns,
to 1 line and 2 columns.

This also reworks the `SizeInfo` to store the number of columns and
lines and consistently has only the terminal lines/columns stored,
instead of including the message bar and search in some places of the
Alacritty renderer/input.

These new changes also make it easy to properly start the selection
scrolling as soon as the mouse is over the message bar, instead of
waiting until it is beyond it.

Fixes #4207.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
2020-09-27 22:36:08 +00:00
Christian Duerr b904207b19
Add support for double underlines
This adds support for double underlines using the colon separated escape
sequence `CSI 4 : 2 m`.

Alacritty will now also always fallback to the normal underline in case
any of the other underlines like the undercurl are specified. The escape
sequence `CSI 4 : 0 m` can now be used to clear all underlines.

Some terminals support `CSI 21 m` for double underline, but since
Alacritty already uses that as cancel bold which is a little more
consistent, that behavior has not changed. So the colon separated
variant must be used.
2020-08-12 19:05:22 +03:00
Christian Duerr 576252294d
Add support for colon separated SGR parameters
This implements the colon separated form of SGR 38 and 48.

Fixes #1485.
2020-08-07 22:37:23 +00:00
Christian Duerr 65bff1878f
Fix saved cursor handling
This resolves several problems with handling of the saved cursor when
switching between primary and alternate screen. Additionally ref-tests
are also added for all common interactions to make sure the behavior
does not regress.

The behavior is based on XTerm's behavior except for interaction with
`reset`. XTerm does not reset the alternate screen's saved cursor on
`reset`, but VTE does. Since a `reset` should reset as much as possible,
Alacritty copies VTE here instead of XTerm.
2020-07-06 19:10:06 +00:00
Christian Duerr 72c916ff43
Preserve linewrap flag across alt screen switches
While neither VTE, URxvt nor Kitty handle this, preserving the linewrap
flag across alternate screen switches seems like the correct thing to
do. XTerm also does handle this correctly, which indicates that it is a
bug and not a feature.
2020-07-06 05:08:36 +00:00
Christian Duerr 6c8966f426
Fix scroll down escape pulling lines from history
This works around a bug where the optimized version of the
`Grid::scroll_down` function would just rotate the entire grid down if
the scrolling region starts at the top of the screen, even if there is
history available.

Since rotations of scrolling regions should not affect the scrollback
history, this optimized version is now only called when the max
scrollback size is 0, making it impossible for the grid to have any
history while it is used.

Since the main usecase of this is the alternate screen buffer, which
never has any history, the performance should not be affected negatively
by this change.

Fixes #3582.
2020-06-25 09:50:17 +00:00
Kirill Chibisov 4cc6421daa Fix incorrect grid.len() and grid.history_size() 2020-01-26 14:49:58 +01:00
Kirill Chibisov 5aaa350e1a Update outdated reftests 2020-01-04 23:55:10 +00:00
Christian Duerr 9da0c042d4
Fix screen reset not clearing cell flags 2019-12-24 20:51:06 +00:00
Christian Duerr 36185c4753
Fix colored row reset performance
This fixes a bug where a row would always get reset completely if its
background does not equal the default terminal background. This leads to
big performance bottlenecks when running commands like `echo "\e[41m" &&
yes`.

Instead of resetting the entire row whenever the template cell is not
empty, the template cell is now compared to the last cell in the row.
The last cell will always be equal to the previous template cell when
`row.occ < row.inner.len()` and if `occ` is equal to the row's length,
the entire row is always reset anyways.

Fixes #2989.
2019-12-10 00:35:13 +01:00
Kirill Chibisov 495a6f3526 Fix cell reset not clearing flags and foreground
Fixes #2330.
2019-11-17 01:04:16 +01:00
Christian Duerr d741d3817d
Add reftest for line deletion 2019-11-15 23:37:24 +01:00
Christian Duerr 0ac3481f83
Add ref test for verifying colored clear behavior
This covers the behavior of clearing the screen and a row with colored
cells.

This covers a bug discovered in #2329 which was not detected in any
existing ref tests.
2019-11-10 20:26:39 +01:00
Christian Duerr 93e87eb0f1
Fix incorrect cell foreground when clearing screen
This fixes a bug that would clear the cells with the current template
cell with just the `flags` reset, to make sure the colors are correct.
However, the cell foreground was not reset, leading to cells counting as
occupied when resizing.

With this change both cell flags and foreground color are ignored when
clearing both the whole screen and inside the line, allowing us to
accurately keep track of cell occupation.

Fixes #2866.
2019-11-04 00:14:23 +01:00
Koichi Murase 33cfc52909 Ignore unsupported CSI sequences
Instead of ignoring unexpected intermediates in CSI escape sequences,
the intermediates are now explicitly checked and the escape sequence is
rejected when an unexpected intermediate is found.

Fixes #2171.
2019-08-06 22:59:16 +00:00
Christian Duerr c4d2725e14
Fix row occ not set during new and reset
Since ref tests were only stored whenever winit requested the window
close, they would not get stored properly when the terminal was closed
through Alacritty using `exit`, Ctrl+D or similar.

This moves the ref test code to the and of the main entry point, which
will always be executed regardless of how the terminal was shutdown.

Fixes #2613.
2019-07-10 21:17:20 +00:00
Theodore Dubois dbd8538762 Split alacritty into a separate crates
The crate containing the entry point is called alacritty, and the crate
containing everything else is called alacritty_terminal.
2019-04-28 13:24:58 +00:00