commit
c1248ff49f
7 changed files with 24 additions and 21 deletions
|
|
@ -25,7 +25,7 @@ pub fn accepts_basic_layout() {
|
||||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||||
fake_input_output.add_terminal_input(&[&QUIT]);
|
fake_input_output.add_terminal_input(&[&QUIT]);
|
||||||
let mut opts = CliArgs::default();
|
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",
|
"src/tests/fixtures/layouts/three-panes-with-nesting.yaml",
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.connect_to_server(&*ZELLIJ_IPC_PIPE);
|
||||||
os_input.send_to_server(ClientToServerMsg::NewClient(
|
os_input.send_to_server(ClientToServerMsg::NewClient(
|
||||||
client_attributes,
|
client_attributes,
|
||||||
opts,
|
Box::new(opts),
|
||||||
config_options,
|
Box::new(config_options),
|
||||||
));
|
));
|
||||||
os_input.set_raw_mode(0);
|
os_input.set_raw_mode(0);
|
||||||
let _ = os_input
|
let _ = os_input
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ use zellij_utils::{
|
||||||
/// Instructions related to server-side application
|
/// Instructions related to server-side application
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) enum ServerInstruction {
|
pub(crate) enum ServerInstruction {
|
||||||
NewClient(ClientAttributes, CliArgs, Options),
|
NewClient(ClientAttributes, Box<CliArgs>, Box<Options>),
|
||||||
Render(Option<String>),
|
Render(Option<String>),
|
||||||
UnblockInputThread,
|
UnblockInputThread,
|
||||||
ClientExit,
|
ClientExit,
|
||||||
|
|
@ -213,8 +213,8 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
|
||||||
|
|
||||||
fn init_session(
|
fn init_session(
|
||||||
os_input: Box<dyn ServerOsApi>,
|
os_input: Box<dyn ServerOsApi>,
|
||||||
opts: CliArgs,
|
opts: Box<CliArgs>,
|
||||||
config_options: Options,
|
config_options: Box<Options>,
|
||||||
to_server: SenderWithContext<ServerInstruction>,
|
to_server: SenderWithContext<ServerInstruction>,
|
||||||
client_attributes: ClientAttributes,
|
client_attributes: ClientAttributes,
|
||||||
) -> SessionMetaData {
|
) -> SessionMetaData {
|
||||||
|
|
@ -241,10 +241,13 @@ fn init_session(
|
||||||
let default_layout = Some(PathBuf::from("default"));
|
let default_layout = Some(PathBuf::from("default"));
|
||||||
#[cfg(any(feature = "test", test))]
|
#[cfg(any(feature = "test", test))]
|
||||||
let default_layout = None;
|
let default_layout = None;
|
||||||
|
let layout_path = opts.layout_path;
|
||||||
let maybe_layout = opts
|
let maybe_layout = opts
|
||||||
.layout
|
.layout
|
||||||
.map(|p| Layout::new(&p, &data_dir))
|
.as_ref()
|
||||||
.or_else(|| default_layout.map(|p| Layout::from_defaults(&p, &data_dir)));
|
.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()
|
let pty_thread = thread::Builder::new()
|
||||||
.name("pty".to_string())
|
.name("pty".to_string())
|
||||||
|
|
|
||||||
|
|
@ -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(
|
pub(crate) fn screen_thread_main(
|
||||||
bus: Bus<ScreenInstruction>,
|
bus: Bus<ScreenInstruction>,
|
||||||
max_panes: Option<usize>,
|
max_panes: Option<usize>,
|
||||||
client_attributes: ClientAttributes,
|
client_attributes: ClientAttributes,
|
||||||
config_options: Options,
|
config_options: Box<Options>,
|
||||||
) {
|
) {
|
||||||
let capabilities = config_options.simplified_ui;
|
let capabilities = config_options.simplified_ui;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,10 +190,9 @@ pub(crate) struct Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layout {
|
impl Layout {
|
||||||
pub fn new(layout_path: &Path, data_dir: &Path) -> Self {
|
pub fn new(layout_path: &Path) -> Self {
|
||||||
let layout_dir = data_dir.join("layouts/");
|
|
||||||
let mut layout_file = File::open(&layout_path)
|
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()));
|
.unwrap_or_else(|_| panic!("cannot find layout {}", &layout_path.display()));
|
||||||
|
|
||||||
let mut layout = String::new();
|
let mut layout = String::new();
|
||||||
|
|
@ -207,14 +206,8 @@ impl Layout {
|
||||||
|
|
||||||
// It wants to use Path here, but that doesn't compile.
|
// It wants to use Path here, but that doesn't compile.
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub fn from_defaults(layout_path: &PathBuf, data_dir: &Path) -> Self {
|
pub fn from_dir(layout: &PathBuf, data_dir: &Path) -> Self {
|
||||||
Self::new(
|
Self::new(&data_dir.join("layouts/").join(layout))
|
||||||
&data_dir
|
|
||||||
.join("layouts/")
|
|
||||||
.join(layout_path)
|
|
||||||
.with_extension("yaml"),
|
|
||||||
&data_dir,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn total_terminal_panes(&self) -> usize {
|
pub fn total_terminal_panes(&self) -> usize {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ pub struct CliArgs {
|
||||||
#[structopt(short, long, parse(from_os_str))]
|
#[structopt(short, long, parse(from_os_str))]
|
||||||
pub layout: Option<PathBuf>,
|
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
|
/// Change where zellij looks for the configuration
|
||||||
#[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV, parse(from_os_str))]
|
#[structopt(short, long, env=ZELLIJ_CONFIG_FILE_ENV, parse(from_os_str))]
|
||||||
pub config: Option<PathBuf>,
|
pub config: Option<PathBuf>,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ pub enum ClientToServerMsg {
|
||||||
DisconnectFromSession,*/
|
DisconnectFromSession,*/
|
||||||
ClientExit,
|
ClientExit,
|
||||||
TerminalResize(PositionAndSize),
|
TerminalResize(PositionAndSize),
|
||||||
NewClient(ClientAttributes, CliArgs, Options),
|
NewClient(ClientAttributes, Box<CliArgs>, Box<Options>),
|
||||||
Action(Action),
|
Action(Action),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue