Commit Graph
54 Commits
Author SHA1 Message Date
Joe Wilm 00d271b7e0 Fix bug parsing OSC strings
OSC strings with UTF-8 previously failed.
2017-03-02 09:19:01 -08:00
Joe Wilm 119c7d2856 Add support for wide characters 2017-03-02 09:19:01 -08:00
Joe Wilm 31ed5160a0 Change cursor colors config to use text and cursor
This changes the cursor color config to use the `text` and `cursor`
properties instead of the current `foreground` and `background`
properties. The latter names stop making sense when dealing with cursors
like a vertical bar or underscore. In the new system, the block,
underscore, or vertical bar would always take the color of `cursor`, and
the text would take the color of `text` when using a block, or keep its
normal color when using the underscore or vertical bar.

A warning is now emitted on startup when the old form of cursor color
config is used. This will be a hard error in the future.
2017-02-25 07:55:35 -08:00
Joe Wilm 418df72a07 Bump glutin
Resolves #422
2017-02-17 23:16:37 -08:00
Michel Boaventura e0980df48e Updates Glutin to proper handle dead keys
Resolves #211.
2017-02-17 15:28:46 -08:00
David Tolnay 2063f54455 Update serde_yaml to 0.6.1
This release reports better errors:

> font.use_thin_strokes: invalid type: string "tru", expected a boolean at line 51 column 21
2017-02-10 18:22:45 -08:00
Joe Wilm f2f750f9f3 Alacritty now compiles on stable Rust 🎉 2017-02-03 08:11:19 -08:00
Joe Wilm 40d7c0c434 Implement save/restore cursor position
This passes the vttest for save and restore cursor position. The
implementation was done according to:

    http://www.vt100.net/docs/vt510-rm/DECSC.html

As of yet, there are a few things not supported by the terminal which
should otherwise be saved/restored.

vte was updated for a fix with CSI param parsing
2017-02-02 09:07:00 -08:00
Joe Wilm 6d744abf7b Update to serde 0.9 and serde-yaml 0.6. 2017-01-29 17:29:56 -08:00
Joe Wilm 08f348ecea Optimize glyph cache access
Loading a glyph from the cache is a very hot operation in the renderer.
The original implementation would first check if a glyph was loaded and
then call `get()` which would have to search a second time. This showed
up as a very slow point in profiles.

This patch addresses glyph cache access in two ways: by using a faster
hasher optimized for small keys (fnv), and by using the entry API for
fetching a cached glyph. The `fnv` hasher is faster than the default and
is very efficient for small keys. Using the entry API on the HashMap
means only 1 lookup instead of two. The entry API has a downside where
the key needs to get cloned on fetches.

Reducing the GlyphKey width to 64-bits helps in both areas. Copying an
8-byte wide type is very cheap and thus limits downside of the entry
API. The small width also helps with the hasher performance.

Over all, this patch reduced typical render times by several hundred
microseconds on a 2013 MacBook Pro with a full screen terminal full of
text.
2017-01-26 08:43:53 -08:00
Kurnevsky Evgeny 1dca5617e2 Use clap as cli parser. 2017-01-24 08:38:38 -08:00
Lukas Lueg 64b42cd2f3 Use the log-crate instead of printing to stdout 2017-01-23 09:14:01 -08:00
Steven Fackler 41f99dc4c0 Dynamically generate test harness
This uses the rustc-test crate, a copy of the standard test crate, to
dynamically create tests for each reference test. No need to remember to
update the macro, just add the directory to ref!
2017-01-23 08:59:54 -08:00
Joe Wilm dfb1b3bb5c Add support for setting title from OSC
Resolves #23
Resolves #144
2017-01-11 09:07:31 -08:00
Manish Goregaokar ee5a9f1338 Replace need for drop_types_in_const with lazy_static 2017-01-06 20:17:10 -08:00
Joe Wilm a105be82cf Real support for placing config in XDG_CONFIG_HOME
Resolves #35.
2017-01-02 20:05:31 -08:00
Joe Wilm a00970c9a8 Add ffi-util crate and use in fontconfig wrapper
This cleans up and fixes the C-type wrapping for fontconfig.
2016-12-30 18:55:10 -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
quininer kel 0a53d3cb86 add fish_cc ref
and update Cargo.lock
2016-12-16 18:39:51 +08:00
Joe Wilm d19e6e38a4 Update to latest Rust 2016-11-23 17:23:14 -08:00
Joe Wilm 3db0bcb2a7 Fix glutin wayland 2016-11-19 21:34:22 -08:00
Joe Wilm 66dbd29cd1 Add support for recording/running ref tests
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-11-19 21:34:11 -08:00
Joe Wilm 8360ab44ec Fallback to received chars when no bindings
Committed this on a plane with no internet; need to get a real glutin
ref pushed somewhere and update this commit before merging into master.
2016-11-17 17:15:56 -08:00
Joe Wilm a652b4a65f Rustup 2016-11-11 16:55:58 -08:00
Joe Wilm 71de5501c4 Rustup and update dependencies
Now uses serde_dervive \o/
2016-10-14 16:38:15 -07:00
Joe Wilm 1d60fdd6e3 Fix X11 WaitEventsIterator Busy Loop
Resolves #10.
2016-10-14 12:19:18 -07:00
Joe Wilm b91c90dc34 Update cargo.lock with osx clipboard 2016-10-08 21:03:47 -07:00
Joe Wilm 9d491f9f67 Start implementing copypasta, a clipboard library
Currently it only supports x11 via the xclip program, and that only
supports reading the clipboard contents.
2016-10-08 18:42:33 -07:00
Joe Wilm 077a058cc4 wip
doesn't work on ubuntu 16.04 for some reason
2016-09-26 22:22:28 -07:00
Joe Wilm f1499d1d45 Use evented I/O for the pty
This was largely an experiment to see whether writing and reading from a
separate thread was causing terminal state corruption as described in
https://github.com/jwilm/alacritty/issues/9. Although this doesn't seem
to fix that particular issue.

Keeping this because it generally seems more correct than
reading/writing from separate locations.
2016-09-24 17:03:07 -07:00
Joe Wilm 969b9005f5 Update VTE for OSC string fix 2016-09-19 08:07:34 -07:00
Joe Wilm c3a383ad5a rustup
Adds a `rustc-version` file which can be used to get the proper
compiler.

    rustup override set $(cat rustc-version)
2016-09-18 18:16:08 -07:00
Joe Wilm 13d2d66b6b Rewrite ansi parser using vte crate
Using the vte crate allows removal of the ansi parser state machine and
enables us to just be concerned with actions described in the protocol.
In addition to making alacritty simpler, this also improves correctness
and performance.
2016-09-18 11:26:00 -07:00
Joe Wilm b9f663f99e Update deps and remove printlns 2016-09-05 14:17:23 -07:00
Joe Wilm 0517f376be Eliminate extra renders
Currently has a bug where screen is blank at startup. That aside,
Alacritty uses basically 0 CPU now. The input thread is still separate
from the render thread, but, given the ability to wake the event loop,
it may be possible to merge them again. I'm not sure if that's actually
desirable.

Performance is seemingly unchanged.
2016-08-31 21:16:17 -07:00
Joe Wilm 0a94ccfcca Update serde, glutin
Glutin includes GlContext::clear_current() for linux
2016-08-30 20:58:23 -07:00
Joe Wilm fd755831f2 Separate input handling from rendering
To minimize rendering, the input must be handled in a separate thread.
To see, why, consider the optimal rendering solution: renders are only
necessary when the pty has data that changes the terminal state, OR
there is a window event which changes the graphics state. When not
drawing, the render thread is to remain parked at a condition variable,
and it's not possible to handle input while parked! Thus, we need a
separate thread.

In addition to adding the separate thread, each subsystem thread is now
spawned in a separate function to (hopefully) improve readability.
2016-08-29 19:23:04 -07:00
Joe Wilm 8b34df7c02 Update Glutin to get Cocoa modifier keys 2016-08-03 08:21:30 -07:00
Joe Wilm 66e7228f41 Input expects modifier keys from Glutin
This is experimental on a separate branch of Glutin. It's intended to
fix the problem of certain key events not being delivered on alt-tab and
breaking the modifier state tracking.
2016-07-30 12:52:53 -07:00
Joe Wilm 80f6f542ab Update to latest nightly
Previous version of serde no longer worked; cargo packages were updated
as a result. `Zero` and `One` traits were deprecated. Use of those was
removed. The `Step` trait gained a lot more methods, and the index::$ty
implementations were updated.
2016-07-15 07:55:44 -07:00
Joe Wilm d304ea9b77 Add config file
Configuration may now be specified in either `$HOME/.alacritty.yml` or
`$HOME/.config/alacritty.yml`. See `alacritty.yml` in the repository
root for an example.

When a configuration file cannot be located, a default configuration is
used.
2016-06-30 09:04:06 -07:00
Joe Wilm 8454bbe183 Enable vsync
The input/pty processing loop previously consumed input on a channel and
hit the rendering when the queue became empty. This had a couple of
problems

1. It was possible to be overwhelmed with input and not give the
   renderer an opportunity to update the screen. This gave the
   appearance of locking up.
2. Multiple frames could be rendered for a single vblank (redundant
   work)
3. Open loop rendering would inevitably have buffer swapping out of sync
   with vblanks and visual tearing would occur.

This commit enables vsync on the glutin window. The rendering was all
moved onto a separate thread from input/pty processing to support vsync.
However, the rendering thread must be 100% synchronized with the updater
thread. There's now a Mutex on the Term, and an atomic bool to ask the
input/pty processing to yield to the renderer.

One aspect of this feature that hasn't been worked out is how to limit
the frame rate. Currently, it just free runs at the screen refresh rate.
The initial attempt here included the input/pty processor holding a lock
while waiting for input. This *almost* worked, but there was a (not
uncommon) edge case where the terminal state was "dirty" but the
renderer was not ready to draw.

Instead of blocking on the refresh issue, it's being punted to after an
MVP is released. The overhead of drawing at 60Hz was profiled to be ~5%
CPU usage, and this is deemed acceptable for an MVP.
2016-06-27 19:46:24 -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 8566e17860 Fix all trivial compiler warnings
Of note are the `ansi` and `grid` modules becoming public. There are
several bits of unused code in each of these. In the case of `grid`, the
unused parts are generally useful, like some indexing implementations.
In ansi, there are pieces that will be used once the parser is more
complete. In any case, these modules are fairly generic and mostly
usable outside of Alacritty.

Unused cargo packages were also removed.
2016-06-09 08:30:55 -07:00
Joe Wilm cdea958e71 Add support for drawing background colors 2016-06-06 16:54:15 -07:00
Joe Wilm 1f3f9add49 Optimize Rendering with batched draw calls
Draw calls are now batched for performance. Render times on git log at
the default size are now ~200usec.
2016-06-04 21:31:41 -07:00
Joe Wilm f944b517fa Add live-reload for shaders
Recompiling the entire program whenever a shader changes is slow, and it
can interrupt flow. Shader reloads are essentially instantaneous now. If
the new shader fails to compile, no state is changed; the previous
program continues to be used.
2016-06-04 10:54:33 -07:00
Joe Wilm a8024f64c7 Update Cargo dependencies
Most importantly, freetype-rs was updated to use freetype-sys 0.4 which
includes the LCD_FILTER apis.
2016-06-02 19:54:16 -07:00
Joe Wilm c70acbac0b Correct sub-pixel font rendering with OpenGL
Uses the GL_ARB_blend_func_extended to get single-pass, per-channel
alpha blending. gl_generator is now used instead of gl to enable the
extension.

The background color is removed since that presumably needs to run in a
separate pass.
2016-05-20 21:36:28 -07:00
Joe Wilm c8b69412b2 Rasterizer uses DPI from Glutin 2016-02-27 20:26:31 -08:00