aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-07-06Disable scroll buffer for "alt" Gridscroll/fix-alt-grid-sizeJoe Wilm
The scroll history size for the alternative grid (used by fullscreen apps such as vim and tmux) is now forced to zero. There are two motivations for this change: 1. According to the literature, the alt screen should not have scroll history. 2. Reduce memory consumption by only allocating the single scroll history. In the future, it may be desirable to support a configuration option to enable a scroll buffer for the alt screen. By launching without this feature, we can delay a decision about whether to officially support this or not.
2018-07-06Fix incorrect cell side in selectionChristian Duerr
Previously the cell side of a selection with the mouse outside of the grid has been calculated by setting the `Side` to `Right` whenever the `X` of the mouse is bigger or equal to `window_width - padding_x`. However since the grid doesn't perfectly fit the window in most cases, there was an additional few pixels where the `Side` would be `Left`, resulting in the selection jumping around. To fix this the additional padding due to not perfectly fitting window size has been included in the calculation. The `X` position is now checked to be bigger or equal to `width - padding_x - extra_padding_x`. An important note is that this will need changing when the grid is centered inside the window, so extra padding is split up evenly. Once that change is merged the calculation required will be `width - padding_x - extra_padding_x / 2.`. This fixes #1412.
2018-07-02Fix scrollback accessing indices out of boundsChristian Duerr
There have been two instances of the scrollback trying to access indices which were moved out of bounds due to new lines (`yes` command). These have both been fixed. The first instance was during semantic selection, since the logic of limiting the selection start point was moved outside of `compute_index`, it was necessary to add this to semantic selection too. Now semantic selection, line selection and normal selection should all work without crashing when new lines are shoving the selection out of bounds. The other error was with the viewport being outside of the scrollback history. Since the default is to keep the scrollback buffer at its current position when new lines are added, it is possible that the position the scrollback buffer is at is suddenly shoved out of the visible area. To fix this the `display_offset` is now limited to always be an allowed value. If a single line of the viewport is moved out of the history now, the viewport should move down a single line now, so only valid content is displayed, with multiple lines this process is repeated. This fixes #1400. There was another error where the iterator would attempt to iterate before the first line in the history buffer, this was because the bounds of the `prev` iterator weren't setup correctly. The iterator should now properly iterate from the first cell in the terminal until the last one. This also fixes #1406, since these semantic selection errors were partiall related to indexing.
2018-06-16Optimize indexing of the grid's raw bufferChristian Duerr
The `compute_index` method in the `Storage` struct used to normalize indices was responsible for a significant amount of the CPU time spent while running the `alt-screen-random-write` benchmark (~50%). The issue with this relatively simple method was that due to how often the method is executed, the modulo operation was too expensive. Instead of the modulo, a more conservative branch has been put in place which has a very efficient best-case (which is hit most of the time). Until now the methods for growing/shrinking the storage buffer and compute_index have been written with the assumption that `self.zero` might be bigger than `self.inner.len()`. However there is no reason why `self.zero` wouldn't be constrained to always be within the size of the raw buffer, so this has been changed to make things a little simpler and more explicit. Instead of clamping the selection to be within the buffer inside the storage, this is now checked in the selection logic to remove all selection-specific logic from `storage.rs`.
2018-06-02Allow changing scrollback history size at runtimeChristian Duerr
Making use of the changes that have been introduced in #1234 and #1284, this allows changing the size of the scrollback buffer at runtime. This simply changes the size of the raw inner buffer making use of the optimized mutation algorithms introduced in #1284. As a result, shrinking the scrollback history size at runtime should be basically free and growing will only introduce a performance cost when there are no more buffered lines. However, as a result there will not be any memory freed when shrinking the scrollback history size at runtime. As discussed in #1234 a potential solution for this could be to truncate the raw buffer whenever more than X lines are deleted, however this issue should not be very significant PR and if a solution is desired a separate issue/PR should be opened. This fixes #1235.
2018-06-02Remove dead codeJoe Wilm
2018-06-02Optimize Storage::swapJoe Wilm
Removes 4 movaps instructions from generated assembly.
2018-06-02Refactor Storage<T> to be a Vec<Row<T>> internallyJoe Wilm
This will allow certain optimizations around swap which are currently only possible in a generalized way with specialization.
2018-06-02Fix issue with endless allocation loopJoe Wilm
Shrinking columns wasn't updating hidden rows in the storage buffer on resizing. When growing the columns again, this resulted in an endless allocation loop. Only one real change was made here, and that was `raw.iter_mut()` to `raw.iter_mut_raw()`. The method `shrink_cols` was relocated to be adjacent to `grow_cols` in the code.
2018-06-02Shave a few cycles off Grid::scroll_upJoe Wilm
This implementation avoids a few extra transformations by operating in buffer-space. However, there is still a transformation from the logical buffer-space to the underlying vector.
2018-06-02Fix OOB index in grid::DisplayIterJoe Wilm
When resizing prior to this patch, hidden rows in Storage were not having columns added along with everything else. This feels like a bit of tech debt, but the patch is simple enough that it won't be much extra to back out later when the underlying cause is addressed (see comments in code).
2018-06-02Optimize Row::resetJoe Wilm
Now, only cells that have been used are cleared. This is achieved by using a "occupied" memo on the Row itself. The value, `occ`, is updated wherever the Row is accessed mutably, and it's cleared to zero in Row::reset. The tests for grid scroll_up and scroll_down were updated to include a test on the value `occ` and slightly refactored, but are otherwise equivalent to the previous implementation of those tests. Because of the change to the `Row` struct, the ref tests were updated so Deserialization keeps working as expected.
2018-06-02Optimize Storage::swap_linesJoe Wilm
Saves a few cycles in a *very* hot function.
2018-06-02Truncate invisible lines before storing ref-testsChristian Duerr
Because there is no good way to store invisible lines in a backwards- and forwards-compatible way, they buffer now gets truncated before dumping the state of a grid when creating a ref-test. This involved a few workaround of which a few required adding additional methods which are only used in ref-tests, these should be minimal though. Since this required the creation of a truncation method anyways, some logic has been added which automatically truncates the invisible buffer when there are more than X (set to 100) invisible lines. This should not impact performance because it rarely occurs, but it could save a bit of memory when the history size is shrunk during runtime (see #1293). This also adds an optional `config.json` file to the ref-test output where it is possible to manually specify variables which should override config defaults, this has been used only for history_size so far. Creating a new ref-test does also still work, so there was no regression here, if history size is altered, the config.json just has to be created manually with the content `{"history_size":HIST_SIZE}`, where `HIST_SIZE` is the desired history size.
2018-06-02Add documentation for `len` field on `Storage`Christian Duerr
Because the purpose of the `len` field wasn't obvious and collided with other uses (like Vec::len()), some additional documentation has added to make things a little easier to understand.
2018-06-02Remove `push` from `Storage`Christian Duerr
Since every line is allocated at startup anyways, the `push` method on `Storage` has been removed and instead of pushing to the vector the initialization has been moved to the `with_capacity` method. This has the advantage that we don't need to keep track of the `len` in push (like adding one), but we just need to worry about growing/shrinking the visible area.
2018-06-02Improve the resizing implementationChristian Duerr
Until now the resizing implementation with scrollback has been really inefficient because it made use of APIs like `Vec::insert`. This has been rewored with this commit. A `len` property has been added to the `Storage` struct which keeps track of the actual length of the raw buffer. This has changed both shrinking and growing implementations. With shrinking, no more lines are removed, only the `len` property is updated to set all lines shrunk to an "invisible" state which cannot be accessed from the outside, this effectively changes it to a O(1) operation. The only issue with this would be memory consumption, but since the maximum shrinkage is the number of lines on one screen, it should be a rather small impacte (probabl <100 lines usually). If desired it would be possible to change this to shrink the raw inner buffer whenever there are more than X lines hidden. Growing now works in a similar way to shrinking, if the "invisible" lines are enough, no new lines are inserted but rather the invisible buffer is made visible again. Otherwise the amount of lines that still needs to be inserted is added to the raw buffer, but instead of the inefficient `Vec::insert`, the `Vec::push` API is used now. This fixes #1271.
2018-06-02fixup! Add assert to Row::growJoe Wilm
Resolves #1337
2018-06-02Add assert to Row::growJoe Wilm
This enforces the invariant that Row::Grow is only called when the row actually needs to be grown.
2018-06-02Re-record grid_reset testChristian Duerr
The old grid_reset test expected the complete grid to be reset, but instead of resetting the whole grid the `grid.scroll_limit` is just set to `0` now. This leads to the rest of the grid still containing the old information. To fix this test it has simply be re-recorded. The new tests now still contains the complete history but it is checked that the `scroll_limit` is correctly reset.
2018-06-02Improve storage comparison algorithmChristian Duerr
Instead of iterating over the raw storage vector because the offsets don't allow direct comparison, the comparison is now done in chunks. Based on benchmarking this is a lot more efficient than using split_off + append or iterating over the elements of the buffer. The `history_size` field has also been removed from the storage structure because it can be easily calculated by substracting the number of visible lines from the length of the raw storage vector.
2018-06-02Reduce size of ref testsChristian Duerr
2018-06-02Reset grid content when running `reset`Christian Duerr
In the current scrollback PR the `reset` command does not affect the scrollback history. To make sure the terminal is properly reset, it should clear the scrollback history. This commit fixes this by creating a new and empty grid whenever `reset` is executed. It takes the current dimensions and history size from the old grid. Right now there's an empty ref-test called `grid_reset` without any content, this should be implemented once #1244 is resolved. This fixes #1242.
2018-06-02Enable history comparison in ref-testsChristian Duerr
Previously ref-tests just ignored the scrollback history to keep the old tests working, this would lead to new tests which rely on scrollback history to succeeed even though they should not. This has been fixed and it is now possible to create ref-tests with and without scrollback history. When available the scrollback history is compared, but the old tests still work without having to adjust them. This fixes #1244.
2018-06-02Reset grid when running `reset`Christian Duerr
In the current scrollback PR the `reset` command does not affect the scrollback history. To make sure the terminal is properly reset, it should clear the scrollback history. To make resetting efficient, instead of resetting the history, the scrollback history is hidden by setting `grid.scroll_limit` to `0`. This will not clear the history but instead just make it inaccessible, which should have the same effect. The visible area is reset by the shell itself, so in combination this clears the complete terminal grid from a user perspective. This fixes #1242.
2018-06-02Fix bright characters in first columnChristian Duerr
This bug was introduced by the commit which fixed the invisible cursor in the first column (54b21b66ecc6f8f149d1425567e0e3d766a3ac54). To resolve this the alternative implementation by @jwilm has been applied which seems to work out. This fixes #1259.
2018-06-02Revert "Fix cursor not showing in first column"Christian Duerr
This reverts commit 54b21b66ecc6f8f149d1425567e0e3d766a3ac54.
2018-06-02Compile on stableJoe Wilm
2018-06-02Fix order of lines after resizeChristian Duerr
There was an issue where the lines would be messed up when the terminal was resized, this was because lines were just added/removed at the end of the buffer instead of the actual end of the terminal (since the end of the terminal might be in the middle of the buffer). This has been fixed by relying on `self.zero` to determine the position of the start of the terminal and then calculating where lines have to be inserted/removed. Some tests have also been added with documentation that should make it a little easier to understand how the process works and how the raw buffer is layed out. This should all work no matter how big the scrollback history and even when the currenty viewport is not at the bottom of the terminal output.
2018-06-02Fix scrollback history size 0 bugChristian Duerr
There was an issue where alacritty would panic whenever the scrollback history size is set to 0, this fixes that issue. The panic was caused by a substraction with unsigned integers which was underflowing, this has been fixed to use `saturating_sub`. After that was fixed there was still a bug where scrollback would not behave correctly because the number of lines in the grid was decided at startup. This has been adapted so whenever the size of the terminal changes, the scrollback history and grid adapts to make sure the number of lines in the terminal is always the number of visible lines plus the amount of scrollback lines configured in the config file. This fixes #1150.
2018-06-02Add documentation to explain the processChristian Duerr
2018-06-02Fix cursor not showing in first columnChristian Duerr
There was a bug in the display iterator where the first column was never reached after the top line because it was instantly incremented to 1 after it was reset when iterator column reached the end of the terminal width. This has been fixed by making sure that the column is never incremented when the column is reset due to a change in terminal line. This fixes #1198.
2018-06-02Fix BCE ref testsJoe Wilm
BCE was broken in attempt to optimize row clearing. The fix is to revert to passing in the current cursor state when clearing.
2018-06-02Fix selection testsChristian Duerr
The latest selection changes broke a few tests, these have been corrected. Two of these tests were broken because they assumed different span types, the test have been changed here because the result was correct. One test did actually catch a bug where selection of two cells from right to left would incorrectly mark the cells as selected even though they should not have been, this has been fixed in the `simple_span` method.
2018-06-02Fix grid scroll testsJoe Wilm
2018-06-02Make tests compile againJoe Wilm
Some tests are still not passing, though. A migration script was added to migrate serialized grids from pre-scrollback to the current format. The script is included with this commit for completeness, posterity, and as an example to be used in the future. A few tests in grid/tests.rs were removed due to becoming irrelevant.
2018-06-02Rework auto-scrolling optionsChristian Duerr
This changes two things, the first thing it does is that now whenever a keybinding sends an escape sequence, the viewport is automatically scrolled to the bottom. This is enabled by default and fixes #1187. The second thing is automatic scrolling when a command writes to the terminal. So when running a command like `sleep 3; ls -lah`, alacritty will scroll to the bottom once the output is sent, even if the viewport is currently not at the bottom of the scrollback. Because this can have an impact on performance, and is not enabled by default in terminals like iTerm or Termite (VTE), it is an opt-in setting in the config.
2018-06-02Fix regression with scrolling regionsJoe Wilm
Resolves #1154
2018-06-02Refactor `span_simple` selectionChristian Duerr
The current `span_simple` selection is everything but simple. This version should have the same functionality as the current `span_simple` with the difference that a lot of complexity has been removed. Not only is this code shorter, it should also be significantly easier to understand with no "magic" to it. This will hopefully prevent us from having an unmaintainable blob of off-by-one guessing in the repo. Also removed the `out` file which I used in the original PR because scrollback is not implemented yet. :)
2018-06-02Replace scrolling methods with enumChristian Duerr
The different scrolling methods added a bunch of boilerplate where the call was just forwarded to the next struct, this has been removed by making the scroll amount into a struct. Now everything is called through one method and the parameter decides how far the viewport should be scrolled.
2018-06-02Add scrollback hotkeysChristian Duerr
This offers a few additional hotkeys that can be used in combination with scrollback. None of these are used by default yet. This implements the following bindings: - ScrollPageUp: Scroll exactly one screen height up - ScrollPageDown: Scroll exactly one screen height down - ScrollToTop: Scroll as far up as possible - ScrollToBottom: Scroll as far down as possible This fixes #1151.
2018-06-02Fix selection starting in first cellChristian Duerr
When selecting to the top and starting in the first cell, alacritty would crash. These cases have been fixed and now selection should be completely working.
2018-06-02Fix buggy selection when scrolling downChristian Duerr
When scrolling down with a selection on screen the first line was not properly selected. This has been fixed by making sure the selection always starts in the first cell when it is only partially visible.
2018-06-02Fix multi-line selection with single cell endChristian Duerr
When the user selected multiple lines, dragging the selection downwards, and then leaves the cursor to the left side of the first cell, the first cell was still incorrectly selected. This has been fixed. The selection also did not update if the mouse was outside of the window, now all movement events are accpeted even when the mouse is outside of the window. This allows updating the selection when the user is dragging the cursor too far. Mouse movement and click events outside of the window are not propagated, these are only used for updating the selection.
2018-06-02Fix selection in scrollbackChristian Duerr
There were a few issues with selection in scrollback that were mainly off-by-one errors. This aims at fixing these issues. This also fixes a bug that currently exists in master where the last cell is not selected when the mouse leaves the window to the right.
2018-06-02Fix linux config default valueChristian Duerr
2018-06-02Merge branch #1095Christian Duerr
Because there was some overlap with branch #1095, these two PRs have been added together and the config has been restructured to make use of a `scrolling` section. The default faux scrolling amount has also been changed to `3` because this simplifies the code and falls in line with what most other terminal emulators do. There should be no additional test failures due to this.
2018-06-02Change config file to display the correct defaultChristian Duerr
2018-06-02Make normal scrolling line amount configurableChristian Duerr
It is now possible to configure the amount of lines the viewport should scroll when using the normal scrolling mode. This fixes #1160.
2018-06-02Fix crash when selection leaves viewportChristian Duerr
There was an issue where alacritty tries to convert the lines in a selection to the on-screen lines even when the selection is not on the screen. This results in a crash. To prevent this from happening the selection now is not shown if it is off the screen. There currently still is a bug that when the selection is at the top of the screen but still half visible, it will not show the top line as selected but start in the second line. This bug should be resolved with https://github.com/jwilm/alacritty/pull/1171. This fixes #1148.