aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-12-16 16:03:20 +0100
committerGitHub <noreply@github.com>2024-12-16 16:03:20 +0100
commitdd291e2a1f9b4ee3eb1a947e1501a54b10663ea7 (patch)
tree0ae41e8175d2a3fd260b3c510a30502f6386ac7f /zellij-utils/src/plugin_api
parentdocs(changelog): multiplayer cursor fix (diff)
downloadsl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.tar.gz
sl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.tar.xz
sl0ppij-dd291e2a1f9b4ee3eb1a947e1501a54b10663ea7.zip
feat(ux): pin floating panes (#3876)
* working * ui indication * add keybinding * add to plugin panes * fix with multiple cursors * toggle with the mouse * fix e2e tests and add new one * some cleanups * add to layouts * make mouse click more lenient * allow setting a new floating pane as pinned * make toggle work throughthe command line * add to plugin api * get tests to pass * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/plugin_api')
-rw-r--r--zellij-utils/src/plugin_api/action.proto1
-rw-r--r--zellij-utils/src/plugin_api/action.rs8
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.proto8
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs36
4 files changed, 49 insertions, 4 deletions
diff --git a/zellij-utils/src/plugin_api/action.proto b/zellij-utils/src/plugin_api/action.proto
index d78d5e69..df7f3b05 100644
--- a/zellij-utils/src/plugin_api/action.proto
+++ b/zellij-utils/src/plugin_api/action.proto
@@ -244,6 +244,7 @@ enum ActionName {
CliPipe = 82;
MoveTab = 83;
KeybindPipe = 84;
+ TogglePanePinned = 85;
}
message Position {
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs
index 9bb8ac7a..96385433 100644
--- a/zellij-utils/src/plugin_api/action.rs
+++ b/zellij-utils/src/plugin_api/action.rs
@@ -688,6 +688,10 @@ impl TryFrom<ProtobufAction> for Action {
},
_ => Err("Wrong payload for Action::RenameSession"),
},
+ Some(ProtobufActionName::TogglePanePinned) => match protobuf_action.optional_payload {
+ Some(_) => Err("TogglePanePinned should not have a payload"),
+ None => Ok(Action::TogglePanePinned),
+ },
Some(ProtobufActionName::KeybindPipe) => match protobuf_action.optional_payload {
Some(_) => Err("KeybindPipe should not have a payload"),
// TODO: at some point we might want to support a payload here
@@ -1284,6 +1288,10 @@ impl TryFrom<Action> for ProtobufAction {
name: ProtobufActionName::KeybindPipe as i32,
optional_payload: None,
}),
+ Action::TogglePanePinned { .. } => Ok(ProtobufAction {
+ name: ProtobufActionName::TogglePanePinned as i32,
+ optional_payload: None,
+ }),
Action::NoOp
| Action::Confirm
| Action::NewInPlacePane(..)
diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto
index 4cc5c10c..14e8a286 100644
--- a/zellij-utils/src/plugin_api/plugin_command.proto
+++ b/zellij-utils/src/plugin_api/plugin_command.proto
@@ -128,6 +128,7 @@ enum CommandName {
RebindKeys = 112;
ListClients = 113;
ChangeHostFolder = 114;
+ SetFloatingPanePinned = 115;
}
message PluginCommand {
@@ -212,9 +213,15 @@ message PluginCommand {
LoadNewPluginPayload load_new_plugin_payload = 87;
RebindKeysPayload rebind_keys_payload = 88;
ChangeHostFolderPayload change_host_folder_payload = 89;
+ SetFloatingPanePinnedPayload set_floating_pane_pinned_payload = 90;
}
}
+message SetFloatingPanePinnedPayload {
+ PaneId pane_id = 1;
+ bool should_be_pinned = 2;
+}
+
message ChangeHostFolderPayload {
string new_host_folder = 1;
}
@@ -485,6 +492,7 @@ message FloatingPaneCoordinates {
optional FixedOrPercentValue y = 2;
optional FixedOrPercentValue width = 3;
optional FixedOrPercentValue height = 4;
+ optional bool pinned = 5;
}
message FixedOrPercentValue {
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index 4317a02e..9d92f260 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -18,10 +18,10 @@ pub use super::generated_api::api::{
RebindKeysPayload, ReconfigurePayload, ReloadPluginPayload, RequestPluginPermissionPayload,
RerunCommandPanePayload, ResizePaneIdWithDirectionPayload, ResizePayload,
RunCommandPayload, ScrollDownInPaneIdPayload, ScrollToBottomInPaneIdPayload,
- ScrollToTopInPaneIdPayload, ScrollUpInPaneIdPayload, SetTimeoutPayload,
- ShowPaneWithIdPayload, SubscribePayload, SwitchSessionPayload, SwitchTabToPayload,
- TogglePaneEmbedOrEjectForPaneIdPayload, TogglePaneIdFullscreenPayload, UnsubscribePayload,
- WebRequestPayload, WriteCharsToPaneIdPayload, WriteToPaneIdPayload,
+ ScrollToTopInPaneIdPayload, ScrollUpInPaneIdPayload, SetFloatingPanePinnedPayload,
+ SetTimeoutPayload, ShowPaneWithIdPayload, SubscribePayload, SwitchSessionPayload,
+ SwitchTabToPayload, TogglePaneEmbedOrEjectForPaneIdPayload, TogglePaneIdFullscreenPayload,
+ UnsubscribePayload, WebRequestPayload, WriteCharsToPaneIdPayload, WriteToPaneIdPayload,
},
plugin_permission::PermissionType as ProtobufPermissionType,
resize::ResizeAction as ProtobufResizeAction,
@@ -81,6 +81,7 @@ impl Into<FloatingPaneCoordinates> for ProtobufFloatingPaneCoordinates {
None => None,
}
}),
+ pinned: self.pinned,
}
}
}
@@ -132,6 +133,7 @@ impl Into<ProtobufFloatingPaneCoordinates> for FloatingPaneCoordinates {
}),
None => None,
},
+ pinned: self.pinned,
}
}
}
@@ -1311,6 +1313,21 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
},
_ => Err("Mismatched payload for ChangeHostFolder"),
},
+ Some(CommandName::SetFloatingPanePinned) => match protobuf_plugin_command.payload {
+ Some(Payload::SetFloatingPanePinnedPayload(set_floating_pane_pinned_payload)) => {
+ match set_floating_pane_pinned_payload
+ .pane_id
+ .and_then(|p| p.try_into().ok())
+ {
+ Some(pane_id) => Ok(PluginCommand::SetFloatingPanePinned(
+ pane_id,
+ set_floating_pane_pinned_payload.should_be_pinned,
+ )),
+ None => Err("PaneId not found!"),
+ }
+ },
+ _ => Err("Mismatched payload for SetFloatingPanePinned"),
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -2144,6 +2161,17 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
new_host_folder: new_host_folder.display().to_string(), // TODO: not accurate?
})),
}),
+ PluginCommand::SetFloatingPanePinned(pane_id, should_be_pinned) => {
+ Ok(ProtobufPluginCommand {
+ name: CommandName::SetFloatingPanePinned as i32,
+ payload: Some(Payload::SetFloatingPanePinnedPayload(
+ SetFloatingPanePinnedPayload {
+ pane_id: pane_id.try_into().ok(),
+ should_be_pinned,
+ },
+ )),
+ })
+ },
}
}
}