Whenever the viewport is scrolled, the selection is rotated to make sure
that it moves with the viewport. However this did not correctly handle
the underflow that happens when the selection goes below 0.
This resolves that problem for the selection by moving the internal line
representation to an isize, thus correctly keeping track of the
selection start/end points even when they have a negative index. Once
the selection is converted to a span, the lines are clamped to the
visible region.
This fixes#1640 and fixes#1643.
There were some unneeded codeblocks and TODO/XXX comments in the code
that have been removed. All issues marked with TODO/XXX have either been
already resolved or tracking issues exist.
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.
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.
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. :)
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.
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.
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.
Selections now *mostly* work. They move as the buffer scrolls, copying
works as it should, and it looks like the different selection modes
behave properly as well.
The new Selection implementation uses buffer coordinates instead of
screen coordinates. This leads to doing a transform from mouse input to
update the selection, and back to screen coordinates when displaying the
selection. Scrolling the selection is fast because the grid is already
operating in buffer coordinates.
There are several bugs to address:
* A _partially_ visible selection will lead to a crash since the drawing
routine converts selection coordinates to screen coordinates. The
solution will be to clip the coordinates at draw time.
* A selection scrolling off the buffer in either direction leads to
indexing out-of-bounds. The solution again is to clip, but this needs
to be done within Selection::rotate by passing a max limit. It may
also need a return type to indicate that the selection is no longer
visible and should be discarded.
* A selection scrolling out of a logical scrolling region is not
clipped. A temporary and robust workaround is to simply discard the
selection in the case of scrolling in a region.
wip selections
fix issue with line selection
selection mostly working
need to support selection not being on the screen at draw time
Fix selection_to_string
Uncomment tests
Supporting selections with scrollback has two major components:
1. Grid needs access to Selection so that it may update the scroll
position as the terminal text changes.
2. Selection needs to be implemented in terms of buffer offsets -- NOT
lines -- and be updated when Storage is rotated.
This commit implements the first part.
Unwrapping inside the config file parsing can lead to some issues that
prevent us from falling back to a default configuration file.
One instance of that issue was mentioned in #1135.
Now all instances of `unwrap()` have been removed and replaced with
proper error handling. This will make the config more robust and
prevents live reload from silently breaking while alacritty is running.
This also fixes a few currently existing clippy issues.
Clippy added an additonal lint which complains about `MyStruct { field:
field }`.
These issues have been fixed, except for some false-positives and issues
in external macros which will probably be fixed with future updates (rust-lang-nursery/bitflags#149)
This adds the ability to click and drag with the mouse and have the
effect of visually selecting text. The ability to copy the selection
into a clipboard buffer is not yet implemented.