Add on_force_close config option
This commit is contained in:
parent
50d049a0ed
commit
67ee63548a
4 changed files with 53 additions and 1 deletions
|
|
@ -164,6 +164,8 @@ pub fn start_client(
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let on_force_close = config_options.on_force_close.unwrap_or_default();
|
||||||
|
|
||||||
let _stdin_thread = thread::Builder::new()
|
let _stdin_thread = thread::Builder::new()
|
||||||
.name("stdin_handler".to_string())
|
.name("stdin_handler".to_string())
|
||||||
.spawn({
|
.spawn({
|
||||||
|
|
@ -200,7 +202,7 @@ pub fn start_client(
|
||||||
Box::new({
|
Box::new({
|
||||||
let os_api = os_input.clone();
|
let os_api = os_input.clone();
|
||||||
move || {
|
move || {
|
||||||
os_api.send_to_server(ClientToServerMsg::Action(Action::Detach));
|
os_api.send_to_server(ClientToServerMsg::Action(on_force_close.into()));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -240,3 +240,10 @@ keybinds:
|
||||||
key: [Ctrl: 'q',]
|
key: [Ctrl: 'q',]
|
||||||
- action: [Detach,]
|
- action: [Detach,]
|
||||||
key: [Char: 'd',]
|
key: [Char: 'd',]
|
||||||
|
|
||||||
|
# Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
|
||||||
|
# eg. when terminal window with an active zellij session is closed
|
||||||
|
# Options:
|
||||||
|
# - Detach (Default)
|
||||||
|
# - Quit
|
||||||
|
#on_force_close: Quit
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
//! Definition of the actions that can be bound to keys.
|
//! Definition of the actions that can be bound to keys.
|
||||||
|
|
||||||
use super::command::RunCommandAction;
|
use super::command::RunCommandAction;
|
||||||
|
use crate::input::options::OnForceClose;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use zellij_tile::data::InputMode;
|
use zellij_tile::data::InputMode;
|
||||||
|
|
||||||
|
|
@ -81,3 +82,12 @@ pub enum Action {
|
||||||
MouseHold(Position),
|
MouseHold(Position),
|
||||||
Copy,
|
Copy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<OnForceClose> for Action {
|
||||||
|
fn from(ofc: OnForceClose) -> Action {
|
||||||
|
match ofc {
|
||||||
|
OnForceClose::Quit => Action::Quit,
|
||||||
|
OnForceClose::Detach => Action::Detach,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,34 @@
|
||||||
use crate::cli::Command;
|
use crate::cli::Command;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use zellij_tile::data::InputMode;
|
use zellij_tile::data::InputMode;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub enum OnForceClose {
|
||||||
|
Quit,
|
||||||
|
Detach,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for OnForceClose {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Detach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for OnForceClose {
|
||||||
|
type Err = Box<dyn std::error::Error>;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"quit" => Ok(Self::Quit),
|
||||||
|
"detach" => Ok(Self::Detach),
|
||||||
|
e => Err(e.to_string().into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)]
|
#[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)]
|
||||||
/// Options that can be set either through the config file,
|
/// Options that can be set either through the config file,
|
||||||
/// or cli flags
|
/// or cli flags
|
||||||
|
|
@ -30,6 +55,8 @@ pub struct Options {
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub disable_mouse_mode: bool,
|
pub disable_mouse_mode: bool,
|
||||||
|
#[structopt(long)]
|
||||||
|
pub on_force_close: Option<OnForceClose>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
|
|
@ -77,6 +104,11 @@ impl Options {
|
||||||
self.disable_mouse_mode
|
self.disable_mouse_mode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let on_force_close = match other.on_force_close {
|
||||||
|
None => self.on_force_close,
|
||||||
|
other => other,
|
||||||
|
};
|
||||||
|
|
||||||
Options {
|
Options {
|
||||||
simplified_ui,
|
simplified_ui,
|
||||||
theme,
|
theme,
|
||||||
|
|
@ -84,6 +116,7 @@ impl Options {
|
||||||
default_shell,
|
default_shell,
|
||||||
layout_dir,
|
layout_dir,
|
||||||
disable_mouse_mode,
|
disable_mouse_mode,
|
||||||
|
on_force_close,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue