diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-06-03 17:15:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-03 17:15:32 +0200 |
| commit | a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d (patch) | |
| tree | 6d354fdd36cf534d73e0cb81a7cacd3fedc1ebb9 /zellij-tile | |
| parent | docs(changelog): theme fixes (diff) | |
| download | sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.gz sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.xz sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.zip | |
feat(ux): improve multiple select (#4221)
* intercept/clear-intercept key APIs
* allow opening a pinned unfocused floating pane
* rework plugin
* improve some apis
* fix tests
* tests for pane groups
* more exact placement and tests
* plugin command permission and cleanup
* improve some multiselect ux
* improve plugin ui
* remove old status indicator
* allow moving plugin out of the way
* style(fmt): rustfmt
* update plugins
* remove old keybinding
* cleanups
* fix: only rename pane if needed
* changelog and some cleanups
* style(fmt): rustfmt
Diffstat (limited to 'zellij-tile')
| -rw-r--r-- | zellij-tile/src/shim.rs | 14 | ||||
| -rw-r--r-- | zellij-tile/src/ui_components/text.rs | 38 |
2 files changed, 52 insertions, 0 deletions
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs index db6ea180..d67768f1 100644 --- a/zellij-tile/src/shim.rs +++ b/zellij-tile/src/shim.rs @@ -1313,6 +1313,20 @@ pub fn embed_multiple_panes(pane_ids: Vec<PaneId>) { unsafe { host_run_plugin_command() }; } +pub fn intercept_key_presses() { + let plugin_command = PluginCommand::InterceptKeyPresses; + let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap(); + object_to_stdout(&protobuf_plugin_command.encode_to_vec()); + unsafe { host_run_plugin_command() }; +} + +pub fn clear_key_presses_intercepts() { + let plugin_command = PluginCommand::ClearKeyPressesIntercepts; + let protobuf_plugin_command: ProtobufPluginCommand = plugin_command.try_into().unwrap(); + object_to_stdout(&protobuf_plugin_command.encode_to_vec()); + unsafe { host_run_plugin_command() }; +} + // Utility Functions #[allow(unused)] diff --git a/zellij-tile/src/ui_components/text.rs b/zellij-tile/src/ui_components/text.rs index 228b8975..787125b5 100644 --- a/zellij-tile/src/ui_components/text.rs +++ b/zellij-tile/src/ui_components/text.rs @@ -54,6 +54,44 @@ impl Text { .map(|i| i.append(&mut indices.into_iter().collect())); self } + pub fn color_substring<S: AsRef<str>>(mut self, index_level: usize, substr: S) -> Self { + let substr = substr.as_ref(); + let mut start = 0; + + while let Some(pos) = self.text[start..].find(substr) { + let abs_pos = start + pos; + self = self.color_range(index_level, abs_pos..abs_pos + substr.len()); + start = abs_pos + substr.len(); + } + + self + } + + pub fn color_all(self, index_level: usize) -> Self { + self.color_range(index_level, ..) + } + + pub fn color_nth_substring<S: AsRef<str>>( + self, + index_level: usize, + substr: S, + occurrence_index: usize, + ) -> Self { + let substr = substr.as_ref(); + let mut start = 0; + let mut count = 0; + + while let Some(pos) = self.text[start..].find(substr) { + if count == occurrence_index { + let abs_pos = start + pos; + return self.color_range(index_level, abs_pos..abs_pos + substr.len()); + } + count += 1; + start = start + pos + substr.len(); + } + + self + } fn pad_indices(&mut self, index_level: usize) { if self.indices.get(index_level).is_none() { for _ in self.indices.len()..=index_level { |
