Commit Graph

35 Commits

Author SHA1 Message Date
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
Joe Wilm 400e4c92a7 build rect describing glyph quad 2016-02-24 19:08:57 -08:00
Joe Wilm 2b7caf95fd Render the letter J
This letter brought to you by OpenGL and freetype.
2016-02-23 20:42:58 -08:00
Joe Wilm 5040c44f67 Implement very basic glyph rasterization
There are several assumptions made at this point and very little (no)
error handling done.
2016-02-21 19:45:35 -08:00
Joe Wilm 2a7dc1deb8 Add function for listing font names on linux
This function isn't exactly useful, but it's working ffi with the
fontconfig library. Woo! Next step will be returning some objects with
more information (like font path so we can start rendering glyphs!).
2016-02-21 15:20:03 -08:00