Commit Graph

28 Commits

Author SHA1 Message Date
Christian Duerr 28abb1f9c7
Fix out of order terminal query responses
This forces all responses made to the PTY through the indirection of the
UI event loop, making sure that the writes to the PTY are in the same
order as the original requests.

This just delays all escape sequences by forcing them through the event
loop, ideally all responses which are not asynchronous (like a clipboard
read) would be made immediately. However since some escapes require
feedback from the UI to mutable structures like the config (e.g. color
query escapes), this would require additional locking.

Fixes #4872.
2021-04-17 23:20:13 +00:00
Christian Duerr 3bd5ac221a
Unify the grid line indexing types
Previously Alacritty was using two different ways to reference lines in
the terminal. Either a `usize`, or a `Line(usize)`. These indexing
systems both served different purposes, but made it difficult to reason
about logic involving these systems because of its inconsistency.

To resolve this issue, a single new `Line(i32)` type has been
introduced.  All existing references to lines and points now rely on
this definition of a line.

The indexing starts at the top of the terminal region with the line 0,
which matches the line 1 used by escape sequences. Each line in the
history becomes increasingly negative and the bottommost line is equal
to the number of visible lines minus one.

Having a system which goes into the negatives allows following the
escape sequence's indexing system closely, while at the same time making
it trivial to implement `Ord` for points.

The Alacritty UI crate is the only place which has a different indexing
system, since rendering and input puts the zero line at the top of the
viewport, rather than the top of the terminal region.

All instances which refer to a number of lines/columns instead of just a
single Line/Column have also been changed to use a `usize` instead. This
way a Line/Column will always refer to a specific place in the grid and
no confusion is created by having a count of lines as a possible index
into the grid storage.
2021-03-30 23:25:38 +00:00
Christian Duerr 530de00049
Move renderable cell transformation to alacritty
This refactors a large chunk of the alacritty_terminal API to expose all
data necessary for rendering uniformly through the `renderable_content`
call. This also no longer transforms the cells for rendering by a GUI
but instead just reports the content from a terminal emulation
perspective. The transformation into renderable cells is now done inside
the alacritty crate.

Since the terminal itself only ever needs to know about modified color
RGB values, the configuration for colors was moved to the alacritty UI
code.
2021-01-24 21:45:36 +00:00
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
Ayose Cazorla cdf5e51e74
Add escape to report text area size
This implements the escapes `CSI 14 t` and `CSI 18 t` which report the
text area size in pixels and characters.
2020-08-28 22:26:03 +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 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 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 4f5f841296
Remove copypasta dependency from alacritty_terminal 2020-06-07 00:33:20 +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
Christian Duerr 81ce93574f
Extend style guideline documentation 2020-05-05 22:50:23 +00:00
Christian Duerr fde2424b39
Remove `fs::read_to_string` reimplementations
After two previous PRs already removed some instances of
reimplementations of the `fs::read_to_string` functionality, this
removes the last remaining occurence and with it all instances of
`File::open`. So this should remove them all for good.
2020-03-26 14:56:41 +00:00
Matthias Krüger 69ca895176
Remove std::fs::read_to_string reimplementation from tests 2020-03-25 15:08:30 +03: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
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 729eef0c93
Update to winit/glutin EventLoop 2.0
This takes the latest glutin master to port Alacritty to the EventLoop
2.0 rework.

This changes a big part of the event loop handling by pushing the event
loop in a separate thread from the renderer and running both in
parallel.

Fixes #2796.
Fixes #2694.
Fixes #2643.
Fixes #2625.
Fixes #2618.
Fixes #2601.
Fixes #2564.
Fixes #2456.
Fixes #2438.
Fixes #2334.
Fixes #2254.
Fixes #2217.
Fixes #1789.
Fixes #1750.
Fixes #1125.
2019-10-05 02:29:26 +02: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 f51c7b067a
Remove color from log output
Fixes #2474.
2019-08-01 14:26:55 +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
Christian Duerr 5d173f6df3
Refactor config parsing files
This is a large refactor of the config parsing structure, attempting to
reduce the size of the file a bit by splitting it up into different
modules with more specific purposes.

This also fixes #2279.
2019-05-10 11:36:16 +00:00
Christian Duerr 9e89aaa477
Switch from copypasta to rust-clipboard
This switches our own `copypasta` crate with the more standardized
`clipboard` library, which allows us to get rid of the `xclip`
dependency on X11.

Additionally, this lays the foundation for native Wayland clipboard
support once the clipboard crate is updated (or a fork is created).

Fixes #5.
2019-04-28 20:21:39 +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