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.
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.
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.
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.
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.
When a scroll region is active with the cursor below the bottom of the
region, newlines should not cause the region to scroll.
A ref test was added for this situation to prevent regressions.
Thanks @hiciu for reporting and @nicm for the test case.
Resolves#745.
Padding can be configured by using the `padding` field in the config
file, like so:
padding:
x: 2
y: 2
which would result in a 2px padding within each side of the window.
ANSI escape sequences like `\x1b[48;5;10m` were not supported until now.
Specifically, the second attribute, 5, says that the following attribute
is a color index.
The ref tests were updated since `enum Color` variants changed.
The terminal now has a `renderable_cells()` function that returns a
`RenderableCellIter` iterator. This allows reuse of the cell selection
code by multiple renderers, makes it testable, and makes it
independently optimizable.
The render API now takes an `Iterator<Item=IndexedCell>` to support both
the new renderable cells iterator and the `render_string()` method which
generates its own iterator.
The `vim_large_window_scoll` ref test was added here because it provides
a nice large and busy grid to benchmark the cell selection with.
Ref tests use a recording of the terminal protocol and a serialization
of the grid state to check that the parsing and action handling systems
produce the correct result. Ref tests may be recorded by running
alacritty with `--ref-test` and closing the terminal by using the window
"X" button. At that point, the recording is fully written to disk, and a
serialization of important state is recorded. Those files should be
moved to an appropriate folder in the `tests/ref/` tree, and the
`ref_test!` macro invocation should be updated accordingly.
A couple of changes were necessary to make this work:
* Ref tests shouldn't create a pty; the pty was refactored out of the
`Term` type.
* Repeatable lines/cols were needed; on startup, the terminal is resized
* by default to 80x24 though that may be changed by passing
`--dimensions w h`.
* Calculating window size based on desired rows/columns and font metrics
required making load_font callable multiple times.
* Refactor types into library crate so they may be imported in an
integration test.
* A whole bunch of types needed symmetric serialization and
deserialization. Mostly this was just adding derives, but the custom
deserialization of Rgb had to change to a deserialize_with function.
This initially adds one ref test as a sanity check, and more will be
added in subsequent commits. This initial ref tests just starts the
terminal and runs `ll`.