mirror of
https://github.com/zellij-org/zellij.git
synced 2026-10-11 22:50:07 +00:00
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
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user