summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-05-18 10:47:58 +0200
committerGitHub <noreply@github.com>2021-05-18 10:47:58 +0200
commitc1248ff49f58067c5cc3df47e4633d9b91fb8829 (patch)
tree8a18820a32392fb4a8a132a27740299ac4849f84
parent8c3bf215b7c56fb1254e55ac182233ac488f3113 (diff)
parentbcbde9fbb5bffe4e1334acc1270314517938cac5 (diff)
Merge pull request #514 from a-kenji/layout-path-506
Split Layout Flag
-rw-r--r--src/tests/integration/layouts.rs2
-rw-r--r--zellij-client/src/lib.rs4
-rw-r--r--zellij-server/src/lib.rs13
-rw-r--r--zellij-server/src/screen.rs5
-rw-r--r--zellij-server/src/ui/layout.rs15
-rw-r--r--zellij-utils/src/cli.rs4
-rw-r--r--zellij-utils/src/ipc.rs2
7 files changed, 24 insertions, 21 deletions
diff --git a/src/tests/integration/layouts.rs b/src/tests/integration/layouts.rs
index 1f02122c4..e69869249 100644
--- a/src/tests/integration/layouts.rs
+++ b/src/tests/integration/layouts.rs
@@ -25,7 +25,7 @@ pub fn accepts_basic_layout() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[&QUIT]);
let mut opts = CliArgs::default();
- opts.layout = Some(PathBuf::from(
+ opts.layout_path = Some(PathBuf::from(
"src/tests/fixtures/layouts/three-panes-with-nesting.yaml",
));
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs
index 9a1a706a9..9deb415e6 100644
--- a/zellij-client/src/lib.rs
+++ b/zellij-client/src/lib.rs
@@ -111,8 +111,8 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs, config: C
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
os_input.send_to_server(ClientToServerMsg::NewClient(
client_attributes,
- opts,
- config_options,
+ Box::new(opts),
+ Box::new(config_options),
));
os_input.set_raw_mode(0);
let _ = os_input
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs
index 6fa87e481..8d82313db 100644
--- a/zellij-server/src/lib.rs
+++ b/zellij-server/src/lib.rs
@@ -36,7 +36,7 @@ use zellij_utils::{
/// Instructions related to server-side application
#[derive(Debug, Clone)]
pub(crate) enum ServerInstruction {
- NewClient(ClientAttributes, CliArgs, Options),
+ NewClient(ClientAttributes, Box<CliArgs>, Box<Options>),
Render(Option<String>),
UnblockInputThread,
ClientExit,
@@ -213,8 +213,8 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
fn init_session(
os_input: Box<dyn ServerOsApi>,
- opts: CliArgs,
- config_options: Options,
+ opts: Box<CliArgs>,
+ config_options: Box<Options>,
to_server: SenderWithContext<ServerInstruction>,
client_attributes: ClientAttributes,
) -> SessionMetaData {
@@ -241,10 +241,13 @@ fn init_session(
let default_layout = Some(PathBuf::from("default"));
#[cfg(any(feature = "test", test))]
let default_layout = None;
+ let layout_path = opts.layout_path;
let maybe_layout = opts
.layout
- .map(|p| Layout::new(&p, &data_dir))
- .or_else(|| default_layout.map(|p| Layout::from_defaults(&p, &data_dir)));
+ .as_ref()
+ .map(|p| Layout::from_dir(&p, &data_dir))
+ .or_else(|| layout_path.map(|p| Layout::new(&p)))
+ .or_else(|| default_layout.map(|p| Layout::from_dir(&p, &data_dir)));
let pty_thread = thread::Builder::new()
.name("pty".to_string())
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 178fd58e9..0500d296d 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -380,11 +380,14 @@ impl Screen {
}
}
+// The box is here in order to make the
+// NewClient enum smaller
+#[allow(clippy::boxed_local)]
pub(crate) fn screen_thread_main(
bus: Bus<ScreenInstruction>,
max_panes: Option<usize>,
client_attributes: ClientAttributes,
- config_options: Options,
+ config_options: Box<Options>,
) {
let capabilities = config_options.simplified_ui;
diff --git a/zellij-server/src/ui/layout.rs b/zellij-server/src/ui/layout.rs
index 9edf50474..3965b478c 100644
--- a/zellij-server/src/ui/layout.rs
+++ b/zellij-server/src/ui/layout.rs
@@ -190,10 +190,9 @@ pub(crate) struct Layout {
}
impl Layout {
- pub fn new(layout_path: &Path, data_dir: &Path) -> Self {
- let layout_dir = data_dir.join("layouts/");
+ pub fn new(layout_path: &Path) -> Self {
let mut layout_file = File::open(&layout_path)
- .or_else(|_| File::open(&layout_dir.join(&layout_path).with_extension("yaml")))
+ .or_else(|_| File::open(&layout_path.with_extension("yaml")))
.unwrap_or_else(|_| panic!("cannot find layout {}", &layout_path.display()));
let mut layout = String::new();
@@ -207,14 +206,8 @@ impl Layout {
// It wants to use Path here, but that doesn't compile.
#[allow(clippy::ptr_arg)]
- pub fn from_defaults(layout_path: &PathBuf, data_dir: &Path) -> Self {
- Self::new(
- &data_dir
- .join("layouts/")
- .join(layout_path)
- .with_extension("yaml"),
- &data_dir,
- )
+ pub fn from_dir(layout: &PathBuf, data_dir: &Path) -> Self {
+ Self::new(&data_dir.join("layouts/").join(layout))
}
pub fn total_terminal_panes(&self) -> usize {
diff --git a/zellij-utils/src/cli.rs b/zellij-utils/src/cli.rs
index 861a736cd..56e93edb3 100644
--- a/zellij-utils/src/cli.rs
+++ b/zellij-utils/src/cli.rs
@@ -24,6 +24,10 @@ pub struct CliArgs {
#[structopt(short, long, parse(from_os_str))]
pub layout: Option<PathBuf>,
+ /// Path to a layout yaml file
+ #[structopt(long, parse(from_os_str))]
+ pub layout_path: Option<PathBuf>,
+
/// Change where zellij looks for the configuration
#[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV, parse(from_os_str))]
pub config: Option<PathBuf>,
diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs
index b7215f69e..725bf16b0 100644
--- a/zellij-utils/src/ipc.rs
+++ b/zellij-utils/src/ipc.rs
@@ -56,7 +56,7 @@ pub enum ClientToServerMsg {
DisconnectFromSession,*/
ClientExit,
TerminalResize(PositionAndSize),
- NewClient(ClientAttributes, CliArgs, Options),
+ NewClient(ClientAttributes, Box<CliArgs>, Box<Options>),
Action(Action),
}