aboutsummaryrefslogtreecommitdiff
path: root/src/event_loop.rs
AgeCommit message (Collapse)Author
2017-01-11Fix bug where event loop could get stuck readingJoe Wilm
One symptom of this bug was being unable to send C-c during `cat /dev/urandom`. cc #271
2017-01-06Handle EINTR in I/O loopJoe Wilm
This fixes an issue where encountering some signals panicked the event loop thread. Resolves #76
2016-12-29Fix pty read sometimes not triggering drawJoe Wilm
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-26Major cleanup for event handlingJoe Wilm
The event handling code grew organically over time, and with that came a number of warts. The primary issue was with passing some random selection of arguments to the input::Processor based on what the input was. There was the issue that if multiple events were drained from a single PollEventsIterator, the terminal mutex was potentially locked and unlocked many times. Finally, and perhaps most importantly, there was no good way to pass necessary state to the Action executor without going through several API layers. To fix all that, the input::ActionContext and input::Processor are now generated once per call to the event::Processor. The input::Processor holds onto the ActionContext so that it doesn't need to be passed through layers of function calls. When a binding is activated, the ActionContext is simply passed to the handler. This did have the effect of breaking the input::Processor tests (specifically, those relating to bindings). The issue was not addressed in this commit since a larger refactor of the bindings is planned which should also improve testability.
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-12-11Display manages window, renderer, rasterizerJoe Wilm
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-11Cleaning up main; Added window moduleJoe Wilm
Adds a wrapper for the glutin::Window which provides strongly typed APIs and more convenient interfaces. Moves some gl calls into the opengl-based renderer. The point of most of the changes here is to clean up main().
2016-12-11Implement Handler::identify_terminal for TermJoe Wilm
The identify_terminal function signature had to change to support writing to the terminal before processing additional input.
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-11-11Fix alacritty shutdown when shell exits on macOSJoe Wilm
Readiness for the pty file descriptor will never be HUP or ERROR; the out-of-band flag raised by sigchld is used instead. Resolves #14.
2016-09-26Clean up event_loop moduleJoe Wilm
The main loop body was originally all written inline. There's now separate functions for each of the actions the loop handles including channel events, pty reading, and pty writing. There's also helper functions on State for managing the write list. The `EventLoop` and its `State` are returned when joining with the thread it spawns. This will potentially be helpful once config reloading is introduced.
2016-09-25Refactor EventLoop into event_loop moduleJoe Wilm
This type and its implementations were seriously cluttering main.rs.