Commit graph

2357 commits

Author SHA1 Message Date
Joe Wilm d4e20a4741 Improve error handling for clipboard actions
Previously, these could have crashed alacritty. Now, they simply print
an error message in Red to stderr. The Red format wrapper was moved to a
central location where both main.rs and the alacritty lib can access it.
2017-01-01 19:09:27 -08:00
Joe Wilm 82bfc41af7 Add support for SGR mouse reporting
According to:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
2017-01-01 18:28:49 -08:00
Joe Wilm a86dfd1a11 Print nice error messages for font loading errors
Resolves #22.
2016-12-31 20:47:29 -08:00
Joe Wilm 2738969f29 Propagate font rasterizer errors
This allows consumers of the font crate to handle errors instead of the
library panicking.
2016-12-31 20:47:02 -08:00
Joe Wilm a00970c9a8 Add ffi-util crate and use in fontconfig wrapper
This cleans up and fixes the C-type wrapping for fontconfig.
2016-12-30 18:55:10 -08:00
Joe Wilm 44c6171bc0 Refactor FontConfig wrappers
There's now a proper wrapper in place for working with the FontConfig
library. This should help significantly with error handling with font
loading; at least, the FontConfig code shouldn't panic. The FreeType
rasterizer still needs to be updated to handle missing fonts, and a more
sensible default font should be specified.
2016-12-30 00:34:57 -05:00
Joe Wilm 72ff775b23 Improve RenderableCellsIter performance
Also adds a benchmark for cell.reset().
2016-12-29 21:56:49 -05:00
Joe Wilm 26ac1df0b1 Add Default impl for Cell
Just a bit of cleanup.
2016-12-29 21:43:55 -05: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 f1336ee1c7 Implement clipboard store for x11 with xclip 2016-12-29 17:57:50 -05:00
Joe Wilm 818a2f6161 Add super hacky underline drawing
Using underscores because it's easy. It's also wrong.

cc #11
2016-12-29 16:05:32 -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 689e0f4ad7 Unify Cursor, Location and name it Point 2016-12-29 11:09:29 -05:00
Joe Wilm 5ee031f55f Add silver searcher ignore file
Searching on the ref tests would find matches in the terminal recording
files and completely screw up the screen state.
2016-12-29 10:49:12 -05:00
Joe Wilm 115a4085b4 Fix selection copy for long lines
Long lines were previously broken at the terminal width. Now, a wrapping
marker is kept on the final cell so that extra newlines are not
inserted.
2016-12-29 10:43:58 -05:00
Joe Wilm 0f1c742857 Minor cleanup in main() 2016-12-27 22:47:25 -05:00
Joe Wilm 8af19c3f0c Fix bug with config reloading
The reloaded config was not used immediately.
2016-12-27 22:46:57 -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 d28a734473 Refactor bindings and fix binding tests
The somewhat redundant KeyBinding and MouseBinding types were removed in
favor of a Binding<T> type. This allows all binding code to be reused
for both scenarios.

The binding tests were fixed by only asserting on `is_triggered_by()`
instead of checking that the action escape sequence was delivered
properly.
2016-12-26 19:00:27 -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 7cdf06e2be Implement copypasta::Store for macOS pasteboard
Only works with strings, currently.
2016-12-24 18:08:46 -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 fd11660c0a Fix config reloading
The main refactor broke config reloading; specifically, colors were not
updating for subsequent draws.
2016-12-16 23:12:44 -08:00
Joe Wilm f32199ae69 Remove dead code 2016-12-16 22:52:38 -08:00
Joe Wilm bde4dacc79 Misc formatting fixes 2016-12-16 22:48:04 -08:00
Joe Wilm 781572096e Remove outdated and no longer correct doc 2016-12-16 22:30:27 -08:00
Joe Wilm 0421012c2d Replace remaining use of try! with ? 2016-12-16 22:29:35 -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 3b995ff87a Merge pull request #27 from quininer/ref_fish_cc
add fish_cc ref
2016-12-16 13:25:01 -08:00
quininer kel 0a53d3cb86 add fish_cc ref
and update Cargo.lock
2016-12-16 18:39:51 +08:00
Joe Wilm 0b3d2dac44 Handle overflow in Term::move_backward
Resolves #25
2016-12-15 09:13:34 -08: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 4e9a307bed Fix a couple of compiler warnings 2016-12-12 09:31:29 -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 79e02b0b2f Update nightly pin on travis 2016-12-11 20:26:33 -08:00
Joe Wilm 3d26d3c68a Implement mouse scrolling with line deltas
This makes scrolling work for mouse wheels (was previously just
trackpads).
2016-12-11 20:23:41 -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 bbd8ddbfc0 Add run() function and document it
The doc comment outlines my plan about cleaning up this function.
2016-12-11 20:23:41 -08:00
Joe Wilm bffe512c33 Add display impl for Points<T> 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 093ac43f80 Move config path into Config type
This cleans up the Config::load API significantly. Several miscellaneous
comments were also added.
2016-12-11 20:23:41 -08:00
Joe Wilm 01bb10885b Cleanup cli option parsing
This introduces the `cli` module and the `cli::Options` type. This type
holds all the options passable on the command line in addition to
providing arg parsing.
2016-12-11 20:23:41 -08:00
Joe Wilm e2e98ed6c2 Force drawing when config reloads 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 61c1e37c46 Add comments in main loop 2016-12-11 20:23:41 -08:00
Joe Wilm 43397cefec Borrow glutin::Window instead of using Arc
glutin::Window is not threadsafe; putting it into an Arc is
misleading (although the glutin::Window type claims to be Send + Sync).
The reference was just needed on the main thread anyway, so it's better
to just pass a ref around directly.
2016-12-11 20:23:41 -08:00
Joe Wilm ce32eee099 Refactor color list management
There's now a ColorList type that provides strongly typed indexing for
not only usize but NamedColor as well. Previously, the `NamedColor` was
casted to a `usize` when indexing the colors. Additionally, only one
copy of the ColorList needs to exist;it's borrowed from the `Config`
when rendering, and the renderer doesn't need a copy.
2016-12-11 20:23:41 -08:00