diff --git a/Cargo.toml b/Cargo.toml index 4a021ccf6..c760b3452 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,5 +55,6 @@ core-text = "~9.2" [features] debug-escape-sequences = ["term/debug-escape-sequences"] +force-glutin = [] [workspace] diff --git a/src/gliumwindows.rs b/src/gliumwindows.rs index 6ea64c7a5..49f7f345f 100644 --- a/src/gliumwindows.rs +++ b/src/gliumwindows.rs @@ -9,7 +9,7 @@ use font::FontConfiguration; use futures; use glium; use glium::glutin::{self, ElementState, MouseCursor}; -use guiloop::GuiEventLoop; +use guiloop::{GuiEventLoop, SessionTerminated}; use opengl::render::Renderer; use opengl::textureatlas::OutOfTextureSpace; use pty::MasterPty; @@ -18,11 +18,11 @@ use std::io::{Read, Write}; use std::os::unix::io::{AsRawFd, RawFd}; use std::process::{Child, Command, ExitStatus}; use std::rc::Rc; -use term::hyperlink::Hyperlink; use term::KeyCode; use term::KeyModifiers; use term::{self, Terminal}; use term::{MouseButton, MouseEventKind}; +use termwiz::hyperlink::Hyperlink; struct Host { display: glium::Display, @@ -41,10 +41,10 @@ impl term::TerminalHost for Host { fn click_link(&mut self, link: &Rc) { // TODO: make this configurable let mut cmd = Command::new("xdg-open"); - cmd.arg(&link.url); + cmd.arg(link.uri()); match cmd.spawn() { Ok(_) => {} - Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.url, err), + Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.uri(), err), } } @@ -533,7 +533,7 @@ impl TerminalWindow { event: WindowEvent::Moved(x, y), .. } => { - self.window_position = Some((x, y)); + self.host.window_position = Some((x, y)); } Event::WindowEvent { event: WindowEvent::ReceivedCharacter(c), diff --git a/src/guiloop/glutinloop.rs b/src/guiloop/glutinloop.rs index e46421e63..bbb984df1 100644 --- a/src/guiloop/glutinloop.rs +++ b/src/guiloop/glutinloop.rs @@ -1,7 +1,7 @@ use failure::Error; use futures::{future, Future}; use glium; -use glium::glutin::{EventsLoopProxy, WindowId}; +use glium::glutin::EventsLoopProxy; use mio; use mio::{PollOpt, Ready, Token}; use std::cell::RefCell; @@ -12,6 +12,9 @@ use std::rc::Rc; use std::sync::mpsc::{self, Receiver, Sender, TryRecvError}; use std::time::Duration; +pub use glium::glutin::WindowId; +pub use gliumwindows::TerminalWindow; + use futurecore; use gliumwindows; use remotemio; @@ -115,7 +118,7 @@ impl GuiEventLoop { let dead = match self.windows.borrow_mut().by_id.get_mut(&window_id) { Some(window) => match window.dispatch_event(event) { Ok(_) => None, - Err(err) => match err.downcast_ref::() { + Err(err) => match err.downcast_ref::() { Some(_) => Some(window_id), _ => return Err(err), }, @@ -187,10 +190,7 @@ impl GuiEventLoop { }; if let Err(err) = result { - if err - .downcast_ref::() - .is_some() - { + if err.downcast_ref::().is_some() { self.schedule_window_close(window_id)?; } else { bail!("{:?}", err); diff --git a/src/guiloop/mod.rs b/src/guiloop/mod.rs index 0c6a9a2af..8b5baddd3 100644 --- a/src/guiloop/mod.rs +++ b/src/guiloop/mod.rs @@ -1,28 +1,22 @@ use failure::Error; use std::process::ExitStatus; -#[cfg(any(windows, target_os = "macos"))] +#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))] mod glutinloop; -#[cfg(any(windows, target_os = "macos"))] -pub use glutinloop::{GuiEventLoop, GuiSender}; +#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))] +pub use self::glutinloop::{GuiEventLoop, GuiSender, TerminalWindow, WindowId}; -#[cfg(any(windows, target_os = "macos"))] -pub use gliumwindows::TerminalWindow; +#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))] +pub use std::sync::mpsc::Receiver as GuiReceiver; -#[cfg(any(windows, target_os = "macos"))] -pub use mpsc::Receiver as GuiReceiver; - -#[cfg(any(windows, target_os = "macos"))] -pub use glium::glutin::WindowId; - -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))] pub use xwindows::xwin::TerminalWindow; -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))] mod x11; -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))] pub use self::x11::*; #[derive(Debug, Fail)] diff --git a/src/main.rs b/src/main.rs index 4ed6021fa..f44d40e38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,7 @@ extern crate x11; extern crate xcb; #[cfg(all(unix, not(target_os = "macos")))] extern crate xcb_util; -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))] mod xwindows; use std::process::Command; @@ -51,11 +51,11 @@ mod config; mod futurecore; mod opengl; -#[cfg(any(windows,target_os = "macos"))] +#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))] mod remotemio; mod clipboard; -#[cfg(any(windows,target_os = "macos"))] +#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))] mod gliumwindows; mod guiloop;