aboutsummaryrefslogtreecommitdiff
path: root/src/event_loop.rs
Commit message (Collapse)AuthorAge
* Split alacritty into a separate cratesTheodore Dubois2019-04-28
| | | | | The crate containing the entry point is called alacritty, and the crate containing everything else is called alacritty_terminal.
* Add rustfmt style guideChristian Duerr2019-03-30
|
* Fix signal handling on Unix systemsRachel K2019-03-12
| | | | | | | | | | | | | | | | | | | | This removes the the signal handling machinery in tty::unix, and replaces it with functionality from signal-hook, which should be more robust. Signals caught by signal-hook wake up the existing I/O event loop, which then delegates back to the PTY to handle them. In particular, this allows `SIGCHLD` (i.e. child process exits) to shut down the terminal promptly, instead of sometimes leaving the window lingering. Fixes #915. Fixes #1276. Fixes #1313. As a side effect, this fixes a very rare bug on Linux, where a `read` from the PTY on the master side would sometimes "fail" with `EIO` if the child closed the client side at a particular moment. This was subject to a race condition, and was very difficult to trigger in practice.
* Normalize Log Message StringsNathan Lilienthal2019-01-07
| | | | | | The general style for errors, warnings and info messages is to start with a capitalized letter and end without a period. The main exception is when dealing with nouns that are clearer with special case handling, e.g. "macOS failed to work" or "ioctl is borked".
* Use mio-extras instead of mio-moreBastien Orivel2018-12-27
| | | | The latter isn't maintained anymore and this removes a bunch of outdated dependencies.
* Ignore result on deregistering ptydm1try2018-12-14
| | | | Fixes #1897.
* Upgrade to Rust 2018Joe Wilm2018-12-10
| | | | | This resolves a lot of NLL issues, however full NLL will be necessary to handle a couple of remaining issues.
* Add support for Windows (#1374)Zac Pullar-Strecker2018-10-16
| | | | | | | | | | | | | | | Initial support for Windows is implemented using the winpty translation layer. Clipboard support for Windows is provided through the `clipboard` crate, and font rasterization is provided by RustType. The tty.rs file has been split into OS-specific files to separate standard pty handling from the winpty implementation. Several binary components are fetched via build script on windows including libclang and winpty. These could be integrated more directly in the future either by building those dependencies as part of the Alacritty build process or by leveraging git lfs to store the artifacts. Fixes #28.
* Rework auto-scrolling optionsChristian Duerr2018-06-02
| | | | | | | | | | | | | | | This changes two things, the first thing it does is that now whenever a keybinding sends an escape sequence, the viewport is automatically scrolled to the bottom. This is enabled by default and fixes #1187. The second thing is automatic scrolling when a command writes to the terminal. So when running a command like `sleep 3; ls -lah`, alacritty will scroll to the bottom once the output is sent, even if the viewport is currently not at the bottom of the scrollback. Because this can have an impact on performance, and is not enabled by default in terminals like iTerm or Termite (VTE), it is an opt-in setting in the config.
* Fix typo in error messageRandy Ramos2018-05-25
|
* Remove all instances of unwrap() from configChristian Duerr2018-03-04
| | | | | | | | | | | | | | | | | | Unwrapping inside the config file parsing can lead to some issues that prevent us from falling back to a default configuration file. One instance of that issue was mentioned in #1135. Now all instances of `unwrap()` have been removed and replaced with proper error handling. This will make the config more robust and prevents live reload from silently breaking while alacritty is running. This also fixes a few currently existing clippy issues. Clippy added an additonal lint which complains about `MyStruct { field: field }`. These issues have been fixed, except for some false-positives and issues in external macros which will probably be fixed with future updates (rust-lang-nursery/bitflags#149)
* Update dependenciesgolem1312018-01-26
| | | | | | Updated the version of some dependencies. This also changes to a new clippy version so clippy can work with the latest nightly compiler again. Some issues created by new lints have been fixed.
* Add clippy check to travisChristian Duerr2018-01-06
| | | | This commit adds clippy as a required step of the build process. To make this possible, all existing clippy issues have been resolved.
* fix some typos in commentsMartin Lindhe2017-10-30
|
* Update most remaining depsJonathan Schleußer2017-09-05
|
* Read more from ptyJoe Wilm2017-07-31
| | | | | | | | | | Resolves an issue with partial draws where programs like vim would send data, but only part of it would be drawn. The logic for escaping when a write is pending has been removed in favor of limiting bytes processed during a pty_read call. The value of MAX_READ may not be ideal.
* Minor cleanup, style fix, dead code removalJoe Wilm2017-05-24
|
* Add DrainResult enumAaron Hill2017-05-24
|
* Fix typoAaron Hill2017-05-24
|
* Ensure that the event loop thread cleanly exits on shutdownAaron Hill2017-05-24
| | | | | | | | | | | | | | | | | | | | | | | | | | Background: If a shell process exits with children still alive (typically due to the `disown` shell builtin), POLLHUP will not be sent to the master PTY file descriptor. This is due to the fact that the disowned process still has the slave PTY open as its STDIN, STDOUT, and STDERR. If a disowned process never reads or writes from its file descriptors (which is often the case for graphical applications), the event loop will end up blocking on poll()/select() when not handling user input received over the mio channel. When Alacritty shuts down and joins on the event loop thread, there can never be any more input on the mio channel - the main thread is no longer handling user keystrokes from the window. Unless a disowned process happens to access its slave PTY file descriptors, the event loop will never get the chance to deetect that it should exit. This commit extends the `Msg` enum to include an explicit `Shutdown` message, which ensures a clean shutdown (e.g. closing the 'recording' file). This allows the select()/poll() call to remain blocking, instead of needing to periodically check the shutdown state in between timed-out calls. Fixes #339
* Fix #573. Ensure we don't write 0 bytes to ptyMartin Algesten2017-05-24
| | | | | | | Any action that results in 0 bytes, such as pasting 0 bytes from the clipboard hangs the terminal (`pbcopy </dev/null` followed by ctrl-v), hangs the terminal on both macOS and Linux. This ensures we never send 0 bytes.
* Better error handling in event loopJoe Wilm2017-04-03
| | | | | | | Also checks hup first since if the terminal is either not readable or writable there's nothing for Alacritty to do. Closes #480.
* Fix bug where event loop could get stuck readingJoe Wilm2017-01-11
| | | | | | | One symptom of this bug was being unable to send C-c during `cat /dev/urandom`. cc #271
* Handle EINTR in I/O loopJoe Wilm2017-01-06
| | | | | | | This fixes an issue where encountering some signals panicked the event loop thread. Resolves #76
* Fix pty read sometimes not triggering drawJoe Wilm2016-12-29
| | | | | | | | | | | 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.
* Major cleanup for event handlingJoe Wilm2016-12-26
| | | | | | | | | | | | | | | | | | | | | | 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.
* Misc formatting fixesJoe Wilm2016-12-16
|
* Rustup and clippyJoe Wilm2016-12-16
| | | | All of the changes in this commit are due to clippy lints.
* Display manages window, renderer, rasterizerJoe Wilm2016-12-11
| | | | | | | | | | 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.
* Cleaning up main; Added window moduleJoe Wilm2016-12-11
| | | | | | | | 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().
* Implement Handler::identify_terminal for TermJoe Wilm2016-12-11
| | | | | The identify_terminal function signature had to change to support writing to the terminal before processing additional input.
* Add support for recording/running ref testsJoe Wilm2016-11-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* Fix alacritty shutdown when shell exits on macOSJoe Wilm2016-11-11
| | | | | | | 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.
* Clean up event_loop moduleJoe Wilm2016-09-26
| | | | | | | | | | | 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.
* Refactor EventLoop into event_loop moduleJoe Wilm2016-09-25
This type and its implementations were seriously cluttering main.rs.