Commit Graph

17 Commits

Author SHA1 Message Date
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 8ed72cc065
Remove Windows WinPTY backend 2021-01-01 05:07:39 +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
Christian Duerr 142f84efb9
Add support for searching without vi mode
This implements search without vi mode by using the selection to track
the active search match and advancing it on user input. The keys to go
to the next or previous match are not configurable and are bound to
enter and shift enter based on Firefox's behavior.

Fixes #3937.
2020-07-15 21:27:32 +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 7aafbb757d
Remove copyright notice from files
Keeping the license as part of every file bloats up the files
unnecessarily and introduces an additional overhead to the creation of
new modules.

Since cargo already provides excellent dependency management, most of
the code-reuse of Alacritty should occur through Rust's dependency
management instead of copying it source.

If code is copied partially, copying the license from the main license
file should be just as easy as copying from the top of the file and
making some adjustments based on where it is used is likely necessary
anyways.
2020-06-06 21:49:14 +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 64a3115648
Fix selection with invisible start and end
This resolves an issue with the selection clamping, where no selection
would be rendered at all when the start was above the viewport while the
end was below it.
2020-03-07 22:17:38 +00:00
Christian Duerr 3fb631b91c
Fix cut off full width glyphs in last column
This resolves the issue with full width glyphs getting rendered in the
last column. Since they need at least two glyphs, it is not possible to
properly render them in the last column.

Instead of rendering half of the glyph in the last column, with the
other half cut off, an additional spacer is now inserted before the wide
glyph. This means that the specific glyph in question is then three
cells wide.

Fixes #2385.
2020-01-09 23:06:41 +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
Christian Duerr 9dddf649a1
Switch to rfind_url for URL detection
This switches to rfind_url for detecting URLs inside the grid. Instead
of expanding at the cursor position, the complete terminal is searched
from the bottom until the visible region is left with no active URL.

Instead of having the field `cur` publicly accessibly on the
`DisplayIterator`, there are the two methods `DisplayIterator::point`
and `DisplayIterator::cell` for accessing the current element of the
iterator now. This allows accessing the current element right after
creating the iterator.

Fixes #2629.
Fixes #2627.
2019-08-01 15:37:01 +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 f002171c84
Fix performance issues with text reflow
Fixes #2567.
Fixes #2414.
2019-06-23 23:29:01 +00:00
JDTX 2c462c7d03 Fix spelling mistakes 2019-04-28 21:42:43 +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