1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00
Commit graph

31 commits

Author SHA1 Message Date
Tom Crayford
d7a5981048 print glutin events if --print-events is passed
When debugging many issues, it's often very helpful to have the raw
glutin events printed out to stderr as they come in. This does that.

Note that since `glutin::Event` doesn't implement `Display`, we just use
rust's debugging output for now via `{:?}`.
2017-01-08 21:09:02 +00:00
Manish Goregaokar
4e1f4c8cd7 Clippy fixes! 2017-01-06 20:44:51 -08:00
Joe Wilm
8d3f5f4e17 Fix panic when closing window
Resolves #81.
2017-01-06 11:22:47 -08:00
Joe Wilm
693aefcbd7 Draw the screen when Refresh event arrives
cc #53
2017-01-04 19:54:29 -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
b704dafb24 Fix some bugs with selections
Moving the window on macOS would cause a panic in certain circumstances.
2016-12-29 20:53:41 -05:00
Joe Wilm
d06360216d Hopefully fix read not triggering draw
The terminal mutex is no longer released between event processing and
doing a draw. This may fix the race condition with data arriving but not
being displayed until a subsequent event.

cc #29
2016-12-29 15:34:33 -05:00
Joe Wilm
ae470bf68b Implement copying selection for macOS
Still need automatic loading into selection copy buffer for linux.
2016-12-26 22:56:19 -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
3b7c7377c9 Refactor input processing to take action context
Various functions take some permutation of the current selection, the
terminal, and a notifier. Instead of having to juggle some number of
arguments everywhere, the `ActionContext` is constructed and then passed
around.
2016-12-25 18:54:01 -05:00
Joe Wilm
6e708d2119 Implement visual component of mouse selections
This adds the ability to click and drag with the mouse and have the
effect of visually selecting text. The ability to copy the selection
into a clipboard buffer is not yet implemented.
2016-12-22 13:44:13 -05:00
Joe Wilm
1a1b740c38 Remove need for Rc<RefCell<_>> usage
This adds a trait OnResize and a separate method handle_resize to the
display. Instead of having a callback to receive resize events, a list
of &mut OnResize are passed to this new method. Doing this allowed the
only RefCell usage in the codebase to be removed :).
2016-12-12 09:31:48 -08:00
Joe Wilm
4b63bddd55 Track terminal cells on mouse movement
The cell under the cursor is now tracked in the input processor at
`self.mouse.line` and `self.mouse.column`. This could probably be
optimized to only compute the cell when in certain states, but the
calculation is cheap.
2016-12-11 22:02:03 -08:00
Joe Wilm
4df29bb377 Finish main.rs cleanup
* config::Monitor is more ergonomic and self-contained
* Fixed an issue with macOS resize. Previously, the terminal was marked
  as dirty in the window resize handler, but the display can't do that.
  Instead, the event processor returns a flag whether it was requested
  to wakeup.
2016-12-11 20:23:41 -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
adf02b5049 Support trackpad scrolling
Linebased scrolling is still unsupported (need a mouse to test with).
2016-12-11 20:23:41 -08:00
Joe Wilm
90e0a759e8 Support normal mouse tracking mode
This allows the user for eg clicking columnts in htop to sort.
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
d97996e19d Make bindings configurable from alacritty.yml
Bindings were previously hardcoded within input.rs; adding, removing, or
changing a binding required a recompile! Now, bindings may be declared
in alacritty.yml. Even better, bindings are live-reloaded when
alacritty.yml is changed!

One unexpected benefit of this change was that all of the special casing
in input.rs has disappeared.

Conversely, config.rs has gained complexity for all of the
deserialization logic.

Resolves #3.
2016-11-17 17:17:54 -08:00
Joe Wilm
cbb9167d43 Redraw screen on focus
Fixes an issue where waking from sleep on macOS would continue showing
the lock screen if Alacritty was the active app.
2016-11-17 17:16:01 -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
6925daa823 Fix/add some keybindings
Adds support for pageup, pagedown, home, and end. Fixes delete inserting
spaces.

Resolves #15.
2016-11-11 18:46:42 -08:00
Joe Wilm
71de5501c4 Rustup and update dependencies
Now uses serde_dervive \o/
2016-10-14 16:38:15 -07:00
Joe Wilm
7e69a070aa Don't write v when pasting on macOS
This is a bit of an experiment to see if simply handling 'v' in the
bindings will work or has any bugs not going through ReceivedCharacter.
The change is necessary though to prevent 'v' from being written in
front of every clipboard paste.
2016-09-27 08:27:39 -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
6a5ac20def Resolve compiler warnings 2016-09-25 19:33:51 -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
be09467d48 Fix some compiler warnings
Also enables debug symbols in release profile by default. Until
Alacritty ships, there's going to be lots of perf analysis which needs
debug symbols.

The PriorityMutex low priority method was never used. Now it's just a
fair mutex.
2016-09-23 10:12:11 -07:00
Joe Wilm
6c9989819b Fix resize not redrawing immediately 2016-09-06 07:43:03 -07:00
Joe Wilm
3085b0b137 Move rendering back to main thread
This is only like the third time I've made this change. The issue of
having a blank screen at startup is due to x11 event loop + glX
interactions. Not sure what the problem is specifically, but
glXMakecurrent was blocking until the x11 event loop advanced.

The input and rendering are able to live on the same thread while still
removing unnecessary renders due to the
glutin::WindowProxy::wakeup_event_loop() method. The PtyReader just
kicks the event loop when there's something to do; otherwise, the event
loop just waits for something to happen and _doesn't_ draw in free run
mode.
2016-09-01 10:27:04 -07:00