diff options
author | Aram Drevekenin <aram@poor.dev> | 2024-02-06 14:26:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 14:26:14 +0100 |
commit | 6b20a958f4e8db5614fffb27fe5d32f07ddfe855 (patch) | |
tree | c8383fb7941b5e0c23cb348a655f2ea0fafd8668 /zellij-utils/src/data.rs | |
parent | 286f7ccc28e3a091e2d3ef5663ae7878056551e6 (diff) |
feat(sessions): welcome screen (#3112)
* prototype - can send layout name for new session from session-manager
* feat(sessions): ui for selecting layout for new session in the session-manager
* fix: send available layouts to plugins
* make tests compile
* fix tests
* improve ui
* fix: respect built-in layouts
* ui for built-in layouts
* some cleanups
* style(fmt): rustfmt
* welcome screen ui
* fix: make sure layout config is not shared between sessions
* allow disconnecting other users from current session and killing other sessions
* fix: respect default layout
* add welcome screen layout
* tests(plugins): new api methods
* fix(session-manager): do not quit welcome screen on esc and break
* fix(plugins): adjust permissions
* style(fmt): rustfmt
* style(fmt): fix warnings
Diffstat (limited to 'zellij-utils/src/data.rs')
-rw-r--r-- | zellij-utils/src/data.rs | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index f1e01115d..d001b75fb 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -765,6 +765,28 @@ pub struct SessionInfo { pub panes: PaneManifest, pub connected_clients: usize, pub is_current_session: bool, + pub available_layouts: Vec<LayoutInfo>, +} + +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub enum LayoutInfo { + BuiltIn(String), + File(String), +} + +impl LayoutInfo { + pub fn name(&self) -> &str { + match self { + LayoutInfo::BuiltIn(name) => &name, + LayoutInfo::File(name) => &name, + } + } + pub fn is_builtin(&self) -> bool { + match self { + LayoutInfo::BuiltIn(_name) => true, + LayoutInfo::File(_name) => false, + } + } } use std::hash::{Hash, Hasher}; @@ -1032,12 +1054,12 @@ impl MessageToPlugin { self } pub fn new_plugin_instance_should_float(mut self, should_float: bool) -> Self { - let mut new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); + let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); new_plugin_args.should_float = Some(should_float); self } pub fn new_plugin_instance_should_replace_pane(mut self, pane_id: PaneId) -> Self { - let mut new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); + let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); new_plugin_args.pane_id_to_replace = Some(pane_id); self } @@ -1045,17 +1067,17 @@ impl MessageToPlugin { mut self, pane_title: impl Into<String>, ) -> Self { - let mut new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); + let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); new_plugin_args.pane_title = Some(pane_title.into()); self } pub fn new_plugin_instance_should_have_cwd(mut self, cwd: PathBuf) -> Self { - let mut new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); + let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); new_plugin_args.cwd = Some(cwd); self } pub fn new_plugin_instance_should_skip_cache(mut self) -> Self { - let mut new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); + let new_plugin_args = self.new_plugin_args.get_or_insert_with(Default::default); new_plugin_args.skip_cache = true; self } @@ -1066,6 +1088,17 @@ pub struct ConnectToSession { pub name: Option<String>, pub tab_position: Option<usize>, pub pane_id: Option<(u32, bool)>, // (id, is_plugin) + pub layout: Option<LayoutInfo>, +} + +impl ConnectToSession { + pub fn apply_layout_dir(&mut self, layout_dir: &PathBuf) { + if let Some(LayoutInfo::File(file_path)) = self.layout.as_mut() { + *file_path = Path::join(layout_dir, &file_path) + .to_string_lossy() + .to_string(); + } + } } #[derive(Debug, Default, Clone)] @@ -1228,4 +1261,6 @@ pub enum PluginCommand { BlockCliPipeInput(String), // String => pipe name CliPipeOutput(String, String), // String => pipe name, String => output MessageToPlugin(MessageToPlugin), + DisconnectOtherClients, + KillSessions(Vec<String>), // one or more session names } |