1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00
Commit graph

26 commits

Author SHA1 Message Date
Christian Duerr
4380d0864b
Fix rotation of selection below 0
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.
2018-10-20 22:30:59 +00:00
Christian Duerr
f50ca1a54c
Scrollback cleanup
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.
2018-07-21 17:17:41 +00:00
Joe Wilm
24c50fa0a7 Remove dead code 2018-06-02 09:56:50 -07:00
Christian Duerr
8168d85a21 Improve storage comparison algorithm
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-02 09:56:50 -07:00
Joe Wilm
b19045da66 Fix BCE ref tests
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-02 09:56:50 -07:00
Christian Duerr
f66e3e457b Fix selection tests
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-02 09:56:50 -07:00
Christian Duerr
f463816162 Refactor span_simple selection
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-02 09:56:50 -07:00
Christian Duerr
e20aa550cb Fix selection starting in first cell
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-02 09:56:50 -07:00
Christian Duerr
58c69cafad Fix multi-line selection with single cell end
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-02 09:56:50 -07:00
Christian Duerr
d9bd21d33f Fix selection in scrollback
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-02 09:46:20 -07:00
Joe Wilm
8018dee181 Support selections with scrolling buffer
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
2018-06-02 09:34:28 -07:00
Joe Wilm
8ef062efd9 Move selection into Grid
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.
2018-06-02 09:34:28 -07:00
Joe Wilm
a88961bbf0 Remove redundant selection::Region type
The type selection::Region was defined identially to std::ops::Range.
Using something other than range just served to confuse.
2018-06-02 09:24:38 -07:00
Christian Duerr
7f2b398ad2
Remove all instances of unwrap() from config
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)
2018-03-04 22:40:15 +00:00
Christian Duerr
2920cbe710
Add clippy check to travis
This commit adds clippy as a required step of the build process. To make
this possible, all existing clippy issues have been resolved.
2018-01-06 01:42:55 +00:00
Matthias Krüger
d552d28418 clippy: do and don't pass some things by reference as suggested (needless_pass_by_value, needless_borrow). 2017-12-03 12:50:40 -08:00
Martin Lindhe
5b444375f2 fix some typos in comments 2017-10-30 09:25:13 -07:00
Joe Wilm
f12fd880fe Update tests for new Selection API 2017-06-19 21:31:50 -07:00
Joe Wilm
6b081dcc95 Fix unnecessary redraws with active selection
Could be cleaned up a bit if there was a wrapper for Option<Selection>
that contained this flag.

Also fixes a few compiler warnings.
2017-06-19 21:31:50 -07:00
Joe Wilm
63bcb46011 Implement semantic and line selection dragging
Unlike the regular selection that is by cell, these selection modes
highlight either semantic groupings or entire lines while the mouse is
dragged.
2017-06-19 21:31:50 -07:00
Manish Goregaokar
4e1f4c8cd7 Clippy fixes! 2017-01-06 20:44:51 -08:00
Manish Goregaokar
fbeded8ac5 Remove need for inclusive ranges 2017-01-06 20:28:17 -08:00
Joe Wilm
b704dafb24 Fix some bugs with selections
Moving the window on macOS would cause a panic in certain circumstances.
2016-12-29 20:53:41 -05:00
Joe Wilm
689e0f4ad7 Unify Cursor, Location and name it Point 2016-12-29 11:09:29 -05:00
Joe Wilm
ae470bf68b Implement copying selection for macOS
Still need automatic loading into selection copy buffer for linux.
2016-12-26 22:56:19 -05:00
Joe Wilm
6e708d2119 Implement visual component of mouse selections
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.
2016-12-22 13:44:13 -05:00