commit
4c079ca25d
5 changed files with 46 additions and 5 deletions
|
|
@ -33,9 +33,10 @@ impl InputHandler {
|
||||||
command_is_executing: CommandIsExecuting,
|
command_is_executing: CommandIsExecuting,
|
||||||
config: Config,
|
config: Config,
|
||||||
send_client_instructions: SenderWithContext<ClientInstruction>,
|
send_client_instructions: SenderWithContext<ClientInstruction>,
|
||||||
|
mode: InputMode,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
InputHandler {
|
InputHandler {
|
||||||
mode: InputMode::Normal,
|
mode,
|
||||||
os_input,
|
os_input,
|
||||||
config,
|
config,
|
||||||
command_is_executing,
|
command_is_executing,
|
||||||
|
|
@ -181,12 +182,14 @@ pub(crate) fn input_loop(
|
||||||
config: Config,
|
config: Config,
|
||||||
command_is_executing: CommandIsExecuting,
|
command_is_executing: CommandIsExecuting,
|
||||||
send_client_instructions: SenderWithContext<ClientInstruction>,
|
send_client_instructions: SenderWithContext<ClientInstruction>,
|
||||||
|
default_mode: InputMode,
|
||||||
) {
|
) {
|
||||||
let _handler = InputHandler::new(
|
let _handler = InputHandler::new(
|
||||||
os_input,
|
os_input,
|
||||||
command_is_executing,
|
command_is_executing,
|
||||||
config,
|
config,
|
||||||
send_client_instructions,
|
send_client_instructions,
|
||||||
|
default_mode,
|
||||||
)
|
)
|
||||||
.handle_input();
|
.handle_input();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,14 +127,18 @@ pub fn start_client(
|
||||||
ClientToServerMsg::NewClient(
|
ClientToServerMsg::NewClient(
|
||||||
client_attributes,
|
client_attributes,
|
||||||
Box::new(opts),
|
Box::new(opts),
|
||||||
Box::new(config_options),
|
Box::new(config_options.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "test", test))]
|
#[cfg(any(feature = "test", test))]
|
||||||
let first_msg = {
|
let first_msg = {
|
||||||
let _ = SESSION_NAME.set("".into());
|
let _ = SESSION_NAME.set("".into());
|
||||||
ClientToServerMsg::NewClient(client_attributes, Box::new(opts), Box::new(config_options))
|
ClientToServerMsg::NewClient(
|
||||||
|
client_attributes,
|
||||||
|
Box::new(opts),
|
||||||
|
Box::new(config_options.clone()),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
|
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
|
||||||
|
|
@ -168,12 +172,14 @@ pub fn start_client(
|
||||||
let send_client_instructions = send_client_instructions.clone();
|
let send_client_instructions = send_client_instructions.clone();
|
||||||
let command_is_executing = command_is_executing.clone();
|
let command_is_executing = command_is_executing.clone();
|
||||||
let os_input = os_input.clone();
|
let os_input = os_input.clone();
|
||||||
|
let default_mode = config_options.default_mode.unwrap_or_default();
|
||||||
move || {
|
move || {
|
||||||
input_loop(
|
input_loop(
|
||||||
os_input,
|
os_input,
|
||||||
config,
|
config,
|
||||||
command_is_executing,
|
command_is_executing,
|
||||||
send_client_instructions,
|
send_client_instructions,
|
||||||
|
default_mode,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,7 @@ pub(crate) fn screen_thread_main(
|
||||||
session_state: Arc<RwLock<SessionState>>,
|
session_state: Arc<RwLock<SessionState>>,
|
||||||
) {
|
) {
|
||||||
let capabilities = config_options.simplified_ui;
|
let capabilities = config_options.simplified_ui;
|
||||||
|
let default_mode = config_options.default_mode.unwrap_or_default();
|
||||||
|
|
||||||
let mut screen = Screen::new(
|
let mut screen = Screen::new(
|
||||||
bus,
|
bus,
|
||||||
|
|
@ -415,9 +416,10 @@ pub(crate) fn screen_thread_main(
|
||||||
capabilities: PluginCapabilities {
|
capabilities: PluginCapabilities {
|
||||||
arrow_fonts: capabilities,
|
arrow_fonts: capabilities,
|
||||||
},
|
},
|
||||||
|
mode: default_mode,
|
||||||
..ModeInfo::default()
|
..ModeInfo::default()
|
||||||
},
|
},
|
||||||
InputMode::Normal,
|
default_mode,
|
||||||
session_state,
|
session_state,
|
||||||
);
|
);
|
||||||
loop {
|
loop {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::str::FromStr;
|
||||||
use strum_macros::{EnumDiscriminants, EnumIter, EnumString, ToString};
|
use strum_macros::{EnumDiscriminants, EnumIter, EnumString, ToString};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
|
@ -92,6 +93,23 @@ impl Default for PaletteColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromStr for InputMode {
|
||||||
|
type Err = Box<dyn std::error::Error>;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"normal" => Ok(InputMode::Normal),
|
||||||
|
"resize" => Ok(InputMode::Resize),
|
||||||
|
"locked" => Ok(InputMode::Locked),
|
||||||
|
"pane" => Ok(InputMode::Pane),
|
||||||
|
"tab" => Ok(InputMode::Tab),
|
||||||
|
"scroll" => Ok(InputMode::Scroll),
|
||||||
|
"renametab" => Ok(InputMode::RenameTab),
|
||||||
|
e => Err(e.to_string().into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub enum PaletteSource {
|
pub enum PaletteSource {
|
||||||
Default,
|
Default,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
use crate::cli::Command;
|
use crate::cli::Command;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
use zellij_tile::data::InputMode;
|
||||||
|
|
||||||
#[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,
|
||||||
|
|
@ -11,6 +12,9 @@ pub struct Options {
|
||||||
/// that is compatible with more fonts
|
/// that is compatible with more fonts
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
pub simplified_ui: bool,
|
pub simplified_ui: bool,
|
||||||
|
/// Allows to specify the default mode
|
||||||
|
#[structopt(long)]
|
||||||
|
pub default_mode: Option<InputMode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
|
|
@ -32,7 +36,15 @@ impl Options {
|
||||||
self.simplified_ui
|
self.simplified_ui
|
||||||
};
|
};
|
||||||
|
|
||||||
Options { simplified_ui }
|
let default_mode = match other.default_mode {
|
||||||
|
None => self.default_mode,
|
||||||
|
other => other,
|
||||||
|
};
|
||||||
|
|
||||||
|
Options {
|
||||||
|
simplified_ui,
|
||||||
|
default_mode,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_cli(&self, other: Option<Command>) -> Options {
|
pub fn from_cli(&self, other: Option<Command>) -> Options {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue