diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-08-24 13:36:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-24 13:36:24 +0200 |
commit | bc628abc1266cdc0dbce4f19a89727527a3e39a8 (patch) | |
tree | 6a0fcac6ec35c71a237bca0128a57a5b40afb0e3 /zellij-tile | |
parent | bf3c072d6dd68da0abd838e95e6004091a4cd331 (diff) |
feat(sessions): add a session manager to switch between sessions, tabs and panes and create new ones (#2721)
* write/read session metadata to disk for all sessions
* switch session client side
* fix tests
* various adjustments
* fix full screen focus bug in tiled panes
* fix tests
* fix permission sorting issue
* cleanups
* add session manager
* fix tests
* various cleanups
* style(fmt): rustfmt
* clear screen before switching sessions
* I hate you clippy
* truncate controls line to width
* version session cache
* attempt to fix plugin tests
* style(fmt): rustfmt
* another attempt to fix the tests in the ci
Diffstat (limited to 'zellij-tile')
-rw-r--r-- | zellij-tile/src/shim.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs index 6204767ad..2ae6770db 100644 --- a/zellij-tile/src/shim.rs +++ b/zellij-tile/src/shim.rs @@ -563,6 +563,34 @@ where unsafe { host_run_plugin_command() }; } +/// Switch to a session with the given name, create one if no name is given +pub fn switch_session(name: Option<&str>) { + let plugin_command = PluginCommand::SwitchSession(ConnectToSession { + name: name.map(|n| n.to_string()), + ..Default::default() + }); + let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap(); + object_to_stdout(&protobuf_plugin_command.encode_to_vec()); + unsafe { host_run_plugin_command() }; +} + +/// Switch to a session with the given name, focusing either the provided pane_id or the provided +/// tab position (in that order) +pub fn switch_session_with_focus( + name: &str, + tab_position: Option<usize>, + pane_id: Option<(u32, bool)>, +) { + let plugin_command = PluginCommand::SwitchSession(ConnectToSession { + name: Some(name.to_owned()), + tab_position, + pane_id, + }); + let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap(); + object_to_stdout(&protobuf_plugin_command.encode_to_vec()); + unsafe { host_run_plugin_command() }; +} + // Utility Functions /// Returns the `TabInfo` corresponding to the currently active tab |