Commit Graph

33 Commits

Author SHA1 Message Date
Steve Blundy 0c3e28617a Fixing tabs in copy-paste
This resolves issues with copy-pasting tabs by including them in the
pasted string.

Selection of tabs is still inconsistent with what might be expected
based on other terminal emulators, however the behavior hasn't
regressed.

This fixes https://github.com/jwilm/alacritty/issues/219.
2018-12-15 21:33:33 +00:00
Christian Duerr 1cebcd660b
Fix rendering of zero-width characters
Instead of rendering zero-width characters as full characters, they are
now properly rendered without advancing the cursor.

Because of performance limitations, this implementation only supports up
to 5 zero-width characters per cell. However, as a result of this
limitation there should not be any performance impact.

This fixes #1317, fixes #696 and closes #1318.
2018-12-09 15:28:22 +00:00
Christian Duerr e01317d885
Fix failing test with `bench` feature
Using the `bench` feature, `cargo test` was failing since one of the
benchmarks was running into a debug assertion for attempting to access a
line with an index beyond the grid length.

Since this issue was caused by the `len` property not being serialized
and deserialized, the `#[serde(skip)]` attribute has been changed to
`#[serde(default)]`. The ref-test has been edited to include the correct
grid length for proper deserialization.

This fixes #1604.
2018-09-29 20:48:24 +00:00
Christian Duerr 3d7e88e8a9
Dynamically initialize grid storage
Previously Alacritty has initialized all lines in the buffer as soon as
it is started. This had the effect that terminals which aren't making
use of the scrollback buffer yet, would still consume large amounts of
memory, potentially even freezing the system at startup.

To resolve this problem, the grid is now dynamically resized in chunks
of `1000` rows. The initial size is just the visible area itself, then
every time lines are written to the terminal emulator, the grid storage
is grown when required.

With the worst-case scenario of having 100_000 lines scrollback
configured, this change improves startup performance at the cost of
scrolling performance.

On my machine the startup changes from ~0.3 to ~0.2 seconds.

The scrolling performance with large throughput is not affected, however
it is slowed down when the number of lines scrolled are close to the
100_000 configured as scrollback. The most taxing benchmark I've found
for this was running `yes | dd count=500 > 500.txt` (note the relatively
small file size). This will cause a slowdown on the first run from 0.05s
to 0.15s. While this is significant, it lines up with the time saved at
startup.

This fixes #1236.
2018-09-24 18:40:09 +00:00
Joe Wilm c61a912f62 Optimize Row::reset
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-02 09:56:50 -07:00
Christian Duerr ac93f6d031 Truncate invisible lines before storing ref-tests
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-02 09:56:50 -07:00
Christian Duerr dec3ee20e9 Re-record grid_reset test
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-02 09:56:50 -07:00
Christian Duerr 31c0f291e0 Reduce size of ref tests 2018-06-02 09:56:50 -07:00
Christian Duerr d39370514a Reset grid content when running `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.
2018-06-02 09:56:50 -07:00
Christian Duerr 2234234ca9 Enable history comparison in ref-tests
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-02 09:56:50 -07:00
Joe Wilm b0f655ac85 Make tests compile again
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-02 09:56:50 -07:00
Joe Wilm 2bda79d94c Add ref test for 855 2017-11-11 09:23:43 -08:00
Joe Wilm c8dcbd3308 Add ref test for CSI REP 2017-09-30 16:30:04 -07:00
Joe Wilm 87468b5c00 Fix newline + scroll region bug (#747)
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.
2017-08-22 11:24:33 -07:00
Joe Wilm 2e98bd9578 Add ref test for 24-bit vim BCE 2017-08-11 08:29:56 -07:00
Joe Wilm f041ce0f59 Fix BCE issues affecting vim
Now pass more vttests as well.

Resolves #123
cc #660 - screenshot there exhibited the problem, but issue is not
entirely about the background problem.
2017-08-11 08:29:56 -07:00
Tuomas Siipola 9316771f64 Add window padding option
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.
2017-05-06 12:53:54 -07:00
Joe Wilm f298e0455a Fix bug with tab rendering
Closes #494.
Resolves #529.
Resolves #512.
Resolves #493.
2017-05-01 09:56:42 -07:00
Joe Wilm 09031decc0 Support insert mode 2017-05-01 08:21:42 -07:00
Joe Wilm 7d20d29f37 Implement tab stop manipulation
Adds implementations for TBC (tabulation clear) and HTS (set horizontal
tabstop).
2017-05-01 08:21:42 -07:00
Joe Wilm 8963e97a5a Add more vttest ref tests 2017-04-19 20:24:02 -07:00
Joe Wilm 811cb266d2 Add reftest for vttest 2 scroll 2017-04-19 20:19:04 -07:00
Joe Wilm 7bc1691b0f Add ref test for tab rendering 2017-04-04 09:03:33 -07:00
Joe Wilm 2d1af06c2d Update ref tests
Implementing BCE caused a few ref tests to fail erroneously.
2017-04-03 20:44:23 -07:00
Joe Wilm 53507ce7d0 Add ref test for tab background highlighting
Generated with

    echo -e "\x1b[48;5;31m1\t2\n\n3\x1b[0;m"
2017-02-27 08:05:11 -08:00
Joe Wilm 59295e4431 Add zsh tab completion ref test 2017-02-07 08:08:08 -08:00
Steven Fackler 2ffdc8d9ca Remove line_wrap test
This doesn't pass, and was mistakenly never actually enabled in the old
ref.rs macro.
2017-01-23 08:59:54 -08:00
Michael Brumlow e8b8bda9f9 Adding test for line wrap.
This test ensures we can enable and disable line wrap.
2017-01-12 00:29:10 -06:00
quininer kel 0a53d3cb86 add fish_cc ref
and update Cargo.lock
2016-12-16 18:39:51 +08:00
Joe Wilm 23e36f1925 Add support for indexed colors
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.
2016-12-11 20:23:41 -08:00
Joe Wilm 30bee80a69 Refactor cell selection out of renderer
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.
2016-12-11 20:23:41 -08:00
Joe Wilm 0dfba30181 Add a number of simple ref-tests
Also adds a feature `err-println` for enabling `err_println!` printing.
2016-11-19 21:34:22 -08:00
Joe Wilm 66dbd29cd1 Add support for recording/running ref tests
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`.
2016-11-19 21:34:11 -08:00