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

23 commits

Author SHA1 Message Date
Joe Wilm
7dd176fea8 Make use of unlikely intrinsic
There's some bounds checks we do that panic if the condition is ever
true.
2016-09-18 18:17:33 -07:00
Joe Wilm
b6f7b39c0d Minor fixes
Remove random println and add a missing #[inline]
2016-09-18 18:16:58 -07:00
Joe Wilm
7da9de34d8 Fix crash
There might be a better way to track cursor state such that these checks
aren't necessary.
2016-09-16 17:12:53 -07:00
Joe Wilm
3c5d46c851 Scrolling v2
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-08-22 08:37:50 -07:00
Joe Wilm
f6cd24eccc Remove unnecessary calls in grid 2016-07-29 18:04:26 -07:00
Joe Wilm
6639e6f24f Move ::grid::index to ::index
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-03 21:07:58 -07:00
Joe Wilm
7f1c1efe47 Grid API is now generic and strongly typed
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-03 17:00:00 -07:00
Joe Wilm
f2e6d66a5e Improve ergonomics of iterating on grid::Row
Iterating on grid::Row types no longer requires calls to iter() or
iter_mut().
2016-07-02 08:25:21 -07:00
Joe Wilm
a2ca10643f Implement Term::erase_chars
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-07-01 21:13:09 -07:00
Joe Wilm
c8fd2c090c Add license headers to source files 2016-06-29 20:59:14 -07:00
Joe Wilm
22789f35c7 Implement terminal resizing
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-29 10:21:02 -07:00
Joe Wilm
69ed81d249 Refactor Tty and Grid creation into Term::new
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-28 09:18:54 -07:00
Joe Wilm
bd8bd26c8b
Add support for macOS
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-14 07:39:06 -07:00
Joe Wilm
8126841ed3
Add support for scrolling regions
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-08 10:39:49 -07:00
Joe Wilm
581eb6b69f
Tweak some Grid methods
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-06 17:45:09 -07:00
Joe Wilm
7834bd177f
Fix bug where there were extra grid rows
Apparently VecDeque::with_capacity is more of a suggestion.
2016-06-06 17:44:06 -07:00
Joe Wilm
1a7eda7b05
Terminal sets more attributes on grid Cells 2016-06-06 17:43:14 -07:00
Joe Wilm
cdea958e71
Add support for drawing background colors 2016-06-06 16:54:15 -07:00
Joe Wilm
4fdd5280f1
Add iterator methods to Grid and Row types
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-04 19:40:30 -07:00
Joe Wilm
30ec145109
Initial support for Terminal Emulation (woo!)
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-06-02 19:42:28 -07:00
Joe Wilm
855ae75697
Add render time meter
Optimization is impossible without measurement!
2016-05-21 11:08:50 -07:00
Joe Wilm
e794bc11b9
Use subpixel font rendering
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-11 08:05:19 -07:00
Joe Wilm
b84eb9e921
Add a Grid
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.
2016-04-10 16:25:05 -07:00