From 8031d6bf645f2de10820d861292efb26358b4af1 Mon Sep 17 00:00:00 2001 From: har7an <99636919+har7an@users.noreply.github.com> Date: Mon, 28 Aug 2023 06:24:27 +0000 Subject: [PATCH] xtask/pipeline: Fix publish task (#2711) * xtask/pipeline: Fix publish task which was previously stuck in an infinite loop after successfully publishing a crate. The error originated in the code only checking for error conditions but not breaking out of the inner infinite loop in case of success. * xtask: Improve publish failure UX by offering the user more actions to choose from when an error occured. * utils/assets: Add generated prost files to assets to make sure they're available at build time and are picked up by all components. It seems we hit some strange bug with the build script where, when running `cargo publish --dry-run` the build script **is not** run before regularly compiling zellij-utils. This shouldn't happen according to the docs, but I cannot explain what's causing it. So we're using this as a workaround for now to make a smooth release. * xtask: Prevent accidental git commit deletion when dry-running a publish. * utils: Add comments to protobuf-related code to explain why these changes were performed. The comments all include a link to an issue comment explaining the situation in greater detail. * xtask: Build protobuf definitions when building any part of the project, similar to how we build the plugins when required. This should ensure that all crates built through `cargo xtask` (which is the officially supported build method) will receive up-to-date protobuf definitions. --- Cargo.lock | 1 + xtask/Cargo.toml | 1 + xtask/src/build.rs | 32 + xtask/src/pipelines.rs | 45 +- zellij-utils/assets/prost/api.action.rs | 577 ++++++++++++++++++ zellij-utils/assets/prost/api.command.rs | 10 + zellij-utils/assets/prost/api.event.rs | 381 ++++++++++++ zellij-utils/assets/prost/api.file.rs | 10 + zellij-utils/assets/prost/api.input_mode.rs | 84 +++ zellij-utils/assets/prost/api.key.rs | 298 +++++++++ zellij-utils/assets/prost/api.message.rs | 10 + .../assets/prost/api.plugin_command.rs | 409 +++++++++++++ zellij-utils/assets/prost/api.plugin_ids.rs | 14 + .../assets/prost/api.plugin_permission.rs | 38 ++ zellij-utils/assets/prost/api.resize.rs | 72 +++ zellij-utils/assets/prost/api.style.rs | 131 ++++ .../assets/prost/generated_plugin_api.rs | 38 ++ zellij-utils/build.rs | 48 +- zellij-utils/src/plugin_api/mod.rs | 16 +- 19 files changed, 2181 insertions(+), 34 deletions(-) create mode 100644 zellij-utils/assets/prost/api.action.rs create mode 100644 zellij-utils/assets/prost/api.command.rs create mode 100644 zellij-utils/assets/prost/api.event.rs create mode 100644 zellij-utils/assets/prost/api.file.rs create mode 100644 zellij-utils/assets/prost/api.input_mode.rs create mode 100644 zellij-utils/assets/prost/api.key.rs create mode 100644 zellij-utils/assets/prost/api.message.rs create mode 100644 zellij-utils/assets/prost/api.plugin_command.rs create mode 100644 zellij-utils/assets/prost/api.plugin_ids.rs create mode 100644 zellij-utils/assets/prost/api.plugin_permission.rs create mode 100644 zellij-utils/assets/prost/api.resize.rs create mode 100644 zellij-utils/assets/prost/api.style.rs create mode 100644 zellij-utils/assets/prost/generated_plugin_api.rs diff --git a/Cargo.lock b/Cargo.lock index 9fda1060a5..c089f3df80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4500,6 +4500,7 @@ version = "0.1.0" dependencies = [ "anyhow", "lazy_static", + "prost-build", "toml", "which", "xflags", diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 4a529f87c2..2ab2b1c4c7 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -11,3 +11,4 @@ xshell = "= 0.2.2" xflags = "0.3.1" which = "4.2" toml = "0.5" +prost-build = "0.11.9" diff --git a/xtask/src/build.rs b/xtask/src/build.rs index b77eda40db..4babad0c3f 100644 --- a/xtask/src/build.rs +++ b/xtask/src/build.rs @@ -38,6 +38,38 @@ pub fn build(sh: &Shell, flags: flags::Build) -> anyhow::Result<()> { } } + // zellij-utils requires protobuf definition files to be present. Usually these are + // auto-generated with `build.rs`-files, but this is currently broken for us. + // See [this PR][1] for details. + // + // [1]: https://github.com/zellij-org/zellij/pull/2711#issuecomment-1695015818 + { + let zellij_utils_basedir = crate::project_root().join("zellij-utils"); + let _pd = sh.push_dir(zellij_utils_basedir); + + let prost_asset_dir = sh.current_dir().join("assets").join("prost"); + let protobuf_source_dir = sh.current_dir().join("src").join("plugin_api"); + std::fs::create_dir_all(&prost_asset_dir).unwrap(); + + let mut prost = prost_build::Config::new(); + prost.out_dir(prost_asset_dir); + prost.include_file("generated_plugin_api.rs"); + let mut proto_files = vec![]; + for entry in std::fs::read_dir(&protobuf_source_dir).unwrap() { + let entry_path = entry.unwrap().path(); + if entry_path.is_file() { + if let Some(extension) = entry_path.extension() { + if extension == "proto" { + proto_files.push(entry_path.display().to_string()) + } + } + } + } + prost + .compile_protos(&proto_files, &[protobuf_source_dir]) + .unwrap(); + } + let _pd = sh.push_dir(Path::new(crate_name)); // Tell the user where we are now println!(); diff --git a/xtask/src/pipelines.rs b/xtask/src/pipelines.rs index 9c82c6c0a0..4195af7637 100644 --- a/xtask/src/pipelines.rs +++ b/xtask/src/pipelines.rs @@ -179,6 +179,13 @@ pub fn dist(sh: &Shell, _flags: flags::Dist) -> anyhow::Result<()> { .with_context(err_context) } +/// Actions for the user to choose from to resolve publishing errors/conflicts. +enum UserAction { + Retry, + Abort, + Ignore, +} + /// Make a zellij release and publish all crates. pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> { let err_context = "failed to publish zellij"; @@ -333,38 +340,46 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> { println!("Publishing crate '{crate_name}' failed with error:"); println!("{:?}", err); println!(); - println!("Retry? [y/n]"); + println!("Please choose what to do: [r]etry/[a]bort/[i]gnore"); let stdin = std::io::stdin(); - let mut buffer = String::new(); - let retry: bool; + let action; loop { + let mut buffer = String::new(); stdin.read_line(&mut buffer).context(err_context)?; - match buffer.trim_end() { - "y" | "Y" => { - retry = true; + "r" | "R" => { + action = UserAction::Retry; break; }, - "n" | "N" => { - retry = false; + "a" | "A" => { + action = UserAction::Abort; + break; + }, + "i" | "I" => { + action = UserAction::Ignore; break; }, _ => { println!(" --> Unknown input '{buffer}', ignoring..."); println!(); - println!("Retry? [y/n]"); + println!("Please choose what to do: [r]etry/[a]bort/[i]gnore"); }, } } - if retry { - continue; - } else { - println!("Aborting publish for crate '{crate_name}'"); - return Err::<(), _>(err); + match action { + UserAction::Retry => continue, + UserAction::Ignore => break, + UserAction::Abort => { + eprintln!("Aborting publish for crate '{crate_name}'"); + return Err::<(), _>(err); + }, } + } else { + // publish successful, continue to next crate + break; } } } @@ -380,7 +395,7 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> { // program. When dry-running we need to undo the release commit first! let result = closure(); - if flags.dry_run { + if flags.dry_run && !skip_build { cmd!(sh, "git reset --hard HEAD~1") .run() .context(err_context)?; diff --git a/zellij-utils/assets/prost/api.action.rs b/zellij-utils/assets/prost/api.action.rs new file mode 100644 index 0000000000..9099b6ef53 --- /dev/null +++ b/zellij-utils/assets/prost/api.action.rs @@ -0,0 +1,577 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Action { + #[prost(enumeration = "ActionName", tag = "1")] + pub name: i32, + #[prost( + oneof = "action::OptionalPayload", + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44" + )] + pub optional_payload: ::core::option::Option, +} +/// Nested message and enum types in `Action`. +pub mod action { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum OptionalPayload { + #[prost(message, tag = "2")] + SwitchToModePayload(super::SwitchToModePayload), + #[prost(message, tag = "3")] + WritePayload(super::WritePayload), + #[prost(message, tag = "4")] + WriteCharsPayload(super::WriteCharsPayload), + #[prost(message, tag = "5")] + SwitchModeForAllClientsPayload(super::SwitchToModePayload), + #[prost(message, tag = "6")] + ResizePayload(super::super::resize::Resize), + #[prost(enumeration = "super::super::resize::ResizeDirection", tag = "7")] + MoveFocusPayload(i32), + #[prost(enumeration = "super::super::resize::ResizeDirection", tag = "8")] + MoveFocusOrTabPayload(i32), + #[prost(message, tag = "9")] + MovePanePayload(super::MovePanePayload), + #[prost(message, tag = "10")] + DumpScreenPayload(super::DumpScreenPayload), + #[prost(message, tag = "11")] + ScrollUpAtPayload(super::ScrollAtPayload), + #[prost(message, tag = "12")] + ScrollDownAtPayload(super::ScrollAtPayload), + #[prost(message, tag = "13")] + NewPanePayload(super::NewPanePayload), + #[prost(message, tag = "14")] + EditFilePayload(super::EditFilePayload), + #[prost(message, tag = "15")] + NewFloatingPanePayload(super::NewFloatingPanePayload), + #[prost(message, tag = "16")] + NewTiledPanePayload(super::NewTiledPanePayload), + #[prost(bytes, tag = "17")] + PaneNameInputPayload(::prost::alloc::vec::Vec), + #[prost(uint32, tag = "18")] + GoToTabPayload(u32), + #[prost(message, tag = "19")] + GoToTabNamePayload(super::GoToTabNamePayload), + #[prost(bytes, tag = "20")] + TabNameInputPayload(::prost::alloc::vec::Vec), + #[prost(message, tag = "21")] + RunPayload(super::RunCommandAction), + #[prost(message, tag = "22")] + LeftClickPayload(super::Position), + #[prost(message, tag = "23")] + RightClickPayload(super::Position), + #[prost(message, tag = "24")] + MiddleClickPayload(super::Position), + #[prost(message, tag = "25")] + LaunchOrFocusPluginPayload(super::LaunchOrFocusPluginPayload), + #[prost(message, tag = "26")] + LeftMouseReleasePayload(super::Position), + #[prost(message, tag = "27")] + RightMouseReleasePayload(super::Position), + #[prost(message, tag = "28")] + MiddleMouseReleasePayload(super::Position), + #[prost(message, tag = "29")] + MouseHoldLeftPayload(super::Position), + #[prost(message, tag = "30")] + MouseHoldRightPayload(super::Position), + #[prost(message, tag = "31")] + MouseHoldMiddlePayload(super::Position), + #[prost(bytes, tag = "32")] + SearchInputPayload(::prost::alloc::vec::Vec), + #[prost(enumeration = "super::SearchDirection", tag = "33")] + SearchPayload(i32), + #[prost(enumeration = "super::SearchOption", tag = "34")] + SearchToggleOptionPayload(i32), + #[prost(message, tag = "35")] + NewTiledPluginPanePayload(super::NewPluginPanePayload), + #[prost(message, tag = "36")] + NewFloatingPluginPanePayload(super::NewPluginPanePayload), + #[prost(string, tag = "37")] + StartOrReloadPluginPayload(::prost::alloc::string::String), + #[prost(uint32, tag = "38")] + CloseTerminalPanePayload(u32), + #[prost(uint32, tag = "39")] + ClosePluginPanePayload(u32), + #[prost(message, tag = "40")] + FocusTerminalPaneWithIdPayload(super::PaneIdAndShouldFloat), + #[prost(message, tag = "41")] + FocusPluginPaneWithIdPayload(super::PaneIdAndShouldFloat), + #[prost(message, tag = "42")] + RenameTerminalPanePayload(super::IdAndName), + #[prost(message, tag = "43")] + RenamePluginPanePayload(super::IdAndName), + #[prost(message, tag = "44")] + RenameTabPayload(super::IdAndName), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IdAndName { + #[prost(bytes = "vec", tag = "1")] + pub name: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "2")] + pub id: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PaneIdAndShouldFloat { + #[prost(uint32, tag = "1")] + pub pane_id: u32, + #[prost(bool, tag = "2")] + pub should_float: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewPluginPanePayload { + #[prost(string, tag = "1")] + pub plugin_url: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub pane_name: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LaunchOrFocusPluginPayload { + #[prost(string, tag = "1")] + pub plugin_url: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub should_float: bool, + #[prost(message, optional, tag = "3")] + pub plugin_configuration: ::core::option::Option, + #[prost(bool, tag = "4")] + pub move_to_focused_tab: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GoToTabNamePayload { + #[prost(string, tag = "1")] + pub tab_name: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub create: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewFloatingPanePayload { + #[prost(message, optional, tag = "1")] + pub command: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewTiledPanePayload { + #[prost(message, optional, tag = "1")] + pub command: ::core::option::Option, + #[prost(enumeration = "super::resize::ResizeDirection", optional, tag = "2")] + pub direction: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MovePanePayload { + #[prost(enumeration = "super::resize::ResizeDirection", optional, tag = "1")] + pub direction: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EditFilePayload { + #[prost(string, tag = "1")] + pub file_to_edit: ::prost::alloc::string::String, + #[prost(uint32, optional, tag = "2")] + pub line_number: ::core::option::Option, + #[prost(string, optional, tag = "3")] + pub cwd: ::core::option::Option<::prost::alloc::string::String>, + #[prost(enumeration = "super::resize::ResizeDirection", optional, tag = "4")] + pub direction: ::core::option::Option, + #[prost(bool, tag = "5")] + pub should_float: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ScrollAtPayload { + #[prost(message, optional, tag = "1")] + pub position: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewPanePayload { + #[prost(enumeration = "super::resize::ResizeDirection", optional, tag = "1")] + pub direction: ::core::option::Option, + #[prost(string, optional, tag = "2")] + pub pane_name: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SwitchToModePayload { + #[prost(enumeration = "super::input_mode::InputMode", tag = "1")] + pub input_mode: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WritePayload { + #[prost(bytes = "vec", tag = "1")] + pub bytes_to_write: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WriteCharsPayload { + #[prost(string, tag = "1")] + pub chars: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DumpScreenPayload { + #[prost(string, tag = "1")] + pub file_path: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub include_scrollback: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Position { + #[prost(int64, tag = "1")] + pub line: i64, + #[prost(int64, tag = "2")] + pub column: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RunCommandAction { + #[prost(string, tag = "1")] + pub command: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "2")] + pub args: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, optional, tag = "3")] + pub cwd: ::core::option::Option<::prost::alloc::string::String>, + #[prost(enumeration = "super::resize::ResizeDirection", optional, tag = "4")] + pub direction: ::core::option::Option, + #[prost(string, optional, tag = "5")] + pub pane_name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, tag = "6")] + pub hold_on_close: bool, + #[prost(bool, tag = "7")] + pub hold_on_start: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PluginConfiguration { + #[prost(message, repeated, tag = "1")] + pub name_and_value: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NameAndValue { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub value: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SearchDirection { + Up = 0, + Down = 1, +} +impl SearchDirection { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + SearchDirection::Up => "Up", + SearchDirection::Down => "Down", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Up" => Some(Self::Up), + "Down" => Some(Self::Down), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SearchOption { + CaseSensitivity = 0, + WholeWord = 1, + Wrap = 2, +} +impl SearchOption { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + SearchOption::CaseSensitivity => "CaseSensitivity", + SearchOption::WholeWord => "WholeWord", + SearchOption::Wrap => "Wrap", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "CaseSensitivity" => Some(Self::CaseSensitivity), + "WholeWord" => Some(Self::WholeWord), + "Wrap" => Some(Self::Wrap), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ActionName { + Quit = 0, + Write = 1, + WriteChars = 2, + SwitchToMode = 3, + SwitchModeForAllClients = 4, + Resize = 5, + FocusNextPane = 6, + FocusPreviousPane = 7, + SwitchFocus = 8, + MoveFocus = 9, + MoveFocusOrTab = 10, + MovePane = 11, + MovePaneBackwards = 12, + ClearScreen = 13, + DumpScreen = 14, + EditScrollback = 15, + ScrollUp = 16, + ScrollUpAt = 17, + ScrollDown = 18, + ScrollDownAt = 19, + ScrollToBottom = 20, + ScrollToTop = 21, + PageScrollUp = 22, + PageScrollDown = 23, + HalfPageScrollUp = 24, + HalfPageScrollDown = 25, + ToggleFocusFullscreen = 26, + TogglePaneFrames = 27, + ToggleActiveSyncTab = 28, + NewPane = 29, + EditFile = 30, + NewFloatingPane = 31, + NewTiledPane = 32, + TogglePaneEmbedOrFloating = 33, + ToggleFloatingPanes = 34, + CloseFocus = 35, + PaneNameInput = 36, + UndoRenamePane = 37, + NewTab = 38, + NoOp = 39, + GoToNextTab = 40, + GoToPreviousTab = 41, + CloseTab = 42, + GoToTab = 43, + GoToTabName = 44, + ToggleTab = 45, + TabNameInput = 46, + UndoRenameTab = 47, + Run = 48, + Detach = 49, + LeftClick = 50, + RightClick = 51, + MiddleClick = 52, + LaunchOrFocusPlugin = 53, + LeftMouseRelease = 54, + RightMouseRelease = 55, + MiddleMouseRelease = 56, + MouseHoldLeft = 57, + MouseHoldRight = 58, + MouseHoldMiddle = 59, + SearchInput = 60, + Search = 61, + SearchToggleOption = 62, + ToggleMouseMode = 63, + PreviousSwapLayout = 64, + NextSwapLayout = 65, + QueryTabNames = 66, + NewTiledPluginPane = 67, + NewFloatingPluginPane = 68, + StartOrReloadPlugin = 69, + CloseTerminalPane = 70, + ClosePluginPane = 71, + FocusTerminalPaneWithId = 72, + FocusPluginPaneWithId = 73, + RenameTerminalPane = 74, + RenamePluginPane = 75, + RenameTab = 76, + BreakPane = 77, + BreakPaneRight = 78, + BreakPaneLeft = 79, +} +impl ActionName { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ActionName::Quit => "Quit", + ActionName::Write => "Write", + ActionName::WriteChars => "WriteChars", + ActionName::SwitchToMode => "SwitchToMode", + ActionName::SwitchModeForAllClients => "SwitchModeForAllClients", + ActionName::Resize => "Resize", + ActionName::FocusNextPane => "FocusNextPane", + ActionName::FocusPreviousPane => "FocusPreviousPane", + ActionName::SwitchFocus => "SwitchFocus", + ActionName::MoveFocus => "MoveFocus", + ActionName::MoveFocusOrTab => "MoveFocusOrTab", + ActionName::MovePane => "MovePane", + ActionName::MovePaneBackwards => "MovePaneBackwards", + ActionName::ClearScreen => "ClearScreen", + ActionName::DumpScreen => "DumpScreen", + ActionName::EditScrollback => "EditScrollback", + ActionName::ScrollUp => "ScrollUp", + ActionName::ScrollUpAt => "ScrollUpAt", + ActionName::ScrollDown => "ScrollDown", + ActionName::ScrollDownAt => "ScrollDownAt", + ActionName::ScrollToBottom => "ScrollToBottom", + ActionName::ScrollToTop => "ScrollToTop", + ActionName::PageScrollUp => "PageScrollUp", + ActionName::PageScrollDown => "PageScrollDown", + ActionName::HalfPageScrollUp => "HalfPageScrollUp", + ActionName::HalfPageScrollDown => "HalfPageScrollDown", + ActionName::ToggleFocusFullscreen => "ToggleFocusFullscreen", + ActionName::TogglePaneFrames => "TogglePaneFrames", + ActionName::ToggleActiveSyncTab => "ToggleActiveSyncTab", + ActionName::NewPane => "NewPane", + ActionName::EditFile => "EditFile", + ActionName::NewFloatingPane => "NewFloatingPane", + ActionName::NewTiledPane => "NewTiledPane", + ActionName::TogglePaneEmbedOrFloating => "TogglePaneEmbedOrFloating", + ActionName::ToggleFloatingPanes => "ToggleFloatingPanes", + ActionName::CloseFocus => "CloseFocus", + ActionName::PaneNameInput => "PaneNameInput", + ActionName::UndoRenamePane => "UndoRenamePane", + ActionName::NewTab => "NewTab", + ActionName::NoOp => "NoOp", + ActionName::GoToNextTab => "GoToNextTab", + ActionName::GoToPreviousTab => "GoToPreviousTab", + ActionName::CloseTab => "CloseTab", + ActionName::GoToTab => "GoToTab", + ActionName::GoToTabName => "GoToTabName", + ActionName::ToggleTab => "ToggleTab", + ActionName::TabNameInput => "TabNameInput", + ActionName::UndoRenameTab => "UndoRenameTab", + ActionName::Run => "Run", + ActionName::Detach => "Detach", + ActionName::LeftClick => "LeftClick", + ActionName::RightClick => "RightClick", + ActionName::MiddleClick => "MiddleClick", + ActionName::LaunchOrFocusPlugin => "LaunchOrFocusPlugin", + ActionName::LeftMouseRelease => "LeftMouseRelease", + ActionName::RightMouseRelease => "RightMouseRelease", + ActionName::MiddleMouseRelease => "MiddleMouseRelease", + ActionName::MouseHoldLeft => "MouseHoldLeft", + ActionName::MouseHoldRight => "MouseHoldRight", + ActionName::MouseHoldMiddle => "MouseHoldMiddle", + ActionName::SearchInput => "SearchInput", + ActionName::Search => "Search", + ActionName::SearchToggleOption => "SearchToggleOption", + ActionName::ToggleMouseMode => "ToggleMouseMode", + ActionName::PreviousSwapLayout => "PreviousSwapLayout", + ActionName::NextSwapLayout => "NextSwapLayout", + ActionName::QueryTabNames => "QueryTabNames", + ActionName::NewTiledPluginPane => "NewTiledPluginPane", + ActionName::NewFloatingPluginPane => "NewFloatingPluginPane", + ActionName::StartOrReloadPlugin => "StartOrReloadPlugin", + ActionName::CloseTerminalPane => "CloseTerminalPane", + ActionName::ClosePluginPane => "ClosePluginPane", + ActionName::FocusTerminalPaneWithId => "FocusTerminalPaneWithId", + ActionName::FocusPluginPaneWithId => "FocusPluginPaneWithId", + ActionName::RenameTerminalPane => "RenameTerminalPane", + ActionName::RenamePluginPane => "RenamePluginPane", + ActionName::RenameTab => "RenameTab", + ActionName::BreakPane => "BreakPane", + ActionName::BreakPaneRight => "BreakPaneRight", + ActionName::BreakPaneLeft => "BreakPaneLeft", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Quit" => Some(Self::Quit), + "Write" => Some(Self::Write), + "WriteChars" => Some(Self::WriteChars), + "SwitchToMode" => Some(Self::SwitchToMode), + "SwitchModeForAllClients" => Some(Self::SwitchModeForAllClients), + "Resize" => Some(Self::Resize), + "FocusNextPane" => Some(Self::FocusNextPane), + "FocusPreviousPane" => Some(Self::FocusPreviousPane), + "SwitchFocus" => Some(Self::SwitchFocus), + "MoveFocus" => Some(Self::MoveFocus), + "MoveFocusOrTab" => Some(Self::MoveFocusOrTab), + "MovePane" => Some(Self::MovePane), + "MovePaneBackwards" => Some(Self::MovePaneBackwards), + "ClearScreen" => Some(Self::ClearScreen), + "DumpScreen" => Some(Self::DumpScreen), + "EditScrollback" => Some(Self::EditScrollback), + "ScrollUp" => Some(Self::ScrollUp), + "ScrollUpAt" => Some(Self::ScrollUpAt), + "ScrollDown" => Some(Self::ScrollDown), + "ScrollDownAt" => Some(Self::ScrollDownAt), + "ScrollToBottom" => Some(Self::ScrollToBottom), + "ScrollToTop" => Some(Self::ScrollToTop), + "PageScrollUp" => Some(Self::PageScrollUp), + "PageScrollDown" => Some(Self::PageScrollDown), + "HalfPageScrollUp" => Some(Self::HalfPageScrollUp), + "HalfPageScrollDown" => Some(Self::HalfPageScrollDown), + "ToggleFocusFullscreen" => Some(Self::ToggleFocusFullscreen), + "TogglePaneFrames" => Some(Self::TogglePaneFrames), + "ToggleActiveSyncTab" => Some(Self::ToggleActiveSyncTab), + "NewPane" => Some(Self::NewPane), + "EditFile" => Some(Self::EditFile), + "NewFloatingPane" => Some(Self::NewFloatingPane), + "NewTiledPane" => Some(Self::NewTiledPane), + "TogglePaneEmbedOrFloating" => Some(Self::TogglePaneEmbedOrFloating), + "ToggleFloatingPanes" => Some(Self::ToggleFloatingPanes), + "CloseFocus" => Some(Self::CloseFocus), + "PaneNameInput" => Some(Self::PaneNameInput), + "UndoRenamePane" => Some(Self::UndoRenamePane), + "NewTab" => Some(Self::NewTab), + "NoOp" => Some(Self::NoOp), + "GoToNextTab" => Some(Self::GoToNextTab), + "GoToPreviousTab" => Some(Self::GoToPreviousTab), + "CloseTab" => Some(Self::CloseTab), + "GoToTab" => Some(Self::GoToTab), + "GoToTabName" => Some(Self::GoToTabName), + "ToggleTab" => Some(Self::ToggleTab), + "TabNameInput" => Some(Self::TabNameInput), + "UndoRenameTab" => Some(Self::UndoRenameTab), + "Run" => Some(Self::Run), + "Detach" => Some(Self::Detach), + "LeftClick" => Some(Self::LeftClick), + "RightClick" => Some(Self::RightClick), + "MiddleClick" => Some(Self::MiddleClick), + "LaunchOrFocusPlugin" => Some(Self::LaunchOrFocusPlugin), + "LeftMouseRelease" => Some(Self::LeftMouseRelease), + "RightMouseRelease" => Some(Self::RightMouseRelease), + "MiddleMouseRelease" => Some(Self::MiddleMouseRelease), + "MouseHoldLeft" => Some(Self::MouseHoldLeft), + "MouseHoldRight" => Some(Self::MouseHoldRight), + "MouseHoldMiddle" => Some(Self::MouseHoldMiddle), + "SearchInput" => Some(Self::SearchInput), + "Search" => Some(Self::Search), + "SearchToggleOption" => Some(Self::SearchToggleOption), + "ToggleMouseMode" => Some(Self::ToggleMouseMode), + "PreviousSwapLayout" => Some(Self::PreviousSwapLayout), + "NextSwapLayout" => Some(Self::NextSwapLayout), + "QueryTabNames" => Some(Self::QueryTabNames), + "NewTiledPluginPane" => Some(Self::NewTiledPluginPane), + "NewFloatingPluginPane" => Some(Self::NewFloatingPluginPane), + "StartOrReloadPlugin" => Some(Self::StartOrReloadPlugin), + "CloseTerminalPane" => Some(Self::CloseTerminalPane), + "ClosePluginPane" => Some(Self::ClosePluginPane), + "FocusTerminalPaneWithId" => Some(Self::FocusTerminalPaneWithId), + "FocusPluginPaneWithId" => Some(Self::FocusPluginPaneWithId), + "RenameTerminalPane" => Some(Self::RenameTerminalPane), + "RenamePluginPane" => Some(Self::RenamePluginPane), + "RenameTab" => Some(Self::RenameTab), + "BreakPane" => Some(Self::BreakPane), + "BreakPaneRight" => Some(Self::BreakPaneRight), + "BreakPaneLeft" => Some(Self::BreakPaneLeft), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.command.rs b/zellij-utils/assets/prost/api.command.rs new file mode 100644 index 0000000000..d337af638c --- /dev/null +++ b/zellij-utils/assets/prost/api.command.rs @@ -0,0 +1,10 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Command { + #[prost(string, tag = "1")] + pub path: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "2")] + pub args: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, optional, tag = "3")] + pub cwd: ::core::option::Option<::prost::alloc::string::String>, +} diff --git a/zellij-utils/assets/prost/api.event.rs b/zellij-utils/assets/prost/api.event.rs new file mode 100644 index 0000000000..39bc97705b --- /dev/null +++ b/zellij-utils/assets/prost/api.event.rs @@ -0,0 +1,381 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EventNameList { + #[prost(enumeration = "EventType", repeated, tag = "1")] + pub event_types: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Event { + #[prost(enumeration = "EventType", tag = "1")] + pub name: i32, + #[prost(oneof = "event::Payload", tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13")] + pub payload: ::core::option::Option, +} +/// Nested message and enum types in `Event`. +pub mod event { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Payload { + #[prost(message, tag = "2")] + ModeUpdatePayload(super::ModeUpdatePayload), + #[prost(message, tag = "3")] + TabUpdatePayload(super::TabUpdatePayload), + #[prost(message, tag = "4")] + PaneUpdatePayload(super::PaneUpdatePayload), + #[prost(message, tag = "5")] + KeyPayload(super::super::key::Key), + #[prost(message, tag = "6")] + MouseEventPayload(super::MouseEventPayload), + #[prost(float, tag = "7")] + TimerPayload(f32), + #[prost(enumeration = "super::CopyDestination", tag = "8")] + CopyToClipboardPayload(i32), + #[prost(bool, tag = "9")] + VisiblePayload(bool), + #[prost(message, tag = "10")] + CustomMessagePayload(super::CustomMessagePayload), + #[prost(message, tag = "11")] + FileListPayload(super::FileListPayload), + #[prost(message, tag = "12")] + PermissionRequestResultPayload(super::PermissionRequestResultPayload), + #[prost(message, tag = "13")] + SessionUpdatePayload(super::SessionUpdatePayload), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SessionUpdatePayload { + #[prost(message, repeated, tag = "1")] + pub session_manifests: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PermissionRequestResultPayload { + #[prost(bool, tag = "1")] + pub granted: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FileListPayload { + #[prost(string, repeated, tag = "1")] + pub paths: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CustomMessagePayload { + #[prost(string, tag = "1")] + pub message_name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub payload: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MouseEventPayload { + #[prost(enumeration = "MouseEventName", tag = "1")] + pub mouse_event_name: i32, + #[prost(oneof = "mouse_event_payload::MouseEventPayload", tags = "2, 3")] + pub mouse_event_payload: ::core::option::Option< + mouse_event_payload::MouseEventPayload, + >, +} +/// Nested message and enum types in `MouseEventPayload`. +pub mod mouse_event_payload { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum MouseEventPayload { + #[prost(uint32, tag = "2")] + LineCount(u32), + #[prost(message, tag = "3")] + Position(super::super::action::Position), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TabUpdatePayload { + #[prost(message, repeated, tag = "1")] + pub tab_info: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PaneUpdatePayload { + #[prost(message, repeated, tag = "1")] + pub pane_manifest: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PaneManifest { + #[prost(uint32, tag = "1")] + pub tab_index: u32, + #[prost(message, repeated, tag = "2")] + pub panes: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SessionManifest { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub tabs: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub panes: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "4")] + pub connected_clients: u32, + #[prost(bool, tag = "5")] + pub is_current_session: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PaneInfo { + #[prost(uint32, tag = "1")] + pub id: u32, + #[prost(bool, tag = "2")] + pub is_plugin: bool, + #[prost(bool, tag = "3")] + pub is_focused: bool, + #[prost(bool, tag = "4")] + pub is_fullscreen: bool, + #[prost(bool, tag = "5")] + pub is_floating: bool, + #[prost(bool, tag = "6")] + pub is_suppressed: bool, + #[prost(string, tag = "7")] + pub title: ::prost::alloc::string::String, + #[prost(bool, tag = "8")] + pub exited: bool, + #[prost(int32, optional, tag = "9")] + pub exit_status: ::core::option::Option, + #[prost(bool, tag = "10")] + pub is_held: bool, + #[prost(uint32, tag = "11")] + pub pane_x: u32, + #[prost(uint32, tag = "12")] + pub pane_content_x: u32, + #[prost(uint32, tag = "13")] + pub pane_y: u32, + #[prost(uint32, tag = "14")] + pub pane_content_y: u32, + #[prost(uint32, tag = "15")] + pub pane_rows: u32, + #[prost(uint32, tag = "16")] + pub pane_content_rows: u32, + #[prost(uint32, tag = "17")] + pub pane_columns: u32, + #[prost(uint32, tag = "18")] + pub pane_content_columns: u32, + #[prost(message, optional, tag = "19")] + pub cursor_coordinates_in_pane: ::core::option::Option, + #[prost(string, optional, tag = "20")] + pub terminal_command: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag = "21")] + pub plugin_url: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, tag = "22")] + pub is_selectable: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TabInfo { + #[prost(uint32, tag = "1")] + pub position: u32, + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, + #[prost(bool, tag = "3")] + pub active: bool, + #[prost(uint32, tag = "4")] + pub panes_to_hide: u32, + #[prost(bool, tag = "5")] + pub is_fullscreen_active: bool, + #[prost(bool, tag = "6")] + pub is_sync_panes_active: bool, + #[prost(bool, tag = "7")] + pub are_floating_panes_visible: bool, + #[prost(uint32, repeated, tag = "8")] + pub other_focused_clients: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "9")] + pub active_swap_layout_name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, tag = "10")] + pub is_swap_layout_dirty: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModeUpdatePayload { + #[prost(enumeration = "super::input_mode::InputMode", tag = "1")] + pub current_mode: i32, + #[prost(message, repeated, tag = "2")] + pub keybinds: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub style: ::core::option::Option, + #[prost(bool, tag = "4")] + pub arrow_fonts_support: bool, + #[prost(string, optional, tag = "5")] + pub session_name: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InputModeKeybinds { + #[prost(enumeration = "super::input_mode::InputMode", tag = "1")] + pub mode: i32, + #[prost(message, repeated, tag = "2")] + pub key_bind: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct KeyBind { + #[prost(message, optional, tag = "1")] + pub key: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub action: ::prost::alloc::vec::Vec, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum EventType { + /// / The input mode or relevant metadata changed + ModeUpdate = 0, + /// / The tab state in the app was changed + TabUpdate = 1, + /// / The pane state in the app was changed + PaneUpdate = 2, + /// / A key was pressed while the user is focused on this plugin's pane + Key = 3, + /// / A mouse event happened while the user is focused on this plugin's pane + Mouse = 4, + /// / A timer expired set by the `set_timeout` method exported by `zellij-tile`. + Timer = 5, + /// / Text was copied to the clipboard anywhere in the app + CopyToClipboard = 6, + /// / Failed to copy text to clipboard anywhere in the app + SystemClipboardFailure = 7, + /// / Input was received anywhere in the app + InputReceived = 8, + /// / This plugin became visible or invisible + Visible = 9, + /// / A message from one of the plugin's workers + CustomMessage = 10, + /// / A file was created somewhere in the Zellij CWD folder + FileSystemCreate = 11, + /// / A file was accessed somewhere in the Zellij CWD folder + FileSystemRead = 12, + /// / A file was modified somewhere in the Zellij CWD folder + FileSystemUpdate = 13, + /// / A file was deleted somewhere in the Zellij CWD folder + FileSystemDelete = 14, + PermissionRequestResult = 15, + SessionUpdate = 16, +} +impl EventType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + EventType::ModeUpdate => "ModeUpdate", + EventType::TabUpdate => "TabUpdate", + EventType::PaneUpdate => "PaneUpdate", + EventType::Key => "Key", + EventType::Mouse => "Mouse", + EventType::Timer => "Timer", + EventType::CopyToClipboard => "CopyToClipboard", + EventType::SystemClipboardFailure => "SystemClipboardFailure", + EventType::InputReceived => "InputReceived", + EventType::Visible => "Visible", + EventType::CustomMessage => "CustomMessage", + EventType::FileSystemCreate => "FileSystemCreate", + EventType::FileSystemRead => "FileSystemRead", + EventType::FileSystemUpdate => "FileSystemUpdate", + EventType::FileSystemDelete => "FileSystemDelete", + EventType::PermissionRequestResult => "PermissionRequestResult", + EventType::SessionUpdate => "SessionUpdate", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ModeUpdate" => Some(Self::ModeUpdate), + "TabUpdate" => Some(Self::TabUpdate), + "PaneUpdate" => Some(Self::PaneUpdate), + "Key" => Some(Self::Key), + "Mouse" => Some(Self::Mouse), + "Timer" => Some(Self::Timer), + "CopyToClipboard" => Some(Self::CopyToClipboard), + "SystemClipboardFailure" => Some(Self::SystemClipboardFailure), + "InputReceived" => Some(Self::InputReceived), + "Visible" => Some(Self::Visible), + "CustomMessage" => Some(Self::CustomMessage), + "FileSystemCreate" => Some(Self::FileSystemCreate), + "FileSystemRead" => Some(Self::FileSystemRead), + "FileSystemUpdate" => Some(Self::FileSystemUpdate), + "FileSystemDelete" => Some(Self::FileSystemDelete), + "PermissionRequestResult" => Some(Self::PermissionRequestResult), + "SessionUpdate" => Some(Self::SessionUpdate), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum CopyDestination { + Command = 0, + Primary = 1, + System = 2, +} +impl CopyDestination { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + CopyDestination::Command => "Command", + CopyDestination::Primary => "Primary", + CopyDestination::System => "System", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Command" => Some(Self::Command), + "Primary" => Some(Self::Primary), + "System" => Some(Self::System), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum MouseEventName { + MouseScrollUp = 0, + MouseScrollDown = 1, + MouseLeftClick = 2, + MouseRightClick = 3, + MouseHold = 4, + MouseRelease = 5, +} +impl MouseEventName { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + MouseEventName::MouseScrollUp => "MouseScrollUp", + MouseEventName::MouseScrollDown => "MouseScrollDown", + MouseEventName::MouseLeftClick => "MouseLeftClick", + MouseEventName::MouseRightClick => "MouseRightClick", + MouseEventName::MouseHold => "MouseHold", + MouseEventName::MouseRelease => "MouseRelease", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "MouseScrollUp" => Some(Self::MouseScrollUp), + "MouseScrollDown" => Some(Self::MouseScrollDown), + "MouseLeftClick" => Some(Self::MouseLeftClick), + "MouseRightClick" => Some(Self::MouseRightClick), + "MouseHold" => Some(Self::MouseHold), + "MouseRelease" => Some(Self::MouseRelease), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.file.rs b/zellij-utils/assets/prost/api.file.rs new file mode 100644 index 0000000000..12aa729397 --- /dev/null +++ b/zellij-utils/assets/prost/api.file.rs @@ -0,0 +1,10 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct File { + #[prost(string, tag = "1")] + pub path: ::prost::alloc::string::String, + #[prost(int32, optional, tag = "2")] + pub line_number: ::core::option::Option, + #[prost(string, optional, tag = "3")] + pub cwd: ::core::option::Option<::prost::alloc::string::String>, +} diff --git a/zellij-utils/assets/prost/api.input_mode.rs b/zellij-utils/assets/prost/api.input_mode.rs new file mode 100644 index 0000000000..97e46481e7 --- /dev/null +++ b/zellij-utils/assets/prost/api.input_mode.rs @@ -0,0 +1,84 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InputModeMessage { + #[prost(enumeration = "InputMode", tag = "1")] + pub input_mode: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum InputMode { + /// / In `Normal` mode, input is always written to the terminal, except for the shortcuts leading + /// / to other modes + Normal = 0, + /// / In `Locked` mode, input is always written to the terminal and all shortcuts are disabled + /// / except the one leading back to normal mode + Locked = 1, + /// / `Resize` mode allows resizing the different existing panes. + Resize = 2, + /// / `Pane` mode allows creating and closing panes, as well as moving between them. + Pane = 3, + /// / `Tab` mode allows creating and closing tabs, as well as moving between them. + Tab = 4, + /// / `Scroll` mode allows scrolling up and down within a pane. + Scroll = 5, + /// / `EnterSearch` mode allows for typing in the needle for a search in the scroll buffer of a pane. + EnterSearch = 6, + /// / `Search` mode allows for searching a term in a pane (superset of `Scroll`). + Search = 7, + /// / `RenameTab` mode allows assigning a new name to a tab. + RenameTab = 8, + /// / `RenamePane` mode allows assigning a new name to a pane. + RenamePane = 9, + /// / `Session` mode allows detaching sessions + Session = 10, + /// / `Move` mode allows moving the different existing panes within a tab + Move = 11, + /// / `Prompt` mode allows interacting with active prompts. + Prompt = 12, + /// / `Tmux` mode allows for basic tmux keybindings functionality + Tmux = 13, +} +impl InputMode { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + InputMode::Normal => "Normal", + InputMode::Locked => "Locked", + InputMode::Resize => "Resize", + InputMode::Pane => "Pane", + InputMode::Tab => "Tab", + InputMode::Scroll => "Scroll", + InputMode::EnterSearch => "EnterSearch", + InputMode::Search => "Search", + InputMode::RenameTab => "RenameTab", + InputMode::RenamePane => "RenamePane", + InputMode::Session => "Session", + InputMode::Move => "Move", + InputMode::Prompt => "Prompt", + InputMode::Tmux => "Tmux", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Normal" => Some(Self::Normal), + "Locked" => Some(Self::Locked), + "Resize" => Some(Self::Resize), + "Pane" => Some(Self::Pane), + "Tab" => Some(Self::Tab), + "Scroll" => Some(Self::Scroll), + "EnterSearch" => Some(Self::EnterSearch), + "Search" => Some(Self::Search), + "RenameTab" => Some(Self::RenameTab), + "RenamePane" => Some(Self::RenamePane), + "Session" => Some(Self::Session), + "Move" => Some(Self::Move), + "Prompt" => Some(Self::Prompt), + "Tmux" => Some(Self::Tmux), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.key.rs b/zellij-utils/assets/prost/api.key.rs new file mode 100644 index 0000000000..186f41c181 --- /dev/null +++ b/zellij-utils/assets/prost/api.key.rs @@ -0,0 +1,298 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Key { + #[prost(enumeration = "key::KeyModifier", optional, tag = "1")] + pub modifier: ::core::option::Option, + #[prost(oneof = "key::MainKey", tags = "2, 3")] + pub main_key: ::core::option::Option, +} +/// Nested message and enum types in `Key`. +pub mod key { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum KeyModifier { + Ctrl = 0, + Alt = 1, + } + impl KeyModifier { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + KeyModifier::Ctrl => "CTRL", + KeyModifier::Alt => "ALT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "CTRL" => Some(Self::Ctrl), + "ALT" => Some(Self::Alt), + _ => None, + } + } + } + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum NamedKey { + PageDown = 0, + PageUp = 1, + LeftArrow = 2, + DownArrow = 3, + UpArrow = 4, + RightArrow = 5, + Home = 6, + End = 7, + Backspace = 8, + Delete = 9, + Insert = 10, + F1 = 11, + F2 = 12, + F3 = 13, + F4 = 14, + F5 = 15, + F6 = 16, + F7 = 17, + F8 = 18, + F9 = 19, + F10 = 20, + F11 = 21, + F12 = 22, + Tab = 23, + Esc = 24, + } + impl NamedKey { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + NamedKey::PageDown => "PageDown", + NamedKey::PageUp => "PageUp", + NamedKey::LeftArrow => "LeftArrow", + NamedKey::DownArrow => "DownArrow", + NamedKey::UpArrow => "UpArrow", + NamedKey::RightArrow => "RightArrow", + NamedKey::Home => "Home", + NamedKey::End => "End", + NamedKey::Backspace => "Backspace", + NamedKey::Delete => "Delete", + NamedKey::Insert => "Insert", + NamedKey::F1 => "F1", + NamedKey::F2 => "F2", + NamedKey::F3 => "F3", + NamedKey::F4 => "F4", + NamedKey::F5 => "F5", + NamedKey::F6 => "F6", + NamedKey::F7 => "F7", + NamedKey::F8 => "F8", + NamedKey::F9 => "F9", + NamedKey::F10 => "F10", + NamedKey::F11 => "F11", + NamedKey::F12 => "F12", + NamedKey::Tab => "Tab", + NamedKey::Esc => "Esc", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "PageDown" => Some(Self::PageDown), + "PageUp" => Some(Self::PageUp), + "LeftArrow" => Some(Self::LeftArrow), + "DownArrow" => Some(Self::DownArrow), + "UpArrow" => Some(Self::UpArrow), + "RightArrow" => Some(Self::RightArrow), + "Home" => Some(Self::Home), + "End" => Some(Self::End), + "Backspace" => Some(Self::Backspace), + "Delete" => Some(Self::Delete), + "Insert" => Some(Self::Insert), + "F1" => Some(Self::F1), + "F2" => Some(Self::F2), + "F3" => Some(Self::F3), + "F4" => Some(Self::F4), + "F5" => Some(Self::F5), + "F6" => Some(Self::F6), + "F7" => Some(Self::F7), + "F8" => Some(Self::F8), + "F9" => Some(Self::F9), + "F10" => Some(Self::F10), + "F11" => Some(Self::F11), + "F12" => Some(Self::F12), + "Tab" => Some(Self::Tab), + "Esc" => Some(Self::Esc), + _ => None, + } + } + } + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Char { + A = 0, + B = 1, + C = 2, + D = 3, + E = 4, + F = 5, + G = 6, + H = 7, + I = 8, + J = 9, + K = 10, + L = 11, + M = 12, + N = 13, + O = 14, + P = 15, + Q = 16, + R = 17, + S = 18, + T = 19, + U = 20, + V = 21, + W = 22, + X = 23, + Y = 24, + Z = 25, + Zero = 26, + One = 27, + Two = 28, + Three = 29, + Four = 30, + Five = 31, + Six = 32, + Seven = 33, + Eight = 34, + Nine = 35, + } + impl Char { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Char::A => "a", + Char::B => "b", + Char::C => "c", + Char::D => "d", + Char::E => "e", + Char::F => "f", + Char::G => "g", + Char::H => "h", + Char::I => "i", + Char::J => "j", + Char::K => "k", + Char::L => "l", + Char::M => "m", + Char::N => "n", + Char::O => "o", + Char::P => "p", + Char::Q => "q", + Char::R => "r", + Char::S => "s", + Char::T => "t", + Char::U => "u", + Char::V => "v", + Char::W => "w", + Char::X => "x", + Char::Y => "y", + Char::Z => "z", + Char::Zero => "zero", + Char::One => "one", + Char::Two => "two", + Char::Three => "three", + Char::Four => "four", + Char::Five => "five", + Char::Six => "six", + Char::Seven => "seven", + Char::Eight => "eight", + Char::Nine => "nine", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "a" => Some(Self::A), + "b" => Some(Self::B), + "c" => Some(Self::C), + "d" => Some(Self::D), + "e" => Some(Self::E), + "f" => Some(Self::F), + "g" => Some(Self::G), + "h" => Some(Self::H), + "i" => Some(Self::I), + "j" => Some(Self::J), + "k" => Some(Self::K), + "l" => Some(Self::L), + "m" => Some(Self::M), + "n" => Some(Self::N), + "o" => Some(Self::O), + "p" => Some(Self::P), + "q" => Some(Self::Q), + "r" => Some(Self::R), + "s" => Some(Self::S), + "t" => Some(Self::T), + "u" => Some(Self::U), + "v" => Some(Self::V), + "w" => Some(Self::W), + "x" => Some(Self::X), + "y" => Some(Self::Y), + "z" => Some(Self::Z), + "zero" => Some(Self::Zero), + "one" => Some(Self::One), + "two" => Some(Self::Two), + "three" => Some(Self::Three), + "four" => Some(Self::Four), + "five" => Some(Self::Five), + "six" => Some(Self::Six), + "seven" => Some(Self::Seven), + "eight" => Some(Self::Eight), + "nine" => Some(Self::Nine), + _ => None, + } + } + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum MainKey { + #[prost(enumeration = "NamedKey", tag = "2")] + Key(i32), + #[prost(enumeration = "Char", tag = "3")] + Char(i32), + } +} diff --git a/zellij-utils/assets/prost/api.message.rs b/zellij-utils/assets/prost/api.message.rs new file mode 100644 index 0000000000..e040e13fff --- /dev/null +++ b/zellij-utils/assets/prost/api.message.rs @@ -0,0 +1,10 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub payload: ::prost::alloc::string::String, + #[prost(string, optional, tag = "3")] + pub worker_name: ::core::option::Option<::prost::alloc::string::String>, +} diff --git a/zellij-utils/assets/prost/api.plugin_command.rs b/zellij-utils/assets/prost/api.plugin_command.rs new file mode 100644 index 0000000000..da13196c00 --- /dev/null +++ b/zellij-utils/assets/prost/api.plugin_command.rs @@ -0,0 +1,409 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PluginCommand { + #[prost(enumeration = "CommandName", tag = "1")] + pub name: i32, + #[prost( + oneof = "plugin_command::Payload", + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39" + )] + pub payload: ::core::option::Option, +} +/// Nested message and enum types in `PluginCommand`. +pub mod plugin_command { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Payload { + #[prost(message, tag = "2")] + SubscribePayload(super::SubscribePayload), + #[prost(message, tag = "3")] + UnsubscribePayload(super::UnsubscribePayload), + #[prost(bool, tag = "4")] + SetSelectablePayload(bool), + #[prost(message, tag = "5")] + OpenFilePayload(super::OpenFilePayload), + #[prost(message, tag = "6")] + OpenFileFloatingPayload(super::OpenFilePayload), + #[prost(message, tag = "7")] + OpenTerminalPayload(super::OpenFilePayload), + #[prost(message, tag = "8")] + OpenTerminalFloatingPayload(super::OpenFilePayload), + #[prost(message, tag = "9")] + OpenCommandPanePayload(super::OpenCommandPanePayload), + #[prost(message, tag = "10")] + OpenCommandPaneFloatingPayload(super::OpenCommandPanePayload), + #[prost(message, tag = "11")] + SwitchTabToPayload(super::SwitchTabToPayload), + #[prost(message, tag = "12")] + SetTimeoutPayload(super::SetTimeoutPayload), + #[prost(message, tag = "13")] + ExecCmdPayload(super::ExecCmdPayload), + #[prost(message, tag = "14")] + PostMessageToPayload(super::PluginMessagePayload), + #[prost(message, tag = "15")] + PostMessageToPluginPayload(super::PluginMessagePayload), + #[prost(bool, tag = "16")] + ShowSelfPayload(bool), + #[prost(message, tag = "17")] + SwitchToModePayload(super::super::action::SwitchToModePayload), + #[prost(string, tag = "18")] + NewTabsWithLayoutPayload(::prost::alloc::string::String), + #[prost(message, tag = "19")] + ResizePayload(super::ResizePayload), + #[prost(message, tag = "20")] + ResizeWithDirectionPayload(super::ResizePayload), + #[prost(message, tag = "21")] + MoveFocusPayload(super::MovePayload), + #[prost(message, tag = "22")] + MoveFocusOrTabPayload(super::MovePayload), + #[prost(bytes, tag = "23")] + WritePayload(::prost::alloc::vec::Vec), + #[prost(string, tag = "24")] + WriteCharsPayload(::prost::alloc::string::String), + #[prost(message, tag = "25")] + MovePaneWithDirectionPayload(super::MovePayload), + #[prost(string, tag = "26")] + GoToTabNamePayload(::prost::alloc::string::String), + #[prost(string, tag = "27")] + FocusOrCreateTabPayload(::prost::alloc::string::String), + #[prost(uint32, tag = "28")] + GoToTabPayload(u32), + #[prost(string, tag = "29")] + StartOrReloadPluginPayload(::prost::alloc::string::String), + #[prost(uint32, tag = "30")] + CloseTerminalPanePayload(u32), + #[prost(uint32, tag = "31")] + ClosePluginPanePayload(u32), + #[prost(message, tag = "32")] + FocusTerminalPanePayload(super::super::action::PaneIdAndShouldFloat), + #[prost(message, tag = "33")] + FocusPluginPanePayload(super::super::action::PaneIdAndShouldFloat), + #[prost(message, tag = "34")] + RenameTerminalPanePayload(super::IdAndNewName), + #[prost(message, tag = "35")] + RenamePluginPanePayload(super::IdAndNewName), + #[prost(message, tag = "36")] + RenameTabPayload(super::IdAndNewName), + #[prost(string, tag = "37")] + ReportCrashPayload(::prost::alloc::string::String), + #[prost(message, tag = "38")] + RequestPluginPermissionPayload(super::RequestPluginPermissionPayload), + #[prost(message, tag = "39")] + SwitchSessionPayload(super::SwitchSessionPayload), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SwitchSessionPayload { + #[prost(string, optional, tag = "1")] + pub name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(uint32, optional, tag = "2")] + pub tab_position: ::core::option::Option, + #[prost(uint32, optional, tag = "3")] + pub pane_id: ::core::option::Option, + #[prost(bool, optional, tag = "4")] + pub pane_id_is_plugin: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestPluginPermissionPayload { + #[prost( + enumeration = "super::plugin_permission::PermissionType", + repeated, + tag = "1" + )] + pub permissions: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubscribePayload { + #[prost(message, optional, tag = "1")] + pub subscriptions: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UnsubscribePayload { + #[prost(message, optional, tag = "1")] + pub subscriptions: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OpenFilePayload { + #[prost(message, optional, tag = "1")] + pub file_to_open: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OpenCommandPanePayload { + #[prost(message, optional, tag = "1")] + pub command_to_run: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SwitchTabToPayload { + #[prost(uint32, tag = "1")] + pub tab_index: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SetTimeoutPayload { + #[prost(double, tag = "1")] + pub seconds: f64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExecCmdPayload { + #[prost(string, repeated, tag = "1")] + pub command_line: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PluginMessagePayload { + #[prost(message, optional, tag = "1")] + pub message: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResizePayload { + #[prost(message, optional, tag = "1")] + pub resize: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MovePayload { + #[prost(message, optional, tag = "1")] + pub direction: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IdAndNewName { + /// pane id or tab index + #[prost(uint32, tag = "1")] + pub id: u32, + #[prost(string, tag = "2")] + pub new_name: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum CommandName { + Subscribe = 0, + Unsubscribe = 1, + SetSelectable = 2, + GetPluginIds = 3, + GetZellijVersion = 4, + OpenFile = 5, + OpenFileFloating = 6, + OpenTerminal = 7, + OpenTerminalFloating = 8, + OpenCommandPane = 9, + OpenCommandPaneFloating = 10, + SwitchTabTo = 11, + SetTimeout = 12, + ExecCmd = 13, + PostMessageTo = 14, + PostMessageToPlugin = 15, + HideSelf = 16, + ShowSelf = 17, + SwitchToMode = 18, + NewTabsWithLayout = 19, + NewTab = 20, + GoToNextTab = 21, + GoToPreviousTab = 22, + Resize = 23, + ResizeWithDirection = 24, + FocusNextPane = 25, + FocusPreviousPane = 26, + MoveFocus = 27, + MoveFocusOrTab = 28, + Detach = 29, + EditScrollback = 30, + Write = 31, + WriteChars = 32, + ToggleTab = 33, + MovePane = 34, + MovePaneWithDirection = 35, + ClearScreen = 36, + ScrollUp = 37, + ScrollDown = 38, + ScrollToTop = 39, + ScrollToBottom = 40, + PageScrollUp = 41, + PageScrollDown = 42, + ToggleFocusFullscreen = 43, + TogglePaneFrames = 44, + TogglePaneEmbedOrEject = 45, + UndoRenamePane = 46, + CloseFocus = 47, + ToggleActiveTabSync = 48, + CloseFocusedTab = 49, + UndoRenameTab = 50, + QuitZellij = 51, + PreviousSwapLayout = 52, + NextSwapLayout = 53, + GoToTabName = 54, + FocusOrCreateTab = 55, + GoToTab = 56, + StartOrReloadPlugin = 57, + CloseTerminalPane = 58, + ClosePluginPane = 59, + FocusTerminalPane = 60, + FocusPluginPane = 61, + RenameTerminalPane = 62, + RenamePluginPane = 63, + RenameTab = 64, + ReportCrash = 65, + RequestPluginPermissions = 66, + SwitchSession = 67, +} +impl CommandName { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + CommandName::Subscribe => "Subscribe", + CommandName::Unsubscribe => "Unsubscribe", + CommandName::SetSelectable => "SetSelectable", + CommandName::GetPluginIds => "GetPluginIds", + CommandName::GetZellijVersion => "GetZellijVersion", + CommandName::OpenFile => "OpenFile", + CommandName::OpenFileFloating => "OpenFileFloating", + CommandName::OpenTerminal => "OpenTerminal", + CommandName::OpenTerminalFloating => "OpenTerminalFloating", + CommandName::OpenCommandPane => "OpenCommandPane", + CommandName::OpenCommandPaneFloating => "OpenCommandPaneFloating", + CommandName::SwitchTabTo => "SwitchTabTo", + CommandName::SetTimeout => "SetTimeout", + CommandName::ExecCmd => "ExecCmd", + CommandName::PostMessageTo => "PostMessageTo", + CommandName::PostMessageToPlugin => "PostMessageToPlugin", + CommandName::HideSelf => "HideSelf", + CommandName::ShowSelf => "ShowSelf", + CommandName::SwitchToMode => "SwitchToMode", + CommandName::NewTabsWithLayout => "NewTabsWithLayout", + CommandName::NewTab => "NewTab", + CommandName::GoToNextTab => "GoToNextTab", + CommandName::GoToPreviousTab => "GoToPreviousTab", + CommandName::Resize => "Resize", + CommandName::ResizeWithDirection => "ResizeWithDirection", + CommandName::FocusNextPane => "FocusNextPane", + CommandName::FocusPreviousPane => "FocusPreviousPane", + CommandName::MoveFocus => "MoveFocus", + CommandName::MoveFocusOrTab => "MoveFocusOrTab", + CommandName::Detach => "Detach", + CommandName::EditScrollback => "EditScrollback", + CommandName::Write => "Write", + CommandName::WriteChars => "WriteChars", + CommandName::ToggleTab => "ToggleTab", + CommandName::MovePane => "MovePane", + CommandName::MovePaneWithDirection => "MovePaneWithDirection", + CommandName::ClearScreen => "ClearScreen", + CommandName::ScrollUp => "ScrollUp", + CommandName::ScrollDown => "ScrollDown", + CommandName::ScrollToTop => "ScrollToTop", + CommandName::ScrollToBottom => "ScrollToBottom", + CommandName::PageScrollUp => "PageScrollUp", + CommandName::PageScrollDown => "PageScrollDown", + CommandName::ToggleFocusFullscreen => "ToggleFocusFullscreen", + CommandName::TogglePaneFrames => "TogglePaneFrames", + CommandName::TogglePaneEmbedOrEject => "TogglePaneEmbedOrEject", + CommandName::UndoRenamePane => "UndoRenamePane", + CommandName::CloseFocus => "CloseFocus", + CommandName::ToggleActiveTabSync => "ToggleActiveTabSync", + CommandName::CloseFocusedTab => "CloseFocusedTab", + CommandName::UndoRenameTab => "UndoRenameTab", + CommandName::QuitZellij => "QuitZellij", + CommandName::PreviousSwapLayout => "PreviousSwapLayout", + CommandName::NextSwapLayout => "NextSwapLayout", + CommandName::GoToTabName => "GoToTabName", + CommandName::FocusOrCreateTab => "FocusOrCreateTab", + CommandName::GoToTab => "GoToTab", + CommandName::StartOrReloadPlugin => "StartOrReloadPlugin", + CommandName::CloseTerminalPane => "CloseTerminalPane", + CommandName::ClosePluginPane => "ClosePluginPane", + CommandName::FocusTerminalPane => "FocusTerminalPane", + CommandName::FocusPluginPane => "FocusPluginPane", + CommandName::RenameTerminalPane => "RenameTerminalPane", + CommandName::RenamePluginPane => "RenamePluginPane", + CommandName::RenameTab => "RenameTab", + CommandName::ReportCrash => "ReportCrash", + CommandName::RequestPluginPermissions => "RequestPluginPermissions", + CommandName::SwitchSession => "SwitchSession", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Subscribe" => Some(Self::Subscribe), + "Unsubscribe" => Some(Self::Unsubscribe), + "SetSelectable" => Some(Self::SetSelectable), + "GetPluginIds" => Some(Self::GetPluginIds), + "GetZellijVersion" => Some(Self::GetZellijVersion), + "OpenFile" => Some(Self::OpenFile), + "OpenFileFloating" => Some(Self::OpenFileFloating), + "OpenTerminal" => Some(Self::OpenTerminal), + "OpenTerminalFloating" => Some(Self::OpenTerminalFloating), + "OpenCommandPane" => Some(Self::OpenCommandPane), + "OpenCommandPaneFloating" => Some(Self::OpenCommandPaneFloating), + "SwitchTabTo" => Some(Self::SwitchTabTo), + "SetTimeout" => Some(Self::SetTimeout), + "ExecCmd" => Some(Self::ExecCmd), + "PostMessageTo" => Some(Self::PostMessageTo), + "PostMessageToPlugin" => Some(Self::PostMessageToPlugin), + "HideSelf" => Some(Self::HideSelf), + "ShowSelf" => Some(Self::ShowSelf), + "SwitchToMode" => Some(Self::SwitchToMode), + "NewTabsWithLayout" => Some(Self::NewTabsWithLayout), + "NewTab" => Some(Self::NewTab), + "GoToNextTab" => Some(Self::GoToNextTab), + "GoToPreviousTab" => Some(Self::GoToPreviousTab), + "Resize" => Some(Self::Resize), + "ResizeWithDirection" => Some(Self::ResizeWithDirection), + "FocusNextPane" => Some(Self::FocusNextPane), + "FocusPreviousPane" => Some(Self::FocusPreviousPane), + "MoveFocus" => Some(Self::MoveFocus), + "MoveFocusOrTab" => Some(Self::MoveFocusOrTab), + "Detach" => Some(Self::Detach), + "EditScrollback" => Some(Self::EditScrollback), + "Write" => Some(Self::Write), + "WriteChars" => Some(Self::WriteChars), + "ToggleTab" => Some(Self::ToggleTab), + "MovePane" => Some(Self::MovePane), + "MovePaneWithDirection" => Some(Self::MovePaneWithDirection), + "ClearScreen" => Some(Self::ClearScreen), + "ScrollUp" => Some(Self::ScrollUp), + "ScrollDown" => Some(Self::ScrollDown), + "ScrollToTop" => Some(Self::ScrollToTop), + "ScrollToBottom" => Some(Self::ScrollToBottom), + "PageScrollUp" => Some(Self::PageScrollUp), + "PageScrollDown" => Some(Self::PageScrollDown), + "ToggleFocusFullscreen" => Some(Self::ToggleFocusFullscreen), + "TogglePaneFrames" => Some(Self::TogglePaneFrames), + "TogglePaneEmbedOrEject" => Some(Self::TogglePaneEmbedOrEject), + "UndoRenamePane" => Some(Self::UndoRenamePane), + "CloseFocus" => Some(Self::CloseFocus), + "ToggleActiveTabSync" => Some(Self::ToggleActiveTabSync), + "CloseFocusedTab" => Some(Self::CloseFocusedTab), + "UndoRenameTab" => Some(Self::UndoRenameTab), + "QuitZellij" => Some(Self::QuitZellij), + "PreviousSwapLayout" => Some(Self::PreviousSwapLayout), + "NextSwapLayout" => Some(Self::NextSwapLayout), + "GoToTabName" => Some(Self::GoToTabName), + "FocusOrCreateTab" => Some(Self::FocusOrCreateTab), + "GoToTab" => Some(Self::GoToTab), + "StartOrReloadPlugin" => Some(Self::StartOrReloadPlugin), + "CloseTerminalPane" => Some(Self::CloseTerminalPane), + "ClosePluginPane" => Some(Self::ClosePluginPane), + "FocusTerminalPane" => Some(Self::FocusTerminalPane), + "FocusPluginPane" => Some(Self::FocusPluginPane), + "RenameTerminalPane" => Some(Self::RenameTerminalPane), + "RenamePluginPane" => Some(Self::RenamePluginPane), + "RenameTab" => Some(Self::RenameTab), + "ReportCrash" => Some(Self::ReportCrash), + "RequestPluginPermissions" => Some(Self::RequestPluginPermissions), + "SwitchSession" => Some(Self::SwitchSession), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.plugin_ids.rs b/zellij-utils/assets/prost/api.plugin_ids.rs new file mode 100644 index 0000000000..647cc06cd0 --- /dev/null +++ b/zellij-utils/assets/prost/api.plugin_ids.rs @@ -0,0 +1,14 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PluginIds { + #[prost(int32, tag = "1")] + pub plugin_id: i32, + #[prost(int32, tag = "2")] + pub zellij_pid: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZellijVersion { + #[prost(string, tag = "1")] + pub version: ::prost::alloc::string::String, +} diff --git a/zellij-utils/assets/prost/api.plugin_permission.rs b/zellij-utils/assets/prost/api.plugin_permission.rs new file mode 100644 index 0000000000..dfe931f8ff --- /dev/null +++ b/zellij-utils/assets/prost/api.plugin_permission.rs @@ -0,0 +1,38 @@ +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum PermissionType { + ReadApplicationState = 0, + ChangeApplicationState = 1, + OpenFiles = 2, + RunCommands = 3, + OpenTerminalsOrPlugins = 4, + WriteToStdin = 5, +} +impl PermissionType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + PermissionType::ReadApplicationState => "ReadApplicationState", + PermissionType::ChangeApplicationState => "ChangeApplicationState", + PermissionType::OpenFiles => "OpenFiles", + PermissionType::RunCommands => "RunCommands", + PermissionType::OpenTerminalsOrPlugins => "OpenTerminalsOrPlugins", + PermissionType::WriteToStdin => "WriteToStdin", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ReadApplicationState" => Some(Self::ReadApplicationState), + "ChangeApplicationState" => Some(Self::ChangeApplicationState), + "OpenFiles" => Some(Self::OpenFiles), + "RunCommands" => Some(Self::RunCommands), + "OpenTerminalsOrPlugins" => Some(Self::OpenTerminalsOrPlugins), + "WriteToStdin" => Some(Self::WriteToStdin), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.resize.rs b/zellij-utils/assets/prost/api.resize.rs new file mode 100644 index 0000000000..22f012464d --- /dev/null +++ b/zellij-utils/assets/prost/api.resize.rs @@ -0,0 +1,72 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Resize { + #[prost(enumeration = "ResizeAction", tag = "1")] + pub resize_action: i32, + #[prost(enumeration = "ResizeDirection", optional, tag = "2")] + pub direction: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveDirection { + #[prost(enumeration = "ResizeDirection", tag = "1")] + pub direction: i32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ResizeAction { + Increase = 0, + Decrease = 1, +} +impl ResizeAction { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ResizeAction::Increase => "Increase", + ResizeAction::Decrease => "Decrease", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Increase" => Some(Self::Increase), + "Decrease" => Some(Self::Decrease), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ResizeDirection { + Left = 0, + Right = 1, + Up = 2, + Down = 3, +} +impl ResizeDirection { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ResizeDirection::Left => "Left", + ResizeDirection::Right => "Right", + ResizeDirection::Up => "Up", + ResizeDirection::Down => "Down", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Left" => Some(Self::Left), + "Right" => Some(Self::Right), + "Up" => Some(Self::Up), + "Down" => Some(Self::Down), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/api.style.rs b/zellij-utils/assets/prost/api.style.rs new file mode 100644 index 0000000000..cd768c3908 --- /dev/null +++ b/zellij-utils/assets/prost/api.style.rs @@ -0,0 +1,131 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Style { + #[prost(message, optional, tag = "1")] + pub palette: ::core::option::Option, + #[prost(bool, tag = "2")] + pub rounded_corners: bool, + #[prost(bool, tag = "3")] + pub hide_session_name: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Palette { + #[prost(enumeration = "ThemeHue", tag = "1")] + pub theme_hue: i32, + #[prost(message, optional, tag = "2")] + pub fg: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub bg: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub black: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub red: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub green: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub yellow: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub blue: ::core::option::Option, + #[prost(message, optional, tag = "9")] + pub magenta: ::core::option::Option, + #[prost(message, optional, tag = "10")] + pub cyan: ::core::option::Option, + #[prost(message, optional, tag = "11")] + pub white: ::core::option::Option, + #[prost(message, optional, tag = "12")] + pub orange: ::core::option::Option, + #[prost(message, optional, tag = "13")] + pub gray: ::core::option::Option, + #[prost(message, optional, tag = "14")] + pub purple: ::core::option::Option, + #[prost(message, optional, tag = "15")] + pub gold: ::core::option::Option, + #[prost(message, optional, tag = "16")] + pub silver: ::core::option::Option, + #[prost(message, optional, tag = "17")] + pub pink: ::core::option::Option, + #[prost(message, optional, tag = "18")] + pub brown: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Color { + #[prost(enumeration = "ColorType", tag = "1")] + pub color_type: i32, + #[prost(oneof = "color::Payload", tags = "2, 3")] + pub payload: ::core::option::Option, +} +/// Nested message and enum types in `Color`. +pub mod color { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Payload { + #[prost(message, tag = "2")] + RgbColorPayload(super::RgbColorPayload), + #[prost(uint32, tag = "3")] + EightBitColorPayload(u32), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RgbColorPayload { + #[prost(uint32, tag = "1")] + pub red: u32, + #[prost(uint32, tag = "2")] + pub green: u32, + #[prost(uint32, tag = "3")] + pub blue: u32, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ColorType { + Rgb = 0, + EightBit = 1, +} +impl ColorType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ColorType::Rgb => "Rgb", + ColorType::EightBit => "EightBit", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Rgb" => Some(Self::Rgb), + "EightBit" => Some(Self::EightBit), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum ThemeHue { + Dark = 0, + Light = 1, +} +impl ThemeHue { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ThemeHue::Dark => "Dark", + ThemeHue::Light => "Light", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "Dark" => Some(Self::Dark), + "Light" => Some(Self::Light), + _ => None, + } + } +} diff --git a/zellij-utils/assets/prost/generated_plugin_api.rs b/zellij-utils/assets/prost/generated_plugin_api.rs new file mode 100644 index 0000000000..a7e73f652d --- /dev/null +++ b/zellij-utils/assets/prost/generated_plugin_api.rs @@ -0,0 +1,38 @@ +pub mod api { + pub mod action { + include!("api.action.rs"); + } + pub mod command { + include!("api.command.rs"); + } + pub mod event { + include!("api.event.rs"); + } + pub mod file { + include!("api.file.rs"); + } + pub mod input_mode { + include!("api.input_mode.rs"); + } + pub mod key { + include!("api.key.rs"); + } + pub mod message { + include!("api.message.rs"); + } + pub mod plugin_command { + include!("api.plugin_command.rs"); + } + pub mod plugin_ids { + include!("api.plugin_ids.rs"); + } + pub mod plugin_permission { + include!("api.plugin_permission.rs"); + } + pub mod resize { + include!("api.resize.rs"); + } + pub mod style { + include!("api.style.rs"); + } +} diff --git a/zellij-utils/build.rs b/zellij-utils/build.rs index 92f89d27ca..9b07cfe86f 100644 --- a/zellij-utils/build.rs +++ b/zellij-utils/build.rs @@ -1,21 +1,33 @@ -use prost_build; -use std::fs; +// NOTE: This build script is currently out of order. +// Refer to [the PR introducing this change][1] to learn more about the reasons. +// TL;DR: The build script doesn't work during a `cargo publish --dry-run` and to ensure we can +// make a release, we decided to temporarily disable it. +// +// [1]: https://github.com/zellij-org/zellij/pull/2711#issuecomment-1695015818 + +//use prost_build; +//use std::fs; fn main() { - let mut prost_build = prost_build::Config::new(); - prost_build.include_file("generated_plugin_api.rs"); - let mut proto_files = vec![]; - for entry in fs::read_dir("src/plugin_api").unwrap() { - let entry_path = entry.unwrap().path(); - if entry_path.is_file() { - if let Some(extension) = entry_path.extension() { - if extension == "proto" { - proto_files.push(entry_path.display().to_string()) - } - } - } - } - prost_build - .compile_protos(&proto_files, &["src/plugin_api"]) - .unwrap(); + //let mut prost_build = prost_build::Config::new(); + //let out_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/prost"); + //let out_dir = std::path::Path::new(out_dir); + + //std::fs::create_dir_all(out_dir).unwrap(); + //prost_build.out_dir(out_dir); + //prost_build.include_file("generated_plugin_api.rs"); + //let mut proto_files = vec![]; + //for entry in fs::read_dir("src/plugin_api").unwrap() { + // let entry_path = entry.unwrap().path(); + // if entry_path.is_file() { + // if let Some(extension) = entry_path.extension() { + // if extension == "proto" { + // proto_files.push(entry_path.display().to_string()) + // } + // } + // } + //} + //prost_build + // .compile_protos(&proto_files, &["src/plugin_api"]) + // .unwrap(); } diff --git a/zellij-utils/src/plugin_api/mod.rs b/zellij-utils/src/plugin_api/mod.rs index 4812d468c0..40057fde02 100644 --- a/zellij-utils/src/plugin_api/mod.rs +++ b/zellij-utils/src/plugin_api/mod.rs @@ -10,6 +10,20 @@ pub mod plugin_ids; pub mod plugin_permission; pub mod resize; pub mod style; +// NOTE: This code is currently out of order. +// Refer to [the PR introducing this change][1] to learn more about the reasons. +// TL;DR: When running `cargo release --dry-run` the build-script in zellij-utils is not executed +// for unknown reasons, causing compilation to fail. To make a new release possible in the +// meantime, we decided to temporarily include the protobuf plugin API definitions +// statically. +// +// [1]: https://github.com/zellij-org/zellij/pull/2711#issuecomment-1695015818 +//pub mod generated_api { +// include!(concat!(env!("OUT_DIR"), "/generated_plugin_api.rs")); +//} pub mod generated_api { - include!(concat!(env!("OUT_DIR"), "/generated_plugin_api.rs")); + include!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/assets/prost/generated_plugin_api.rs" + )); }