diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-03-10 10:18:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-10 10:18:44 +0100 |
| commit | 2035e052f38a738639840a685ddc6a107ea11136 (patch) | |
| tree | 45f901bd2f670ec4e865e9e6570ca1fa6a67c8a0 /zellij-utils/src | |
| parent | allow specifying ip/port with the zellij web --status cli (#4825) (diff) | |
| download | sl0ppij-2035e052f38a738639840a685ddc6a107ea11136.tar.gz sl0ppij-2035e052f38a738639840a685ddc6a107ea11136.tar.xz sl0ppij-2035e052f38a738639840a685ddc6a107ea11136.zip | |
Highlight priority levels (#4827)
* highlight priority levels
* add pr
Diffstat (limited to 'zellij-utils/src')
| -rw-r--r-- | zellij-utils/src/data.rs | 18 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.proto | 7 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/plugin_command.rs | 36 |
3 files changed, 53 insertions, 8 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 70435bac..724f0abf 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -1203,6 +1203,23 @@ impl Default for PaletteColor { } } +/// Priority layer for plugin-supplied regex highlights. +/// Higher-priority layers take visual precedence over lower ones +/// when highlights overlap. Built-in highlights (mouse selection, +/// search results) always take precedence over all plugin layers. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub enum HighlightLayer { + Hint, // lowest: pure pattern matching (paths, URLs, IPs) + Tool, // middle: backed by runtime domain knowledge (git, docker, k8s) + ActionFeedback, // highest: result of an explicit user action (search, bookmarks) +} + +impl Default for HighlightLayer { + fn default() -> Self { + HighlightLayer::Hint + } +} + /// Style for a plugin-supplied regex highlight. /// Theme-based variants reference `style.colors.text_unselected.*`. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -1231,6 +1248,7 @@ pub enum HighlightStyle { pub struct RegexHighlight { pub pattern: String, // key for upsert; also the regex source pub style: HighlightStyle, + pub layer: HighlightLayer, pub context: BTreeMap<String, String>, // arbitrary data echoed back verbatim on click pub on_hover: bool, // if true, only rendered when the cursor overlaps this match pub bold: bool, diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto index 89836c90..0634d63e 100644 --- a/zellij-utils/src/plugin_api/plugin_command.proto +++ b/zellij-utils/src/plugin_api/plugin_command.proto @@ -1255,6 +1255,12 @@ message CustomIndexHighlight { optional uint32 bg = 2; } +enum HighlightLayer { + Hint = 0; + Tool = 1; + ActionFeedback = 2; +} + message RegexHighlight { string pattern = 1; HighlightStyle style = 2; @@ -1264,6 +1270,7 @@ message RegexHighlight { bool italic = 6; bool underline = 7; optional string tooltip_text = 8; + HighlightLayer layer = 9; } message SetPaneRegexHighlightsPayload { diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs index 2ce11c99..00acb760 100644 --- a/zellij-utils/src/plugin_api/plugin_command.rs +++ b/zellij-utils/src/plugin_api/plugin_command.rs @@ -51,11 +51,11 @@ pub use super::generated_api::api::{ GetTabInfoPayload, GetTabInfoResponse as ProtobufGetTabInfoResponse, GoToTabWithIdPayload, GroupAndUngroupPanesPayload, HideFloatingPanesPayload as ProtobufHideFloatingPanesPayload, HideFloatingPanesResponse as ProtobufHideFloatingPanesResponse, HidePaneWithIdPayload, - HighlightAndUnhighlightPanesPayload, HighlightStyle as ProtobufHighlightStyle, - HttpVerb as ProtobufHttpVerb, IdAndNewName, KeyToRebind, KeyToUnbind, KillSessionsPayload, - ListTokensResponse, LoadNewPluginPayload, MessageToPluginPayload, - MovePaneWithPaneIdInDirectionPayload, MovePaneWithPaneIdPayload, MovePayload, - NewPluginArgs as ProtobufNewPluginArgs, NewTabPayload, + HighlightAndUnhighlightPanesPayload, HighlightLayer as ProtobufHighlightLayer, + HighlightStyle as ProtobufHighlightStyle, HttpVerb as ProtobufHttpVerb, IdAndNewName, + KeyToRebind, KeyToUnbind, KillSessionsPayload, ListTokensResponse, LoadNewPluginPayload, + MessageToPluginPayload, MovePaneWithPaneIdInDirectionPayload, MovePaneWithPaneIdPayload, + MovePayload, NewPluginArgs as ProtobufNewPluginArgs, NewTabPayload, NewTabResponse as ProtobufNewTabResponse, NewTabsResponse as ProtobufNewTabsResponse, NewTabsWithLayoutInfoPayload, OpenCommandPaneBackgroundResponse as ProtobufOpenCommandPaneBackgroundResponse, @@ -122,9 +122,9 @@ pub use super::generated_api::api::{ use crate::data::{ ConnectToSession, DeleteLayoutResponse, EditLayoutResponse, FloatingPaneCoordinates, GetFocusedPaneInfoResponse, GetPaneCwdResponse, GetPanePidResponse, - GetPaneRunningCommandResponse, HighlightStyle, HttpVerb, InputMode, KeyWithModifier, - MessageToPlugin, NewPluginArgs, PaneId, PermissionType, PluginCommand, RegexHighlight, - RenameLayoutResponse, SaveLayoutResponse, + GetPaneRunningCommandResponse, HighlightLayer, HighlightStyle, HttpVerb, InputMode, + KeyWithModifier, MessageToPlugin, NewPluginArgs, PaneId, PermissionType, PluginCommand, + RegexHighlight, RenameLayoutResponse, SaveLayoutResponse, }; use crate::input::actions::Action; use crate::input::layout::PercentOrFixed; @@ -2510,6 +2510,15 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand { RegexHighlight { pattern: h.pattern, style, + layer: match h.layer { + x if x == ProtobufHighlightLayer::Tool as i32 => { + HighlightLayer::Tool + }, + x if x == ProtobufHighlightLayer::ActionFeedback as i32 => { + HighlightLayer::ActionFeedback + }, + _ => HighlightLayer::Hint, // 0 or unknown => Hint + }, context, on_hover: h.on_hover, bold: h.bold, @@ -4167,6 +4176,17 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand { italic: h.italic, underline: h.underline, tooltip_text: h.tooltip_text, + layer: match h.layer { + HighlightLayer::Hint => { + ProtobufHighlightLayer::Hint as i32 + }, + HighlightLayer::Tool => { + ProtobufHighlightLayer::Tool as i32 + }, + HighlightLayer::ActionFeedback => { + ProtobufHighlightLayer::ActionFeedback as i32 + }, + }, } }) .collect(), |
