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);
|
||||
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",
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub enum ClientToServerMsg {
|
|||
DisconnectFromSession,*/
|
||||
ClientExit,
|
||||
TerminalResize(PositionAndSize),
|
||||
NewClient(ClientAttributes, CliArgs, Options),
|
||||
NewClient(ClientAttributes, Box<CliArgs>, Box<Options>),
|
||||
Action(Action),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue