Skip to content

Commit

Permalink
refactor: revert tip changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devzbysiu committed Jan 24, 2024
1 parent f05fdbb commit d8c9946
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 68 deletions.
28 changes: 22 additions & 6 deletions default-plugins/status-bar/src/tip/data/compact_layout.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
use ansi_term::Color::{Fixed, RGB};
use ansi_term::{ANSIString, Style};
use ansi_term::{
unstyled_len, ANSIString, ANSIStrings,
Color::{Fixed, RGB},
Style,
};

use crate::LinePart;
use crate::{action_key, style_key_with_modifier};
use crate::{ansi_strings, LinePart};
use zellij_tile::prelude::{actions::Action, *};
use zellij_tile_utils::palette_match;

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn compact_layout_full(help: &ModeInfo) -> LinePart {
// Tip: UI taking up too much space? Start Zellij with
// zellij -l compact or remove pane frames with Ctrl + <p> + <z>
Expand All @@ -21,7 +37,7 @@ pub fn compact_layout_full(help: &ModeInfo) -> LinePart {
Style::new().paint(" or remove pane frames with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn compact_layout_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -39,7 +55,7 @@ pub fn compact_layout_medium(help: &ModeInfo) -> LinePart {
Style::new().paint(" or remove frames with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn compact_layout_short(help: &ModeInfo) -> LinePart {
Expand All @@ -56,7 +72,7 @@ pub fn compact_layout_short(help: &ModeInfo) -> LinePart {
Style::new().paint(" or remove frames with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
Expand Down
28 changes: 22 additions & 6 deletions default-plugins/status-bar/src/tip/data/edit_scrollbuffer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
use ansi_term::Color::{Fixed, RGB};
use ansi_term::{ANSIString, Style};
use ansi_term::{
unstyled_len, ANSIString, ANSIStrings,
Color::{Fixed, RGB},
Style,
};

use crate::{action_key, ansi_strings, style_key_with_modifier, LinePart};
use crate::{action_key, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{actions::Action, *};
use zellij_tile_utils::palette_match;

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn edit_scrollbuffer_full(help: &ModeInfo) -> LinePart {
// Tip: Search through the scrollbuffer using your default $EDITOR with
// Ctrl + <s> + <e>
Expand All @@ -17,7 +33,7 @@ pub fn edit_scrollbuffer_full(help: &ModeInfo) -> LinePart {
Style::new().paint(" with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn edit_scrollbuffer_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -32,7 +48,7 @@ pub fn edit_scrollbuffer_medium(help: &ModeInfo) -> LinePart {
Style::new().paint(" with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn edit_scrollbuffer_short(help: &ModeInfo) -> LinePart {
Expand All @@ -46,7 +62,7 @@ pub fn edit_scrollbuffer_short(help: &ModeInfo) -> LinePart {
Style::new().paint(" with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
Expand Down
23 changes: 18 additions & 5 deletions default-plugins/status-bar/src/tip/data/floating_panes_mouse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
use ansi_term::{ANSIString, Style};
use ansi_term::{unstyled_len, ANSIString, ANSIStrings, Style};

use crate::{action_key, ansi_strings, style_key_with_modifier, LinePart};
use crate::{action_key, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{actions::Action, *};

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn floating_panes_mouse_full(help: &ModeInfo) -> LinePart {
// Tip: Toggle floating panes with Ctrl + <p> + <w> and move them with keyboard or mouse
let mut bits = vec![
Expand All @@ -11,7 +24,7 @@ pub fn floating_panes_mouse_full(help: &ModeInfo) -> LinePart {
];
bits.extend(add_keybinds(help));
bits.push(Style::new().paint(" and move them with keyboard or mouse"));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn floating_panes_mouse_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -21,14 +34,14 @@ pub fn floating_panes_mouse_medium(help: &ModeInfo) -> LinePart {
Style::new().paint("Toggle floating panes with "),
];
bits.extend(add_keybinds(help));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn floating_panes_mouse_short(help: &ModeInfo) -> LinePart {
// Ctrl + <p> + <w> => floating panes
let mut bits = add_keybinds(help);
bits.push(Style::new().paint(" => floating panes"));
ansi_strings!(&bits)
strings!(&bits)
}

fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
Expand Down
12 changes: 0 additions & 12 deletions default-plugins/status-bar/src/tip/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,3 @@ lazy_static! {
)
]);
}

#[macro_export]
macro_rules! ansi_strings {
($ANSIStrings:expr) => {{
let strings: &[::ansi_term::ANSIString] = $ANSIStrings;
let ansi_strings = ::ansi_term::ANSIStrings(strings);
LinePart {
part: format!("{}", ansi_strings),
len: ::ansi_term::unstyled_len(&ansi_strings),
}
}};
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
use ansi_term::{ANSIString, Style};
use ansi_term::{unstyled_len, ANSIString, ANSIStrings, Style};

use crate::{action_key_group, ansi_strings, style_key_with_modifier, LinePart};
use crate::{action_key_group, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{actions::Action, *};

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn move_focus_hjkl_tab_switch_full(help: &ModeInfo) -> LinePart {
// Tip: When changing focus with Alt + <←↓↑→> moving off screen left/right focuses the next tab.
let mut bits = vec![
Expand All @@ -11,7 +24,7 @@ pub fn move_focus_hjkl_tab_switch_full(help: &ModeInfo) -> LinePart {
];
bits.extend(add_keybinds(help));
bits.push(Style::new().paint(" moving off screen left/right focuses the next tab."));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn move_focus_hjkl_tab_switch_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -22,14 +35,14 @@ pub fn move_focus_hjkl_tab_switch_medium(help: &ModeInfo) -> LinePart {
];
bits.extend(add_keybinds(help));
bits.push(Style::new().paint(" off screen focuses the next tab."));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn move_focus_hjkl_tab_switch_short(help: &ModeInfo) -> LinePart {
// Alt + <←↓↑→> off screen edge focuses next tab.
let mut bits = add_keybinds(help);
bits.push(Style::new().paint(" off screen edge focuses next tab."));
ansi_strings!(&bits)
strings!(&bits)
}

fn add_keybinds(help: &ModeInfo) -> Vec<ANSIString> {
Expand Down
28 changes: 22 additions & 6 deletions default-plugins/status-bar/src/tip/data/move_tabs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
use ansi_term::Color::{Fixed, RGB};
use ansi_term::Style;
use ansi_term::{
unstyled_len, ANSIString, ANSIStrings,
Color::{Fixed, RGB},
Style,
};

use zellij_tile::prelude::*;
use zellij_tile_utils::palette_match;

use crate::{ansi_strings, LinePart};
use crate::LinePart;

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn move_tabs_full(help: &ModeInfo) -> LinePart {
// Tip: Wrong order of tabs? You can move them to left and right with:
Expand All @@ -19,7 +35,7 @@ pub fn move_tabs_full(help: &ModeInfo) -> LinePart {
Style::new().fg(green_color).bold().paint("Alt + o"),
Style::new().paint(" (right)"),
];
ansi_strings!(&bits)
strings!(&bits)
}

pub fn move_tabs_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -35,7 +51,7 @@ pub fn move_tabs_medium(help: &ModeInfo) -> LinePart {
Style::new().fg(green_color).bold().paint("Alt + o"),
Style::new().paint(" (right)"),
];
ansi_strings!(&bits)
strings!(&bits)
}

pub fn move_tabs_short(help: &ModeInfo) -> LinePart {
Expand All @@ -49,5 +65,5 @@ pub fn move_tabs_short(help: &ModeInfo) -> LinePart {
Style::new().fg(green_color).bold().paint("Alt + o"),
Style::new().paint(" (right)"),
];
ansi_strings!(&bits)
strings!(&bits)
}
23 changes: 18 additions & 5 deletions default-plugins/status-bar/src/tip/data/quicknav.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
use ansi_term::{ANSIString, Style};
use ansi_term::{unstyled_len, ANSIString, ANSIStrings, Style};

use crate::{action_key, action_key_group, ansi_strings, style_key_with_modifier, LinePart};
use crate::{action_key, action_key_group, style_key_with_modifier, LinePart};
use zellij_tile::prelude::{actions::Action, *};

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn quicknav_full(help: &ModeInfo) -> LinePart {
let groups = add_keybinds(help);

Expand All @@ -13,7 +26,7 @@ pub fn quicknav_full(help: &ModeInfo) -> LinePart {
bits.push(Style::new().paint(" => navigate between panes. "));
bits.extend(groups.resize);
bits.push(Style::new().paint(" => increase/decrease pane size."));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn quicknav_medium(help: &ModeInfo) -> LinePart {
Expand All @@ -26,7 +39,7 @@ pub fn quicknav_medium(help: &ModeInfo) -> LinePart {
bits.push(Style::new().paint(" => navigate. "));
bits.extend(groups.resize);
bits.push(Style::new().paint(" => resize pane."));
ansi_strings!(&bits)
strings!(&bits)
}

pub fn quicknav_short(help: &ModeInfo) -> LinePart {
Expand All @@ -38,7 +51,7 @@ pub fn quicknav_short(help: &ModeInfo) -> LinePart {
bits.extend(groups.move_focus);
bits.push(Style::new().paint(" / "));
bits.extend(groups.resize);
ansi_strings!(&bits)
strings!(&bits)
}

struct Keygroups<'a> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
use ansi_term::Color::{Fixed, RGB};
use ansi_term::Style;
use ansi_term::{
unstyled_len, ANSIString, ANSIStrings,
Color::{Fixed, RGB},
Style,
};

use crate::{ansi_strings, LinePart};
use crate::LinePart;
use zellij_tile::prelude::*;
use zellij_tile_utils::palette_match;

macro_rules! strings {
($ANSIStrings:expr) => {{
let strings: &[ANSIString] = $ANSIStrings;

let ansi_strings = ANSIStrings(strings);

LinePart {
part: format!("{}", ansi_strings),
len: unstyled_len(&ansi_strings),
}
}};
}

pub fn mouse_click_to_terminal_full(help: &ModeInfo) -> LinePart {
// Tip: SHIFT + <mouse-click> bypasses Zellij and sends the mouse click directly to the terminal
let green_color = palette_match!(help.style.colors.green);
let orange_color = palette_match!(help.style.colors.orange);

ansi_strings!(&[
strings!(&[
Style::new().paint(" Tip: "),
Style::new().fg(orange_color).bold().paint("Shift"),
Style::new().paint(" + <"),
Expand All @@ -23,7 +39,7 @@ pub fn mouse_click_to_terminal_medium(help: &ModeInfo) -> LinePart {
// Tip: SHIFT + <mouse-click> sends the click directly to the terminal
let green_color = palette_match!(help.style.colors.green);
let orange_color = palette_match!(help.style.colors.orange);
ansi_strings!(&[
strings!(&[
Style::new().paint(" Tip: "),
Style::new().fg(orange_color).bold().paint("Shift"),
Style::new().paint(" + <"),
Expand All @@ -37,7 +53,7 @@ pub fn mouse_click_to_terminal_short(help: &ModeInfo) -> LinePart {
let green_color = palette_match!(help.style.colors.green);
let orange_color = palette_match!(help.style.colors.orange);

ansi_strings!(&[
strings!(&[
Style::new().paint(" Tip: "),
Style::new().fg(orange_color).bold().paint("Shift"),
Style::new().paint(" + <"),
Expand Down
Loading

0 comments on commit d8c9946

Please sign in to comment.