summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--default-plugins/compact-bar/src/line.rs71
-rw-r--r--default-plugins/status-bar/src/first_line.rs99
-rw-r--r--default-plugins/status-bar/src/main.rs41
-rw-r--r--default-plugins/status-bar/src/tip/data/compact_layout.rs6
-rw-r--r--default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs6
-rw-r--r--default-plugins/status-bar/src/tip/data/sync_tab.rs6
-rw-r--r--zellij-server/src/lib.rs15
-rw-r--r--zellij-server/src/os_input_output.rs8
-rw-r--r--zellij-server/src/panes/floating_panes/floating_pane_grid.rs4
-rw-r--r--zellij-server/src/panes/floating_panes/mod.rs19
-rw-r--r--zellij-server/src/panes/plugin_pane.rs6
-rw-r--r--zellij-server/src/panes/terminal_pane.rs6
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs134
-rw-r--r--zellij-server/src/panes/tiled_panes/pane_resizer.rs33
-rw-r--r--zellij-server/src/panes/tiled_panes/stacked_panes.rs397
-rw-r--r--zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs114
-rw-r--r--zellij-server/src/plugins/mod.rs8
-rw-r--r--zellij-server/src/pty.rs2
-rw-r--r--zellij-server/src/route.rs18
-rw-r--r--zellij-server/src/screen.rs21
-rw-r--r--zellij-server/src/tab/layout_applier.rs184
-rw-r--r--zellij-server/src/tab/mod.rs132
-rw-r--r--zellij-server/src/tab/swap_layouts.rs166
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs959
-rw-r--r--zellij-server/src/tab/unit/tab_tests.rs2
-rw-r--r--zellij-server/src/thread_bus.rs5
-rw-r--r--zellij-server/src/ui/pane_boundaries_frame.rs13
-rw-r--r--zellij-server/src/unit/screen_tests.rs6
-rw-r--r--zellij-utils/src/cli.rs36
-rw-r--r--zellij-utils/src/input/actions.rs36
-rw-r--r--zellij-utils/src/input/layout.rs105
-rw-r--r--zellij-utils/src/input/unit/layout_test.rs416
-rw-r--r--zellij-utils/src/kdl/kdl_layout_parser.rs277
-rw-r--r--zellij-utils/src/kdl/mod.rs41
34 files changed, 2529 insertions, 863 deletions
diff --git a/default-plugins/compact-bar/src/line.rs b/default-plugins/compact-bar/src/line.rs
index c51ae4748..13394a092 100644
--- a/default-plugins/compact-bar/src/line.rs
+++ b/default-plugins/compact-bar/src/line.rs
@@ -289,7 +289,14 @@ pub fn tab_line(
let current_title_len = get_current_title_len(&prefix);
if current_title_len < cols {
let mut remaining_space = cols - current_title_len;
- if let Some(swap_layout_status) = swap_layout_status(remaining_space, active_swap_layout_name, is_swap_layout_dirty, mode, &palette, tab_separator(capabilities)) {
+ if let Some(swap_layout_status) = swap_layout_status(
+ remaining_space,
+ active_swap_layout_name,
+ is_swap_layout_dirty,
+ mode,
+ &palette,
+ tab_separator(capabilities),
+ ) {
remaining_space -= swap_layout_status.len;
let mut buffer = String::new();
for _ in 0..remaining_space {
@@ -307,37 +314,51 @@ pub fn tab_line(
prefix
}
-fn swap_layout_status(max_len: usize, swap_layout_name: &Option<String>, is_swap_layout_damaged: bool, input_mode: InputMode, palette: &Palette, separator: &str) -> Option<LinePart> {
+fn swap_layout_status(
+ max_len: usize,
+ swap_layout_name: &Option<String>,
+ is_swap_layout_damaged: bool,
+ input_mode: InputMode,
+ palette: &Palette,
+ separator: &str,
+) -> Option<LinePart> {
match swap_layout_name {
Some(swap_layout_name) => {
let mut swap_layout_name = format!(" {} ", swap_layout_name);
swap_layout_name.make_ascii_uppercase();
let swap_layout_name_len = swap_layout_name.len() + 3;
- let (prefix_separator, swap_layout_name, suffix_separator) = if input_mode == InputMode::Locked {
- (
- style!(palette.black, palette.fg).paint(separator),
- style!(palette.black, palette.fg).italic().paint(&swap_layout_name),
- style!(palette.fg, palette.black).paint(separator),
- )
- } else if is_swap_layout_damaged {
- (
- style!(palette.black, palette.fg).paint(separator),
- style!(palette.black, palette.fg).bold().paint(&swap_layout_name),
- style!(palette.fg, palette.black).paint(separator),
- )
- } else {
- (
- style!(palette.black, palette.green).paint(separator),
- style!(palette.black, palette.green).bold().paint(&swap_layout_name),
- style!(palette.green, palette.black).paint(separator),
- )
- };
- let swap_layout_indicator = format!("{}{}{}", prefix_separator, swap_layout_name, suffix_separator);
- let (part, full_len) = (
- format!("{}", swap_layout_indicator),
- swap_layout_name_len,
+ let (prefix_separator, swap_layout_name, suffix_separator) =
+ if input_mode == InputMode::Locked {
+ (
+ style!(palette.black, palette.fg).paint(separator),
+ style!(palette.black, palette.fg)
+ .italic()
+ .paint(&swap_layout_name),
+ style!(palette.fg, palette.black).paint(separator),
+ )
+ } else if is_swap_layout_damaged {
+ (
+ style!(palette.black, palette.fg).paint(separator),
+ style!(palette.black, palette.fg)
+ .bold()
+ .paint(&swap_layout_name),
+ style!(palette.fg, palette.black).paint(separator),
+ )
+ } else {
+ (
+ style!(palette.black, palette.green).paint(separator),
+ style!(palette.black, palette.green)
+ .bold()
+ .paint(&swap_layout_name),
+ style!(palette.green, palette.black).paint(separator),
+ )
+ };
+ let swap_layout_indicator = format!(
+ "{}{}{}",
+ prefix_separator, swap_layout_name, suffix_separator
);
+ let (part, full_len) = (format!("{}", swap_layout_indicator), swap_layout_name_len);
let short_len = swap_layout_name_len + 1; // 1 is the space between
if full_len <= max_len {
Some(LinePart {
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs
index ab669d013..23a6d5869 100644
--- a/default-plugins/status-bar/src/first_line.rs
+++ b/default-plugins/status-bar/src/first_line.rs
@@ -1,12 +1,11 @@
-use ansi_term::{
- unstyled_len,
- ANSIStrings,
-};
+use ansi_term::{unstyled_len, ANSIStrings};
use zellij_tile::prelude::actions::Action;
use zellij_tile::prelude::*;
use crate::color_elements;
-use crate::{action_key, action_key_group, get_common_modifier, style_key_with_modifier, TO_NORMAL};
+use crate::{
+ action_key, action_key_group, get_common_modifier, style_key_with_modifier, TO_NORMAL,
+};
use crate::{ColoredElements, LinePart};
struct KeyShortcut {
@@ -237,18 +236,27 @@ fn key_indicators(
fn swap_layout_keycode(mode_info: &ModeInfo, palette: &Palette) -> LinePart {
let mode_keybinds = mode_info.get_mode_keybinds();
- let prev_next_keys = action_key_group(&mode_keybinds, &[&[Action::PreviousSwapLayout], &[Action::NextSwapLayout]]);
- let prev_next_keys_indicator = style_key_with_modifier(&prev_next_keys, palette, Some(palette.black));
+ let prev_next_keys = action_key_group(
+ &mode_keybinds,
+ &[&[Action::PreviousSwapLayout], &[Action::NextSwapLayout]],
+ );
+ let prev_next_keys_indicator =
+ style_key_with_modifier(&prev_next_keys, palette, Some(palette.black));
let keycode = ANSIStrings(&prev_next_keys_indicator);
let len = unstyled_len(&keycode);
let part = keycode.to_string();
- LinePart {
- part,
- len
- }
+ LinePart { part, len }
}
-fn swap_layout_status(max_len: usize, swap_layout_name: &Option<String>, is_swap_layout_damaged: bool, mode_info: &ModeInfo, colored_elements: ColoredElements, palette: &Palette, separator: &str) -> Option<LinePart> {
+fn swap_layout_status(
+ max_len: usize,
+ swap_layout_name: &Option<String>,
+ is_swap_layout_damaged: bool,
+ mode_info: &ModeInfo,
+ colored_elements: ColoredElements,
+ palette: &Palette,
+ separator: &str,
+) -> Option<LinePart> {
match swap_layout_name {
Some(swap_layout_name) => {
let mut swap_layout_name = format!(" {} ", swap_layout_name);
@@ -259,20 +267,33 @@ fn swap_layout_status(max_len: usize, swap_layout_name: &Option<String>, is_swap
macro_rules! style_swap_layout_indicator {
($style_name:ident) => {{
(
- colored_elements.$style_name.prefix_separator.paint(separator),
- colored_elements.$style_name.styled_text.paint(&swap_layout_name),
- colored_elements.$style_name.suffix_separator.paint(separator)
+ colored_elements
+ .$style_name
+ .prefix_separator
+ .paint(separator),
+ colored_elements
+ .$style_name
+ .styled_text
+ .paint(&swap_layout_name),
+ colored_elements
+ .$style_name
+ .suffix_separator
+ .paint(separator),
)
}};
}
- let (prefix_separator, swap_layout_name, suffix_separator) = if mode_info.mode == InputMode::Locked {
- style_swap_layout_indicator!(disabled)
- } else if is_swap_layout_damaged {
- style_swap_layout_indicator!(unselected)
- } else {
- style_swap_layout_indicator!(selected)
- };
- let swap_layout_indicator = format!("{}{}{}", prefix_separator, swap_layout_name, suffix_separator);
+ let (prefix_separator, swap_layout_name, suffix_separator) =
+ if mode_info.mode == InputMode::Locked {
+ style_swap_layout_indicator!(disabled)
+ } else if is_swap_layout_damaged {
+ style_swap_layout_indicator!(unselected)
+ } else {
+ style_swap_layout_indicator!(selected)
+ };
+ let swap_layout_indicator = format!(
+ "{}{}{}",
+ prefix_separator, swap_layout_name, suffix_separator
+ );
let (part, full_len) = if mode_info.mode == InputMode::Locked {
(
format!("{}", swap_layout_indicator),
@@ -280,7 +301,13 @@ fn swap_layout_status(max_len: usize, swap_layout_name: &Option<String>, is_swap
)
} else {
(
- format!("{}{}{}{}", keycode, colored_elements.superkey_prefix.paint(" "), swap_layout_indicator, colored_elements.superkey_prefix.paint(" ")),
+ format!(
+ "{}{}{}{}",
+ keycode,
+ colored_elements.superkey_prefix.paint(" "),
+ swap_layout_indicator,
+ colored_elements.superkey_prefix.paint(" ")
+ ),
keycode.len + swap_layout_name_len + 1, // 1 is the space between
)
};
@@ -422,7 +449,12 @@ fn get_key_shortcut_for_mode<'a>(
None
}
-pub fn first_line(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usize, separator: &str) -> LinePart {
+pub fn first_line(
+ help: &ModeInfo,
+ tab_info: Option<&TabInfo>,
+ max_len: usize,
+ separator: &str,
+) -> LinePart {
let supports_arrow_fonts = !help.capabilities.arrow_fonts;
let colored_elements = color_elements(help.style.colors, !supports_arrow_fonts);
let binds = &help.get_mode_keybinds();
@@ -503,14 +535,25 @@ pub fn first_line(help: &ModeInfo, tab_info: Option<&TabInfo>, max_len: usize, s
));
}
- let mut key_indicators = key_indicators(max_len, &default_keys, colored_elements, separator, help);
+ let mut key_indicators =
+ key_indicators(max_len, &default_keys, colored_elements, separator, help);
if key_indicators.len < max_len {
if let Some(tab_info) = tab_info {
let mut remaining_space = max_len - key_indicators.len;
- if let Some(swap_layout_status) = swap_layout_status(remaining_space, &tab_info.active_swap_layout_name, tab_info.is_swap_layout_dirty, help, colored_elements, &help.style.colors, separator) {
+ if let Some(swap_layout_status) = swap_layout_status(
+ remaining_space,
+ &tab_info.active_swap_layout_name,
+ tab_info.is_swap_layout_dirty,
+ help,
+ colored_elements,
+ &help.style.colors,
+ separator,
+ ) {
remaining_space -= swap_layout_status.len;
for _ in 0..remaining_space {
- key_indicators.part.push_str(&ANSIStrings(&[colored_elements.superkey_prefix.paint(" ")]).to_string());
+ key_indicators.part.push_str(
+ &ANSIStrings(&[colored_elements.superkey_prefix.paint(" ")]).to_string(),
+ );
key_indicators.len += 1;
}
key_indicators.append(&swap_layout_status);
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs
index 8e7414e87..172d9751a 100644
--- a/default-plugins/status-bar/src/main.rs
+++ b/default-plugins/status-bar/src/main.rs
@@ -382,7 +382,11 @@ pub fn action_key_group(keymap: &[(Key, Vec<Action>)], actions: &[&[Action]]) ->
///
/// The returned Vector of [`ANSIString`] is suitable for transformation into an [`ANSIStrings`]
/// type.
-pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette, background: Option<PaletteColor>) -> Vec<ANSIString<'static>> {
+pub fn style_key_with_modifier(
+ keyvec: &[Key],
+ palette: &Palette,
+ background: Option<PaletteColor>,
+) -> Vec<ANSIString<'static>> {
// Nothing to do, quit...
if keyvec.is_empty() {
return vec![];
@@ -407,7 +411,11 @@ pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette, background: Op
} else {
if let Some(background) = background {
let background = palette_match!(background);
- Style::new().fg(orange_color).on(background).bold().paint(modifier_str)
+ Style::new()
+ .fg(orange_color)
+ .on(background)
+ .bold()
+ .paint(modifier_str)
} else {
Style::new().fg(orange_color).bold().paint(modifier_str)
}
@@ -418,7 +426,12 @@ pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette, background: Op
let group_start_str = if no_modifier { "<" } else { " + <" };
if let Some(background) = background {
let background = palette_match!(background);
- ret.push(Style::new().fg(text_color).on(background).paint(group_start_str));
+ ret.push(
+ Style::new()
+ .fg(text_color)
+ .on(background)
+ .paint(group_start_str),
+ );
} else {
ret.push(Style::new().fg(text_color).paint(group_start_str));
}
@@ -455,14 +468,25 @@ pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette, background: Op
if idx > 0 && !key_separator.is_empty() {
if let Some(background) = background {
let background = palette_match!(background);
- ret.push(Style::new().fg(text_color).on(background).paint(key_separator));
+ ret.push(
+ Style::new()
+ .fg(text_color)
+ .on(background)
+ .paint(key_separator),
+ );
} else {
ret.push(Style::new().fg(text_color).paint(key_separator));
}
}
if let Some(background) = background {
let background = palette_match!(background);
- ret.push(Style::new().fg(green_color).on(background).bold().paint(key.clone()));
+ ret.push(
+ Style::new()
+ .fg(green_color)
+ .on(background)
+ .bold()
+ .paint(key.clone()),
+ );
} else {
ret.push(Style::new().fg(green_color).bold().paint(key.clone()));
}
@@ -471,7 +495,12 @@ pub fn style_key_with_modifier(keyvec: &[Key], palette: &Palette, background: Op
let group_end_str = ">";
if let Some(background) = background {
let background = palette_match!(background);
- ret.push(Style::new().fg(text_color).on(background).paint(group_end_str));
+ ret.push(
+ Style::new()
+ .fg(text_color)
+ .on(background)
+ .paint(group_end_str),
+ );
} else {
ret.push(Style::new().fg(text_color).paint(group_end_str));
}
diff --git a/default-plugins/status-bar/src/tip/data/compact_layout.rs b/default-plugins/status-bar/src/tip/data/compact_layout.rs
index df557bd5f..77dec8a60 100644
--- a/default-plugins/status-bar/src/tip/data/compact_layout.rs
+++ b/default-plugins/status-bar/src/tip/data/compact_layout.rs
@@ -95,6 +95,10 @@ fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
let mut bits = vec![];
bits.extend(style_key_with_modifier(&to_pane, &help.style.colors, None));
bits.push(Style::new().paint(", "));
- bits.extend(style_key_with_modifier(&pane_frames, &help.style.colors, None));
+ bits.extend(style_key_with_modifier(
+ &pane_frames,
+ &help.style.colors,
+ None,
+ ));
bits
}
diff --git a/default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs b/default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs
index ae883be92..ebd944b77 100644
--- a/default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs
+++ b/default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs
@@ -85,6 +85,10 @@ fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
let mut bits = vec![];
bits.extend(style_key_with_modifier(&to_pane, &help.style.colors, None));
bits.push(Style::new().paint(", "));
- bits.extend(style_key_with_modifier(&edit_buffer, &help.style.colors, None));
+ bits.extend(style_key_with_modifier(
+ &edit_buffer,
+ &help.style.colors,
+ None,
+ ));
bits
}
diff --git a/default-plugins/status-bar/src/tip/data/sync_tab.rs b/default-plugins/status-bar/src/tip/data/sync_tab.rs
index 4d4f38a75..486e2aa24 100644
--- a/default-plugins/status-bar/src/tip/data/sync_tab.rs
+++ b/default-plugins/status-bar/src/tip/data/sync_tab.rs
@@ -63,6 +63,10 @@ fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
let mut bits = vec![];
bits.extend(style_key_with_modifier(&to_tab, &help.style.colors, None));
bits.push(Style::new().paint(", "));
- bits.extend(style_key_with_modifier(&sync_tabs, &help.style.colors, None));
+ bits.extend(style_key_with_modifier(
+ &am