mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 05:42:03 +03:00
Add confirmation to QuitApplication action
refs: https://github.com/wez/wezterm/issues/280
This commit is contained in:
parent
cbf29c2e53
commit
1aeabba79f
@ -191,3 +191,16 @@ pub fn confirm_close_window(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn confirm_quit_program(mut term: TermWizTerminal) -> anyhow::Result<()> {
|
||||
if run_confirmation_app("🛑 Really Quit WezTerm?", &mut term)? {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
use ::window::{Connection, ConnectionOps};
|
||||
let con = Connection::get().expect("call on gui thread");
|
||||
con.terminate_message_loop();
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ mod tabnavigator;
|
||||
pub use confirm_close_pane::confirm_close_pane;
|
||||
pub use confirm_close_pane::confirm_close_tab;
|
||||
pub use confirm_close_pane::confirm_close_window;
|
||||
pub use confirm_close_pane::confirm_quit_program;
|
||||
pub use copy::CopyOverlay;
|
||||
pub use launcher::launcher;
|
||||
pub use search::SearchOverlay;
|
||||
|
@ -3,8 +3,8 @@ use super::quad::*;
|
||||
use super::renderstate::*;
|
||||
use super::utilsprites::RenderMetrics;
|
||||
use crate::gui::overlay::{
|
||||
confirm_close_pane, confirm_close_tab, confirm_close_window, launcher, start_overlay,
|
||||
start_overlay_pane, tab_navigator, CopyOverlay, SearchOverlay,
|
||||
confirm_close_pane, confirm_close_tab, confirm_close_window, confirm_quit_program, launcher,
|
||||
start_overlay, start_overlay_pane, tab_navigator, CopyOverlay, SearchOverlay,
|
||||
};
|
||||
use crate::gui::scrollbar::*;
|
||||
use crate::gui::selection::*;
|
||||
@ -1972,8 +1972,16 @@ impl TermWindow {
|
||||
con.hide_application();
|
||||
}
|
||||
QuitApplication => {
|
||||
let con = Connection::get().expect("call on gui thread");
|
||||
con.terminate_message_loop();
|
||||
let mux = Mux::get().unwrap();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => anyhow::bail!("no active tab!?"),
|
||||
};
|
||||
|
||||
let (overlay, future) =
|
||||
start_overlay(self, &tab, move |_tab_id, term| confirm_quit_program(term));
|
||||
self.assign_overlay(tab.tab_id(), overlay);
|
||||
promise::spawn::spawn(future).detach();
|
||||
}
|
||||
SelectTextAtMouseCursor(mode) => self.select_text_at_mouse_cursor(*mode, pane),
|
||||
ExtendSelectionToMouseCursor(mode) => {
|
||||
|
Loading…
Reference in New Issue
Block a user