aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/event.rs b/src/event.rs
index 39ed25f6..4f7f1a76 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -1,15 +1,21 @@
//! Process window events
+#[cfg(unix)]
+use std::fs;
use std::borrow::Cow;
use std::fs::File;
use std::io::Write;
use std::sync::mpsc;
use std::time::{Instant};
+use std::env;
use serde_json as json;
use parking_lot::MutexGuard;
use glutin::{self, ModifiersState, Event, ElementState};
use copypasta::{Clipboard, Load, Store, Buffer as ClipboardBuffer};
+use glutin::dpi::PhysicalSize;
+#[cfg(unix)]
+use crate::tty;
use crate::ansi::{Handler, ClearMode};
use crate::grid::Scroll;
use crate::config::{self, Config};
@@ -21,10 +27,9 @@ use crate::selection::Selection;
use crate::sync::FairMutex;
use crate::term::{Term, SizeInfo, TermMode, Search};
use crate::term::cell::Cell;
-use crate::util::limit;
+use crate::util::{limit, start_daemon};
use crate::util::fmt::Red;
use crate::window::Window;
-use glutin::dpi::PhysicalSize;
/// Byte sequences are sent to a `Notify` in response to some events
pub trait Notify {
@@ -177,6 +182,23 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn clear_log(&mut self) {
self.terminal.clear_log();
}
+
+ fn spawn_new_instance(&mut self) {
+ let alacritty = env::args().next().unwrap();
+ #[cfg(unix)]
+ let args = [
+ "--working-directory".into(),
+ fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID }))
+ .expect("shell working directory"),
+ ];
+ #[cfg(not(unix))]
+ let args: [&str; 0] = [];
+
+ match start_daemon(&alacritty, &args) {
+ Ok(_) => debug!("Started new Alacritty process: {} {:?}", alacritty, args),
+ Err(_) => warn!("Unable to start new Alacritty process: {} {:?}", alacritty, args),
+ }
+ }
}
/// The ActionContext can't really have direct access to the Window