Files
LLeMbas-TTY/window/src/connection.rs
T
Wez Furlong 754f8166b5 Add HideApplication and QuitApplication key assignments
```
[[keys]]
key = "q"
mods = "CMD"
action = "QuitApplication"
```

refs: https://github.com/wez/wezterm/issues/150
2020-02-14 08:49:15 -08:00

39 lines
1.1 KiB
Rust

use crate::Connection;
use anyhow::Result as Fallible;
use std::cell::RefCell;
use std::rc::Rc;
thread_local! {
static CONN: RefCell<Option<Rc<Connection>>> = RefCell::new(None);
}
pub trait ConnectionOps {
fn get() -> Option<Rc<Connection>> {
let mut res = None;
CONN.with(|m| {
if let Some(mux) = &*m.borrow() {
res = Some(Rc::clone(mux));
}
});
res
}
fn init() -> Fallible<Rc<Connection>> {
let conn = Rc::new(Connection::create_new()?);
CONN.with(|m| *m.borrow_mut() = Some(Rc::clone(&conn)));
crate::spawn::SPAWN_QUEUE.register_promise_schedulers();
Ok(conn)
}
fn terminate_message_loop(&self);
fn run_message_loop(&self) -> Fallible<()>;
/// Hide the application.
/// This actions hides all of the windows of the application and switches
/// focus away from it.
fn hide_application(&self) {}
// TODO: return a handle that can be used to cancel the timer
fn schedule_timer<F: FnMut() + 'static>(&self, interval: std::time::Duration, callback: F);
}