Commit Graph

33 Commits

Author SHA1 Message Date
Michael Brumlow b99fda5214 Fixing panic on cat /dev/urandom
- Checks to make sure lines count coming from the pty are within a proper
range before doing scrolling.

- Sanitizes scroll region when being set.

- Changes panic for unimplemented screen clear to a print statement.

The first two changes ensure scrolling won't crash us. By sanitizing the
region on set we don't have to complicate the scroll code with limits,
mins, or maxes to ensure the scroll operation is within the range.
Checking if the lines is greater than the total region allows us to
simply clear the region and avoid subtracting large numbers from small
ones.
2017-01-10 00:57:49 -06:00
Joe Wilm 9e713189cc Merge pull request #216 from mbrumlow/better_bounds_checking
Better bounds checking.
2017-01-07 21:24:55 -08:00
Michael Brumlow 5642624f40 Changes requested.
- Rename wrap to input_needs_wrap and providing documentation.
- Standardize on min.
- Optimization on subtracting col.
2017-01-07 21:46:02 -06:00
Michael Brumlow fb56dcbad9 Fixing resize crashes.
Most of the crashes on resize were due to columns and lines being set to
zero. This causes all sorts of other checks within the code to ensure
these values are greater than zero before running calculations. To avoid
this we just need to ensure that lines and columns are some non zero
value. This is seems to be what gnome terminal does. I have selected
2 lines and two columns for min terminal size for now.
2017-01-07 18:07:03 -06:00
Michael Brumlow c106ee6601 Removing stale comment. 2017-01-07 17:17:46 -06:00
Michael Brumlow 24453fa698 Implementing line wrapping.
This implementation of line wrapping ensures self.cursor.col is never out
of bounds, thus not requiring checking.
2017-01-07 17:13:42 -06:00
Michael Brumlow b88fd8a23e Better bounds checking.
- Remove the use of limit.
- Reduce the number of comparisons.

When using numbers provided by the PTY for subtractions there is a extra
step of ensuring that we won't trigger failure on testing when trying to
subtract form zero.

** NOTE **

This commit fails fails the tmux_git_log test. I am submitting a PR to
talk about the test. I think the test was generated before a few things
were fixed the final test gird still has cells that should have been
scrolled off the screen. Also, comparing output from gnome-terminal
there is no difference. So this PR is here to discuss and gather
information on balding test and discussing the possibility that this test
may be flawed.

** NOTE **
2017-01-07 15:47:05 -06:00
Michael Brumlow 180150bbc1 Fixes a slew of bounds issues. 2017-01-07 02:06:30 -06:00
Manish Goregaokar 4e1f4c8cd7 Clippy fixes! 2017-01-06 20:44:51 -08:00
Manish Goregaokar 49187d53f2 Add `nightly` feature, use for `unlikely` intrinsic 2017-01-06 20:28:17 -08:00
Manish Goregaokar fbeded8ac5 Remove need for inclusive ranges 2017-01-06 20:28:17 -08:00
Manish Goregaokar c579d07993 Remove need for range_contains feature 2017-01-06 20:17:10 -08:00
Manish Goregaokar 800b65622c Remove need for step_by feature 2017-01-06 20:17:10 -08:00
Josh Leverette 2dd5f0f45d Handle invalid gotos more gracefully. 2017-01-06 15:00:15 -05:00
Joe Wilm 82bfc41af7 Add support for SGR mouse reporting
According to:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
2017-01-01 18:28:49 -08:00
Joe Wilm 72ff775b23 Improve RenderableCellsIter performance
Also adds a benchmark for cell.reset().
2016-12-29 21:56:49 -05:00
Joe Wilm 26ac1df0b1 Add Default impl for Cell
Just a bit of cleanup.
2016-12-29 21:43:55 -05:00
Joe Wilm a91a3f2dce Fix pty read sometimes not triggering draw
There was a lot of complexity around the threadsafe `Flag` type and
waking up the event loop. The idea was to prevent unnecessary calls to
the glutin window's wakeup_event_loop() method which can be expensive.
This complexity made it difficult to get synchronization between the pty
reader and the render thread correct. Now, the `dirty` flag on the
terminal is also used to prevent spurious wakeups. It is only changed
when the mutex is held, so race conditions associated with that flag
shouldn't happen.
2016-12-29 21:38:22 -05: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 115a4085b4 Fix selection copy for long lines
Long lines were previously broken at the terminal width. Now, a wrapping
marker is kept on the final cell so that extra newlines are not
inserted.
2016-12-29 10:43:58 -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
Joe Wilm bde4dacc79 Misc formatting fixes 2016-12-16 22:48:04 -08:00
Joe Wilm dc918ae71a Rustup and clippy
All of the changes in this commit are due to clippy lints.
2016-12-16 22:13:51 -08:00
Joe Wilm 0b3d2dac44 Handle overflow in Term::move_backward
Resolves #25
2016-12-15 09:13:34 -08:00
Joe Wilm 1a1b740c38 Remove need for Rc<RefCell<_>> usage
This adds a trait OnResize and a separate method handle_resize to the
display. Instead of having a callback to receive resize events, a list
of &mut OnResize are passed to this new method. Doing this allowed the
only RefCell usage in the codebase to be removed :).
2016-12-12 09:31:48 -08:00
Joe Wilm 4b63bddd55 Track terminal cells on mouse movement
The cell under the cursor is now tracked in the input processor at
`self.mouse.line` and `self.mouse.column`. This could probably be
optimized to only compute the cell when in certain states, but the
calculation is cheap.
2016-12-11 22:02:03 -08:00
Joe Wilm ed0b1cfff0 Display manages window, renderer, rasterizer
This is part of an ongoing decoupling effort across the codebase and
tidying effort in main.rs. Everything to do with showing the window with
a grid of characters is now managed by the `Display` type. It owns the
window, the font rasterizer, and the renderer. The only info needed from
it are dimensions of characters and the window itself for sizing the
terminal properly. Additionally, the I/O loop has access to wake it up
when new data arrives.
2016-12-11 20:23:41 -08:00
Joe Wilm ed48d08c03 Implement Handler::identify_terminal for Term
The identify_terminal function signature had to change to support
writing to the terminal before processing additional input.
2016-12-11 20:23:41 -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 ff5081d5e5 Add support for bracketed paste
Binding/Action execute now has access to TermMode to support bracketed
paste mode.
2016-12-11 20:23:41 -08:00
Joe Wilm 7bf3d059c3 Move term::cell module to its own file
The cell module was previously implemented within term.rs. Now each
module has its own file.
2016-12-11 20:23:41 -08:00