1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00
Commit graph

23 commits

Author SHA1 Message Date
Christian Duerr
2920cbe710
Add clippy check to travis
This commit adds clippy as a required step of the build process. To make
this possible, all existing clippy issues have been resolved.
2018-01-06 01:42:55 +00:00
Martin Lindhe
5b444375f2 fix some typos in comments 2017-10-30 09:25:13 -07:00
Jonathan Schleußer
a3d35ec185 Update most remaining deps 2017-09-05 09:07:00 -07:00
Joe Wilm
702df40da4 Read more from pty
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.
2017-07-31 12:57:17 -07:00
Joe Wilm
112abf385f Minor cleanup, style fix, dead code removal 2017-05-24 10:56:50 -07:00
Aaron Hill
7eff38d7b7 Add DrainResult enum 2017-05-24 10:56:50 -07:00
Aaron Hill
bc8d86f970 Fix typo 2017-05-24 10:56:50 -07:00
Aaron Hill
876dc15152 Ensure that the event loop thread cleanly exits on shutdown
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
2017-05-24 10:56:50 -07:00
Martin Algesten
262c70be57 Fix #573. Ensure we don't write 0 bytes to pty
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.
2017-05-24 09:10:11 -07:00
Joe Wilm
9acd612b23 Better error handling in event loop
Also checks hup first since if the terminal is either not readable or
writable there's nothing for Alacritty to do.

Closes #480.
2017-04-03 21:34:21 -07:00
Joe Wilm
a7fc46afce Fix bug where event loop could get stuck reading
One symptom of this bug was being unable to send C-c during `cat
/dev/urandom`.

cc #271
2017-01-11 10:33:56 -08:00
Joe Wilm
5f6dedd7d3 Handle EINTR in I/O loop
This fixes an issue where encountering some signals panicked the event
loop thread.

Resolves #76
2017-01-06 08:25:40 -08:00
Joe Wilm
a91a3f2dce Fix pty read sometimes not triggering draw
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-29 21:38:22 -05:00
Joe Wilm
358c9fa17d Major cleanup for event handling
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-26 18:39:30 -05:00
Joe Wilm
bde4dacc79 Misc formatting fixes 2016-12-16 22:48:04 -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
Joe Wilm
ed0b1cfff0 Display manages window, renderer, rasterizer
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-11 20:23:41 -08:00
Joe Wilm
4ba2931437 Cleaning up main; Added window module
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-11 20:23:41 -08:00
Joe Wilm
ed48d08c03 Implement Handler::identify_terminal for Term
The identify_terminal function signature had to change to support
writing to the terminal before processing additional input.
2016-12-11 20:23:41 -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
e4260134aa Fix alacritty shutdown when shell exits on macOS
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-11-11 18:02:38 -08:00
Joe Wilm
89937e7bc5 Clean up event_loop module
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-26 08:28:38 -07:00
Joe Wilm
3f6deb8e2f Refactor EventLoop into event_loop module
This type and its implementations were seriously cluttering main.rs.
2016-09-25 19:49:44 -07:00