aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid
AgeCommit message (Collapse)Author
2024-03-12Fix hint `Select` action for hyperlink escapeChristian Duerr
This fixes an issue where the `Select` action for hyperlink escape text would select the entire line, instead of selecting only the hyperlink itself. It also changes the way hyperlinks with the same ID are highlighted, removing the restriction of being on consecutive lines and instead highlighting all visible cells that correspond to the matching hyperlink. Closes #7766.
2024-02-14Fix regional scrolling leaking into historyChristian Duerr
This fixes an issue where a scrolling region that does not start at the top of the screen would still rotate lines into history when scrolling the content "upwards".
2024-02-11Fix row indexing with inclusive rangesAlexandru Placinta
2023-11-10Remove `alacritty_config` from alacritty_terminalKirill Chibisov
There's no need to force alacritty's user configuration on other users of the crate, thus provide the options actually used by alacritty_terminal itself.
2023-10-25Fix typosPavel Roskin
2023-06-17Fix the crash when shrinking scrolled terminalKirill Chibisov
display_offset was adjusted unconditionally, thus it could go beyound the history limits, so clamp it to history like we do in grow_colums. Fixes #6862.
2022-07-25Fix clippy warningsChris Copeland
2022-07-20Replace `map().unwrap_or()` with `map_or()`Chris Copeland
Use a `map_or` instead of a `map().unwrap_or()` chain.
2022-07-10Add support for hyperlink escape sequenceKirill Chibisov
This commit adds support for hyperlink escape sequence `OSC 8 ; params ; URI ST`. The configuration option responsible for those is `hints.enabled.hyperlinks`. Fixes #922.
2022-06-15Use `MaybeUninit<usize>` instead of `usize` in `Storage::swap`nils
`Row` contains pointer bytes, which are not valid for `usize`, therefore `MaybeUninit<usize>` should be used instead to do an untyped copy.
2022-05-20Enable damage tracking only on WaylandKirill Chibisov
Other platforms don't have such concepts in general or have them via different interfaces not related to EGL. This commit also resolves some minor clippy issues. Fixes #6051. Co-authored-by: Christian Duerr <contact@christianduerr.com>
2021-12-18Keep history position when viewport is cleareda5ob7r
This patch resolves a behavior that display area doesn't keep track of content in a scrollback buffer due to display offset reset when viewport clear is invoked. This is similar to #5341, but this problem is caused by viewport clear instead of new outputs to the viewport.
2021-12-03Fix crash when vi cursor in history during cleara5ob7r
Fixes #5544.
2021-10-11Update rustfmt configurationChristian Duerr
In this change I went through all current rustfmt configuration options and expanded our existing configuration with overrides whenever deemed appropriate. The `normalize_doc_attributes` option is still unstable, but seems to work without any issues. Even when passing macros like `include_str!` that is recognized properly and not normalized. So while this wasn't an issue anywhere in the code, it should make sure it never will be. When it comes to imports there are two new major additions. The `imports_granularity` and `group_imports` options. Both mostly just incorporate unwritten rules that have existed in Alacritty for a long time. Unfortunately since `alacritty_terminal` imports in `alacritty` are supposed to be separate blocks, the `group_imports` option cannot be used.
2021-05-22Improve rendering performanceChristian Duerr
This PR combines a couple of optimizations to drastically reduce the time it takes to gather everything necessary for rendering Alacritty's terminal grid. To help with the iteration over the grid, the `DisplayIter` which made heavy use of dynamic dispatch has been replaced with a simple addition to the `GridIterator` which also had the benefit of making the code a little easier to understand. The hints/search check for each cell was always performing an array lookup before figuring out that the cell is not part of a hint or search. Since the general case is that the cell is neither part of hints or search, they've been wrapped in an `Option` to make verifying their activity a simple `is_some()` check. For some reason the compiler was also struggling with the `cursor` method of the `RenderableContent`. Since the iterator is explicitly drained, the performance took a hit of multiple milliseconds for a single branch. Our implementation does never reach the case where draining the iterator would be necessary, so this sanity check has just been replaced with a `debug_assert`. Overall this has managed to reduce the time it takes to collect all renderable content from ~7-8ms in my large grid test to just ~3-4ms.
2021-05-01Fix release mode testsChristian Duerr
Fixes #5041.
2021-04-08Fix automatic scrolling on resizeRichard Steinmetz
2021-03-31Keep viewport in place during resizeRichard Steinmetz
Fixes #4879. Co-authored-by: Christian Duerr <contact@christianduerr.com>
2021-03-30Unify the grid line indexing typesChristian Duerr
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-01-24Move renderable cell transformation to alacrittyChristian Duerr
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-11Fix assertion crash on 32-bit systemsr-c-f
Fixes #4687.
2021-01-01Remove Windows WinPTY backendChristian Duerr
2020-12-31Use ConfigDeserialize for all config enumsChristian Duerr
This fixes up all of the remaining enums which are used in the configuration file to make sure they all support fully case insensitive deserialization. Fixes #4611.
2020-12-10Fix scrolling region performance with fixed linesChristian Duerr
This resolves an issue with Alacritty's scrolling region performance when there's a number of fixed lines at the top of the screen. This affects commonly used applications like tmux or vim. Instead of using separate logic for when the scrolling region starts at the top of the screen without any fixed lines, the code should now try to figure out the target position of these fixed lines ahead of time, swap them into place and still perform the optimized implementation to move the grid. This comes with the small trade-off that since lines are swapped before rotating the screen without clearing or removing any lines during the rotation process, that the places the fixed lines have been swapped with will appear out of order when using scrolling regions in the primary screen buffer. Since the use of scrolling regions primarily affects the alternate screen and most terminals don't keep any history at all, this should however not cause any problems.
2020-11-13Add ability to select text during searchChristian Duerr
This removes the restriction of not being able to select text while the search is active, making it a bit less jarring of a UX when the user tries to interact with the terminal during search. Since the selection was used during vi-less search to highlight the focused match, there is now an option for a focused match color, which uses the inverted normal match color by default. This focused match is used for both search modes. Other mouse interactions are now also possible during search, like opening URLs or clicking inside of mouse mode applications.
2020-11-05Use dynamic storage for zerowidth charactersChristian Duerr
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-07-15Add support for searching without vi modeChristian Duerr
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-15Fix cursor reflowChristian Duerr
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-14Fix crash on cursor resizeChristian Duerr
Fixes #3960.
2020-07-09Add regex scrollback buffer searchChristian Duerr
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-09Fix cursor reflowChristian Duerr
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-06Preserve linewrap flag across alt screen switchesChristian Duerr
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-01Fix reflow of empty wrapped cursor lineChristian Duerr
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-06-26Clear selection on clear line/screen escapesKirill Chibisov
Selection is now cleared if clear line or clear screen escape sequences are clearing content behind it.
2020-06-25Fix scroll down escape pulling lines from historyChristian Duerr
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-18Add automatic scrolling during selectionChristian Duerr
This adds a new `Scheduler` which allows for staging events to be processed at a later time. If there is a selection active and the mouse is above or below the window, the viewport will now scroll torwards the direction of the mouse. The amount of lines scrolled depends on the distance of the mouse to the boundaries used for selection scrolling. To make it possible to scroll while in fullscreen, the selection scrolling area includes the padding of the window and is at least 5 pixels high in case there is not enough padding present.
2020-06-06Remove copyright notice from filesChristian Duerr
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-05-30Refactor Term/Grid separationChristian Duerr
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-05Extend style guideline documentationChristian Duerr
2020-03-24Fix cursor position after alt screen resizeChristian Duerr
This fixes a regression introduced in 4cc6421, which ignored the main grid's cursor when increasing the number of lines available, causing incorrect cursor position after restoring to the primary screen. Additionally another similar bug has been fixed where the grid was not scrolled correctly when shrinking while in the alternate screen. When the grid is resized multiple lines at once, there was also an issue with Alacritty either pulling all lines from history or none at all, instead of mixing both approaches and pulling just what is required. This lead to incorrect cursor positions when the resize could partially make use of history. Fixes #3499.
2020-03-21Fix invisible selectionChristian Duerr
This resolves a bug where the very first/last cell would still be selected when both the start and the end were below/above the viewport.
2020-03-18Add modal keyboard motion modeChristian Duerr
This implements a basic mode for navigating inside of Alacritty's history with keyboard bindings. They're bound by default to vi's motion shortcuts but are fully customizable. Since this relies on key bindings only single key bindings are currently supported (so no `ge`, or repetition). Other than navigating the history and moving the viewport, this mode should enable making use of all available selection modes to copy content to the clipboard and launch URLs below the cursor. This also changes the rendering of the block cursor at the side of selections, since previously it could be inverted to be completely invisible. Since that would have caused some troubles with this keyboard selection mode, the block cursor now is no longer inverted when it is at the edges of a selection. Fixes #262.
2020-03-07Fix selection with invisible start and endChristian Duerr
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-02-12Fix incorrect display offset after rotationKirill Chibisov
Regression was introduced in 4cc6421daa4ff5976ab43c67110a7a80a36541e5, however it was working before only due to grid.len() bug.
2020-01-28Fix inconsistent test module namingChristian Duerr
2020-01-26Fix incorrect grid.len() and grid.history_size()Kirill Chibisov
2020-01-24Fix selection rotating outside of scrolling regionChristian Duerr
Fixes #2983.
2020-01-21Fix first cell when selection is off screenChristian Duerr
Since the expansion of the selection was done after clamping it to the grid, the selection would incorrectly move the clamped start over by one cell when the start was to the right of the original column. By resetting the side of the start point to `Left` before expanding, this can be circumvented. This also resolves a regression which broke backwards bracket selection. Fixes #3223.
2020-01-09Fix cut off full width glyphs in last columnChristian Duerr
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-04Update outdated reftestsKirill Chibisov