aboutsummaryrefslogtreecommitdiff
path: root/src/grid.rs
AgeCommit message (Collapse)Author
2018-01-06Add clippy check to travisChristian Duerr
This commit adds clippy as a required step of the build process. To make this possible, all existing clippy issues have been resolved.
2017-09-27Use clippy = "*", update, and fix some warnings (#796)Aaron Hill
Because there are so many clippy warnings in the current codebase, this commit removes '#![cfg_attr(feature = "clippy", deny(clippy))]', to make it easier to fix warnings incrementally.
2017-06-19Implement semantic and line selection draggingJoe Wilm
Unlike the regular selection that is by cell, these selection modes highlight either semantic groupings or entire lines while the mouse is dragged.
2017-04-20Fix some bugs with resizeJoe Wilm
2017-04-19Pass scrolling region tests in vttest 2Joe Wilm
2017-04-03Add better printing for ref test failureJoe Wilm
The previous format was extremely difficult for a human to parse.
2017-02-11Move color list to Term structJoe Wilm
The color list needs to be updated by the parser, and this isn't possible if it's on the config. This change makes sense semantically as well since it's really part of the terminal state. This is in preparation for OSC color parsing.
2017-02-07Semantic SelectionXiaoyu Yin
Fix tests and add line select Refactor BidirectionalIter to remove if blocks Allow for cells tagged with WRAPLINE to continue expanding the selection Reorganize config into structs Add test coverage that callbacks are called Cleanup mouse config - Uses Duration type for ClickHandler::threshold - Removes `action` property from ClickHandler--this can be added in a backwards compatible way later on - Renames ClickState::DblClick to DoubleClick fixup! Cleanup mouse config
2017-01-23Use the log-crate instead of printing to stdoutLukas Lueg
2017-01-06Add `nightly` feature, use for `unlikely` intrinsicManish Goregaokar
2017-01-06Remove need for inclusive rangesManish Goregaokar
2017-01-06Remove need for step_by featureManish Goregaokar
2016-12-29Unify Cursor, Location and name it PointJoe Wilm
2016-12-22Implement visual component of mouse selectionsJoe Wilm
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-16Misc formatting fixesJoe Wilm
2016-12-16Rustup and clippyJoe Wilm
All of the changes in this commit are due to clippy lints.
2016-11-19Add support for recording/running ref testsJoe Wilm
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-09-18Make use of `unlikely` intrinsicJoe Wilm
There's some bounds checks we do that panic if the condition is ever true.
2016-09-18Minor fixesJoe Wilm
Remove random println and add a missing #[inline]
2016-09-16Fix crashJoe Wilm
There might be a better way to track cursor state such that these checks aren't necessary.
2016-08-22Scrolling v2Joe Wilm
The previous scrolling + scroll region implementation exhibited display corruption bugs in several applications including tmux, irssi, htop, and vim. The new implementation doesn't seem to suffer from any of those issues. This implementation is able to `find /usr` on my machine (nearly 600k lines) in ~2.0 seconds while st is able to do the same in ~2.2 seconds. Alacritty is officially faster!
2016-07-29Remove unnecessary calls in gridJoe Wilm
2016-07-03Move ::grid::index to ::indexJoe Wilm
The grid and term modules already rely on the index types, and ansi is about to be updated with strongly typed APIs. Since Cursor, Line, and Column are fundamental to the code in several modules, namespacing them under one of them seems less correct than a module that stands by itself.
2016-07-03Grid API is now generic and strongly typedJoe Wilm
The Grid no longer knows about a `Cell` and is instead generic. The `Cell` type is coupled to the `term` module already, and it's been moved there to reflect the strong relationship. Grid APIs previously accepted `usize` for many arguments. If the caller intended rows to be columns, but the function accepted them in reverse, there would be no compiler error. Now there is, and this should prevent such bugs from entering the code. The Grid internals grew significantly to accomodate the strongly typed APIs. There is now a `grid::index` module which defines Cursor, Line, and Column. The Grid APIs are all based on these types now. Indexing for Ranges proved to be somewhat awkward. A new range had to be constructed in the implementation. If the optimizer can't figure out what's going on in that case, the ranges may not be a zero-cost abstraction.
2016-07-02Improve ergonomics of iterating on grid::RowJoe Wilm
Iterating on grid::Row types no longer requires calls to iter() or iter_mut().
2016-07-01Implement Term::erase_charsJoe Wilm
Fixes last known issue with htop. I think this implementation might not be correct, but I don't yet understand the difference between erasing and deleting (I imagine it's the difference between graphics state vs grid state). Will probably need to circle back here. Adds all range indexing operations to rows. Some were needed for the erase_chars impl, and the rest are there for fully generality.
2016-06-29Add license headers to source filesJoe Wilm
2016-06-29Implement terminal resizingJoe Wilm
The resize event is received from glutin on the update thread, but the renderer needs to be informed as well for updating the viewport and projection matrix. This is achieved with an mpsc::channel. To support resizing, the grid now offers methods for growing and shrinking, and there are several implementations available for clear_region based on different Range* types. Core resize logic is all in Term::resize. It attempts to keep as much context as possible when shinking the window. When growing, it's basically just adding rows.
2016-06-28Refactor Tty and Grid creation into Term::newJoe Wilm
This moves more logic out of main() and prepares the Term type to handle resizing. By providing all size data to Term, it is now possible to implement a resize function there which handles all resizing logic save for the rendering subsystem.
2016-06-14Add support for macOSJoe Wilm
Alacritty now runs on macOS using CoreText for font rendering. The font rendering subsystems were moved into a separate crate called `font`. The font crate provides a unified (albeit limited) API which wraps CoreText on macOS and FreeType/FontConfig on other platforms. The unified API differed slightly from what the original Rasterizer for freetype implemented, and it was updated accordingly. The cell separation properties (sep_x and sep_y) are now premultiplied into the cell width and height. They were previously passed through as uniforms to the shaders; removing them prevents a lot of redundant work. `libc` has some differences between Linux and macOS. `__errno_location` is not available on macOS, and the `errno` crate was brought in to provide a cross-platform API for dealing with errno. Differences in `openpty` were handled by implementing a macOS specific version. It would be worth investigating a way to unify the implementations at some point. A type mismatch with TIOCSCTTY was resolved with a cast. Differences in libc::passwd struct fields were resolved by using std::mem::uninitialized instead of zeroing the struct ourselves. This has the benefit of being much cleaner. The thread setup had to be changed to support both macOS and Linux. macOS requires that events from the window be handled on the main thread. Failure to do so will prevent the glutin window from even showing up! For this reason, the renderer and parser were moved to their own thread, and the input is received on the main thread. This is essentially reverse the setup prior to this commit. Renderer initialization (and thus font cache initialization) had to be moved to the rendering thread as well since there's no way to make_context(null) with glx on Linux. Trying to just call make_context a second time on the rendering thread had resulted in a panic!.
2016-06-08Add support for scrolling regionsJoe Wilm
It's now possible to move around within Vim without the screen becoming corrupt! The ANSI parser now calls a (new) `set_scrolling_region` on the handler when the DECSTBM CSI is received. In order to provide a sensible default in case that the sequence doesn't include arguments, a TermInfo trait was added which currently has methods for inspecting number of rows and columns. This was added as an additional trait instead of being included on Handler since they have semantically different purposes. The tests had to be updated to account for the additional trait bounds. The utilities module now has a `Rotate` trait which is implemented for the built-in slice type. This means that slices and anything derefing to a slice can be rotated. Since VecDeque doesn't support slicing (it's a circular buffer), the grid rows are now held in a Vec to support rotation. For ergomomic access to the grid for scrolling and clearing regions, additional Index/IndexMut implementations were added to the grid::Row type. Finally, a `reset` method was added to `Cell` which properly resets the state to default (instead of just clearing the char). This supports region clearing and also fixed a bug where cell backgrounds would remain after being cleared.
2016-06-06Tweak some Grid methodsJoe Wilm
Adds some #[inline] tags, and delegates to internals for num_rows and num_cols. In case these become different than the expected values, this should help to fail sooner.
2016-06-06Fix bug where there were extra grid rowsJoe Wilm
Apparently VecDeque::with_capacity is more of a suggestion.
2016-06-06Terminal sets more attributes on grid CellsJoe Wilm
2016-06-06Add support for drawing background colorsJoe Wilm
2016-06-04Add iterator methods to Grid and Row typesJoe Wilm
The iterator methods simplify logic in the main grid render function. To disambiguate iterator methods from those returning counts (and to free up names), the `rows()` and `cols()` methods on `Grid` have been renamed to `num_rows()` and `num_cols()`, respectively.
2016-06-02Initial support for Terminal Emulation (woo!)Joe Wilm
This patch introduces basic support for terminal emulation. Basic means commands that don't use paging and are not full screen applications like vim or tmux. Some paging applications are working properly, such as as `git log`. Other pagers work reasonably well as long as the help menu is not accessed. There is now a central Rgb color type which is shared by the renderer, terminal emulation, and the pty parser. The parser no longer owns a Handler. Instead, a mutable reference to a Handler is provided whenever advancing the parser. This resolved some potential ownership issues (eg parser owning the `Term` type would've been unworkable).
2016-05-21Add render time meterJoe Wilm
Optimization is impossible without measurement!
2016-04-11Use subpixel font renderingJoe Wilm
OpenGL only supports shared alpha blending. Subpixel font rendering requires using the font RGB values as alpha masks for the corresponding RGB channels. To support this, blending is implemented in the fragment shader.
2016-04-10Add a GridJoe Wilm
The grid holds the state of the terminal with row-major ordering. Eventually, the grid::Cell type will hold other attributes such as color, background color, decorations, and weight. An initialization list is added for common ASCII symbols.