Merge 'upstream/main' into config-file

This commit is contained in:
a-kenji 2021-03-11 22:43:43 +01:00
commit acc2524105
38 changed files with 1301 additions and 627 deletions

13
Cargo.lock generated
View file

@ -24,6 +24,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "arrayvec"
version = "0.5.2"
@ -280,7 +289,7 @@ version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"ansi_term",
"ansi_term 0.11.0",
"atty",
"bitflags",
"strsim 0.8.0",
@ -1494,6 +1503,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
name = "status-bar"
version = "0.1.0"
dependencies = [
"ansi_term 0.12.1",
"colored",
"zellij-tile",
]
@ -1585,6 +1595,7 @@ dependencies = [
name = "tab-bar"
version = "0.1.0"
dependencies = [
"ansi_term 0.12.1",
"colored",
"zellij-tile",
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

View file

@ -5,9 +5,11 @@ parts:
split_size:
Fixed: 1
plugin: tab-bar
events:
- Tab
- direction: Vertical
expansion_boundary: true
- direction: Vertical
split_size:
Fixed: 1
Fixed: 2
plugin: status-bar

View file

@ -7,4 +7,5 @@ license = "MIT"
[dependencies]
colored = "2"
zellij-tile = { path = "../../zellij-tile" }
ansi_term = "0.12"
zellij-tile = { path = "../../zellij-tile" }

View file

@ -0,0 +1,359 @@
use ansi_term::{ANSIStrings, Style};
use zellij_tile::*;
use crate::colors::{BLACK, BRIGHT_GRAY, GRAY, GREEN, RED, WHITE};
use crate::{LinePart, ARROW_SEPARATOR};
struct CtrlKeyShortcut {
mode: CtrlKeyMode,
action: CtrlKeyAction,
}
impl CtrlKeyShortcut {
pub fn new(mode: CtrlKeyMode, action: CtrlKeyAction) -> Self {
CtrlKeyShortcut { mode, action }
}
}
enum CtrlKeyAction {
Lock,
Pane,
Tab,
Resize,
Scroll,
Quit,
}
enum CtrlKeyMode {
Unselected,
Selected,
Disabled,
}
impl CtrlKeyShortcut {
pub fn full_text(&self) -> String {
match self.action {
CtrlKeyAction::Lock => String::from("LOCK"),
CtrlKeyAction::Pane => String::from("PANE"),
CtrlKeyAction::Tab => String::from("TAB"),
CtrlKeyAction::Resize => String::from("RESIZE"),
CtrlKeyAction::Scroll => String::from("SCROLL"),
CtrlKeyAction::Quit => String::from("QUIT"),
}
}
pub fn shortened_text(&self) -> String {
match self.action {
CtrlKeyAction::Lock => String::from("LOCK"),
CtrlKeyAction::Pane => String::from("ane"),
CtrlKeyAction::Tab => String::from("ab"),
CtrlKeyAction::Resize => String::from("esize"),
CtrlKeyAction::Scroll => String::from("croll"),
CtrlKeyAction::Quit => String::from("uit"),
}
}
pub fn letter_shortcut(&self) -> char {
match self.action {
CtrlKeyAction::Lock => 'g',
CtrlKeyAction::Pane => 'p',
CtrlKeyAction::Tab => 't',
CtrlKeyAction::Resize => 'r',
CtrlKeyAction::Scroll => 's',
CtrlKeyAction::Quit => 'q',
}
}
}
fn unselected_mode_shortcut(letter: char, text: &str) -> LinePart {
let prefix_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
let char_left_separator = Style::new()
.bold()
.fg(BLACK)
.on(BRIGHT_GRAY)
.bold()
.paint(format!(" <"));
let char_shortcut = Style::new()
.bold()
.fg(RED)
.on(BRIGHT_GRAY)
.bold()
.paint(format!("{}", letter));
let char_right_separator = Style::new()
.bold()
.fg(BLACK)
.on(BRIGHT_GRAY)
.bold()
.paint(format!(">"));
let styled_text = Style::new()
.fg(BLACK)
.on(BRIGHT_GRAY)
.bold()
.paint(format!("{} ", text));
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
LinePart {
part: format!(
"{}",
ANSIStrings(&[
prefix_separator,
char_left_separator,
char_shortcut,
char_right_separator,
styled_text,
suffix_separator
])
),
len: text.chars().count() + 6, // 2 for the arrows, 3 for the char separators, 1 for the character
}
}
fn selected_mode_shortcut(letter: char, text: &str) -> LinePart {
let prefix_separator = Style::new().fg(GRAY).on(GREEN).paint(ARROW_SEPARATOR);
let char_left_separator = Style::new()
.bold()
.fg(BLACK)
.on(GREEN)
.bold()
.paint(format!(" <"));
let char_shortcut = Style::new()
.bold()
.fg(RED)
.on(GREEN)
.bold()
.paint(format!("{}", letter));
let char_right_separator = Style::new()
.bold()
.fg(BLACK)
.on(GREEN)
.bold()
.paint(format!(">"));
let styled_text = Style::new()
.fg(BLACK)
.on(GREEN)
.bold()
.paint(format!("{} ", text));
let suffix_separator = Style::new().fg(GREEN).on(GRAY).paint(ARROW_SEPARATOR);
LinePart {
part: format!(
"{}",
ANSIStrings(&[
prefix_separator,
char_left_separator,
char_shortcut,
char_right_separator,
styled_text,
suffix_separator
])
),
len: text.chars().count() + 6, // 2 for the arrows, 3 for the char separators, 1 for the character
}
}
fn disabled_mode_shortcut(text: &str) -> LinePart {
let prefix_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
let styled_text = Style::new()
.fg(GRAY)
.on(BRIGHT_GRAY)
.dimmed()
.paint(format!("{} ", text));
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
LinePart {
part: format!("{}{}{}", prefix_separator, styled_text, suffix_separator),
len: text.chars().count() + 2 + 1, // 2 for the arrows, 1 for the padding in the end
}
}
fn selected_mode_shortcut_single_letter(letter: char) -> LinePart {
let char_shortcut_text = format!(" {} ", letter);
let len = char_shortcut_text.chars().count() + 4; // 2 for the arrows, 2 for the padding
let prefix_separator = Style::new().fg(GRAY).on(GREEN).paint(ARROW_SEPARATOR);
let char_shortcut = Style::new()
.bold()
.fg(RED)
.on(GREEN)
.bold()
.paint(char_shortcut_text);
let suffix_separator = Style::new().fg(GREEN).on(GRAY).paint(ARROW_SEPARATOR);
LinePart {
part: format!(
"{}",
ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator])
),
len,
}
}
fn unselected_mode_shortcut_single_letter(letter: char) -> LinePart {
let char_shortcut_text = format!(" {} ", letter);
let len = char_shortcut_text.chars().count() + 4; // 2 for the arrows, 2 for the padding
let prefix_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
let char_shortcut = Style::new()
.bold()
.fg(RED)
.on(BRIGHT_GRAY)
.bold()
.paint(char_shortcut_text);
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
LinePart {
part: format!(
"{}",
ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator])
),
len,
}
}
fn full_ctrl_key(key: &CtrlKeyShortcut) -> LinePart {
let full_text = key.full_text();
let letter_shortcut = key.letter_shortcut();
match key.mode {
CtrlKeyMode::Unselected => {
unselected_mode_shortcut(letter_shortcut, &format!(" {}", full_text))
}
CtrlKeyMode::Selected => {
selected_mode_shortcut(letter_shortcut, &format!(" {}", full_text))
}
CtrlKeyMode::Disabled => {
disabled_mode_shortcut(&format!(" <{}> {}", letter_shortcut, full_text))
}
}
}
fn shortened_ctrl_key(key: &CtrlKeyShortcut) -> LinePart {
let shortened_text = key.shortened_text();
let letter_shortcut = key.letter_shortcut();
let shortened_text = match key.action {
CtrlKeyAction::Lock => format!(" {}", shortened_text),
_ => shortened_text,
};
match key.mode {
CtrlKeyMode::Unselected => {
unselected_mode_shortcut(letter_shortcut, &format!("{}", shortened_text))
}
CtrlKeyMode::Selected => {
selected_mode_shortcut(letter_shortcut, &format!("{}", shortened_text))
}
CtrlKeyMode::Disabled => {
disabled_mode_shortcut(&format!(" <{}>{}", letter_shortcut, shortened_text))
}
}
}
fn single_letter_ctrl_key(key: &CtrlKeyShortcut) -> LinePart {
let letter_shortcut = key.letter_shortcut();
match key.mode {
CtrlKeyMode::Unselected => unselected_mode_shortcut_single_letter(letter_shortcut),
CtrlKeyMode::Selected => selected_mode_shortcut_single_letter(letter_shortcut),
CtrlKeyMode::Disabled => disabled_mode_shortcut(&format!(" {}", letter_shortcut)),
}
}
fn key_indicators(max_len: usize, keys: &[CtrlKeyShortcut]) -> LinePart {
let mut line_part = LinePart::default();
for ctrl_key in keys {
let key = full_ctrl_key(ctrl_key);
line_part.part = format!("{}{}", line_part.part, key.part);
line_part.len += key.len;
}
if line_part.len < max_len {
return line_part;
}
line_part = LinePart::default();
for ctrl_key in keys {
let key = shortened_ctrl_key(ctrl_key);
line_part.part = format!("{}{}", line_part.part, key.part);
line_part.len += key.len;
}
if line_part.len < max_len {
return line_part;
}
line_part = LinePart::default();
for ctrl_key in keys {
let key = single_letter_ctrl_key(ctrl_key);
line_part.part = format!("{}{}", line_part.part, key.part);
line_part.len += key.len;
}
if line_part.len < max_len {
return line_part;
}
line_part = LinePart::default();
line_part
}
pub fn superkey() -> LinePart {
let prefix_text = " Ctrl + ";
let prefix = Style::new().fg(WHITE).on(GRAY).bold().paint(prefix_text);
LinePart {
part: format!("{}", prefix),
len: prefix_text.chars().count(),
}
}
pub fn ctrl_keys(help: &Help, max_len: usize) -> LinePart {
match &help.mode {
InputMode::Locked => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Quit),
],
),
InputMode::Resize => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
],
),
InputMode::Pane => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
],
),
InputMode::Tab | InputMode::RenameTab => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
],
),
InputMode::Scroll => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
],
),
InputMode::Normal | _ => key_indicators(
max_len,
&vec![
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Resize),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Scroll),
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Quit),
],
),
}
}

View file

@ -1,9 +1,25 @@
use colored::*;
mod first_line;
mod second_line;
use std::fmt::{Display, Error, Formatter};
use zellij_tile::*;
use first_line::{ctrl_keys, superkey};
use second_line::keybinds;
pub mod colors {
use ansi_term::Colour::{self, Fixed};
pub const WHITE: Colour = Fixed(255);
pub const BLACK: Colour = Fixed(16);
pub const GREEN: Colour = Fixed(154);
pub const ORANGE: Colour = Fixed(166);
pub const GRAY: Colour = Fixed(238);
pub const BRIGHT_GRAY: Colour = Fixed(245);
pub const RED: Colour = Fixed(88);
}
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
static ARROW_SEPARATOR: &str = "";
static ARROW_SEPARATOR: &str = "";
static MORE_MSG: &str = " ... ";
#[derive(Default)]
@ -11,7 +27,8 @@ struct State {}
register_tile!(State);
struct LinePart {
#[derive(Default)]
pub struct LinePart {
part: String,
len: usize,
}
@ -22,240 +39,24 @@ impl Display for LinePart {
}
}
fn prefix(help: &Help) -> LinePart {
let prefix_text = " Zellij ";
let part = match &help.mode {
InputMode::Command => {
let prefix = prefix_text.bold().white().on_black();
let separator = ARROW_SEPARATOR.black().on_magenta();
format!("{}{}", prefix, separator)
}
InputMode::Normal => {
let prefix = prefix_text.bold().white().on_black();
let separator = ARROW_SEPARATOR.black().on_green();
format!("{}{}", prefix, separator)
}
_ => {
let prefix = prefix_text.bold().white().on_black();
let separator = ARROW_SEPARATOR.black().on_magenta();
format!("{}{}", prefix, separator)
}
};
let len = prefix_text.chars().count() + ARROW_SEPARATOR.chars().count();
LinePart { part, len }
}
fn key_path(help: &Help) -> LinePart {
let superkey_text = "<Ctrl-g> ";
let (part, len) = match &help.mode {
InputMode::Command => {
let key_path = superkey_text.bold().on_magenta();
let first_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count();
(format!("{}{}", key_path, first_separator), len)
}
InputMode::Resize => {
let mode_shortcut_text = "r ";
let superkey = superkey_text.bold().on_magenta();
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
InputMode::Pane => {
let mode_shortcut_text = "p ";
let superkey = superkey_text.bold().on_magenta();
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
InputMode::Tab => {
let mode_shortcut_text = "t ";
let superkey = superkey_text.bold().on_magenta();
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
InputMode::Scroll => {
let mode_shortcut_text = "s ";
let superkey = superkey_text.bold().on_magenta();
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
InputMode::Normal | _ => {
let key_path = superkey_text.on_green();
let separator = ARROW_SEPARATOR.green().on_black();
(
format!("{}{}", key_path, separator),
superkey_text.chars().count() + ARROW_SEPARATOR.chars().count(),
)
}
};
LinePart { part, len }
}
fn keybinds(help: &Help, max_width: usize) -> LinePart {
let mut keybinds = String::new();
let mut len = 0;
let full_keybinds_len =
help.keybinds
.iter()
.enumerate()
.fold(0, |acc, (i, (shortcut, description))| {
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let description_length = description.chars().count() + 2;
let (_separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
acc + shortcut_length + description_length + separator_len
});
if full_keybinds_len < max_width {
for (i, (shortcut, description)) in help.keybinds.iter().enumerate() {
let separator = if i > 0 { " / " } else { "" };
let shortcut_len = shortcut.chars().count();
let shortcut = match help.mode {
InputMode::Normal => shortcut.cyan(),
_ => shortcut.white().bold(),
};
keybinds = format!("{}{}<{}> {}", keybinds, separator, shortcut, description);
len += shortcut_len + separator.chars().count();
}
} else {
for (i, (shortcut, description)) in help.keybinds.iter().enumerate() {
let description_first_word = description.split(' ').next().unwrap_or("");
let current_length = keybinds.chars().count();
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let description_first_word_length = description_first_word.chars().count();
let (separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
let shortcut = match help.mode {
InputMode::Normal => shortcut.cyan(),
_ => shortcut.white().bold(),
};
if current_length
+ shortcut_length
+ description_first_word_length
+ separator_len
+ MORE_MSG.chars().count()
< max_width
{
keybinds = format!(
"{}{}<{}> {}",
keybinds, separator, shortcut, description_first_word
);
len += shortcut_length + description_first_word_length + separator_len;
} else if current_length + shortcut_length + separator_len + MORE_MSG.chars().count()
< max_width
{
keybinds = format!("{}{}<{}>", keybinds, separator, shortcut);
len += shortcut_length + separator_len;
} else {
keybinds = format!("{}{}", keybinds, MORE_MSG);
len += MORE_MSG.chars().count();
break;
}
}
}
LinePart {
part: keybinds,
len,
}
}
impl ZellijTile for State {
fn init(&mut self) {
set_selectable(false);
set_invisible_borders(true);
set_max_height(1);
set_max_height(2);
}
fn draw(&mut self, _rows: usize, cols: usize) {
let help = get_help();
let line_prefix = prefix(&help);
let key_path = key_path(&help);
let line_len_before_keybinds = line_prefix.len + key_path.len;
let status_bar = if line_len_before_keybinds + MORE_MSG.chars().count() < cols {
let keybinds = keybinds(&help, cols - line_len_before_keybinds);
let keybinds = keybinds.part.cyan().on_black();
format!("{}{}{}", line_prefix, key_path, keybinds)
} else if line_len_before_keybinds < cols {
format!("{}{}", line_prefix, key_path)
} else if line_prefix.len < cols {
format!("{}", line_prefix)
} else {
// sorry, too small :(
format!("")
};
// 40m is black background, 0K is so that it fills the rest of the line,
// I could not find a way to do this with colored and did not want to have to
// manually fill the line with spaces to achieve the same
println!("{}\u{1b}[40m\u{1b}[0K", status_bar);
let superkey = superkey();
let ctrl_keys = ctrl_keys(&help, cols - superkey.len);
let first_line = format!("{}{}", superkey, ctrl_keys);
let second_line = keybinds(&help, cols);
// [48;5;238m is gray background, [0K is so that it fills the rest of the line
// [48;5;16m is black background, [0K is so that it fills the rest of the line
println!("{}\u{1b}[48;5;238m\u{1b}[0K", first_line);
println!("{}\u{1b}[48;5;16m\u{1b}[0K", second_line);
}
}

View file

@ -0,0 +1,182 @@
// use colored::*;
use ansi_term::{ANSIStrings, Style};
use zellij_tile::*;
use crate::colors::{BLACK, GREEN, ORANGE, WHITE};
use crate::{LinePart, MORE_MSG};
fn full_length_shortcut(is_first_shortcut: bool, letter: &str, description: &str) -> LinePart {
let separator = if is_first_shortcut { " " } else { " / " };
let separator = Style::new().on(BLACK).fg(WHITE).paint(separator);
let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let shortcut_left_separator = Style::new().on(BLACK).fg(WHITE).paint("<");
let shortcut = Style::new().on(BLACK).fg(GREEN).bold().paint(letter);
let shortcut_right_separator = Style::new().on(BLACK).fg(WHITE).paint("> ");
let description_len = description.chars().count();
let description = Style::new().on(BLACK).fg(WHITE).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
part: format!(
"{}",
ANSIStrings(&[
separator,
shortcut_left_separator,
shortcut,
shortcut_right_separator,
description
])
),
len,
}
}
fn first_word_shortcut(is_first_shortcut: bool, letter: &str, description: &str) -> LinePart {
let separator = if is_first_shortcut { " " } else { " / " };
let separator = Style::new().on(BLACK).fg(WHITE).paint(separator);
let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let shortcut_left_separator = Style::new().on(BLACK).fg(WHITE).paint("<");
let shortcut = Style::new().on(BLACK).fg(GREEN).bold().paint(letter);
let shortcut_right_separator = Style::new().on(BLACK).fg(WHITE).paint("> ");
let description_first_word = description.split(' ').next().unwrap_or("");
let description_first_word_length = description_first_word.chars().count();
let description_first_word = Style::new()
.on(BLACK)
.fg(WHITE)
.bold()
.paint(description_first_word);
let len = shortcut_len + description_first_word_length + separator.chars().count();
LinePart {
part: format!(
"{}",
ANSIStrings(&[
separator,
shortcut_left_separator,
shortcut,
shortcut_right_separator,
description_first_word,
])
),
len,
}
}
fn locked_interface_indication() -> LinePart {
let locked_text = " -- INTERFACE LOCKED -- ";
let locked_text_len = locked_text.chars().count();
let locked_styled_text = Style::new().on(BLACK).fg(WHITE).bold().paint(locked_text);
LinePart {
part: format!("{}", locked_styled_text),
len: locked_text_len,
}
}
fn select_pane_shortcut(is_first_shortcut: bool) -> LinePart {
let shortcut = "ENTER";
let description = "Select pane";
let separator = if is_first_shortcut { " " } else { " / " };
let separator = Style::new().on(BLACK).fg(WHITE).paint(separator);
let shortcut_len = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let shortcut_left_separator = Style::new().on(BLACK).fg(WHITE).paint("<");
let shortcut = Style::new().on(BLACK).fg(ORANGE).bold().paint(shortcut);
let shortcut_right_separator = Style::new().on(BLACK).fg(WHITE).paint("> ");
let description_len = description.chars().count();
let description = Style::new().on(BLACK).fg(WHITE).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
part: format!(
"{}",
ANSIStrings(&[
separator,
shortcut_left_separator,
shortcut,
shortcut_right_separator,
description
])
),
len,
}
}
fn full_shortcut_list(help: &Help) -> LinePart {
match help.mode {
InputMode::Normal => LinePart::default(),
InputMode::Locked => locked_interface_indication(),
_ => {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = full_length_shortcut(i == 0, &letter, &description);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
line_part
}
}
}
fn shortened_shortcut_list(help: &Help) -> LinePart {
match help.mode {
InputMode::Normal => LinePart::default(),
InputMode::Locked => locked_interface_indication(),
_ => {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, &letter, &description);
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
line_part
}
}
}
fn best_effort_shortcut_list(help: &Help, max_len: usize) -> LinePart {
match help.mode {
InputMode::Normal => LinePart::default(),
InputMode::Locked => {
let line_part = locked_interface_indication();
if line_part.len <= max_len {
line_part
} else {
LinePart::default()
}
}
_ => {
let mut line_part = LinePart::default();
for (i, (letter, description)) in help.keybinds.iter().enumerate() {
let shortcut = first_word_shortcut(i == 0, &letter, &description);
if line_part.len + shortcut.len + MORE_MSG.chars().count() > max_len {
// TODO: better
line_part.part = format!("{}{}", line_part.part, MORE_MSG);
line_part.len += MORE_MSG.chars().count();
break;
}
line_part.len += shortcut.len;
line_part.part = format!("{}{}", line_part.part, shortcut,);
}
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
if line_part.len + select_pane_shortcut.len <= max_len {
line_part.len += select_pane_shortcut.len;
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
}
line_part
}
}
}
pub fn keybinds(help: &Help, max_width: usize) -> LinePart {
let full_shortcut_list = full_shortcut_list(help);
if full_shortcut_list.len <= max_width {
return full_shortcut_list;
}
let shortened_shortcut_list = shortened_shortcut_list(help);
if shortened_shortcut_list.len <= max_width {
return shortened_shortcut_list;
}
return best_effort_shortcut_list(help, max_width);
}

View file

@ -7,4 +7,5 @@ license = "MIT"
[dependencies]
colored = "2"
ansi_term = "0.12"
zellij-tile = { path = "../../zellij-tile" }

View file

@ -0,0 +1,180 @@
use crate::colors::{BLACK, GRAY, ORANGE, WHITE};
use ansi_term::{ANSIStrings, Style};
use crate::{LinePart, ARROW_SEPARATOR};
fn get_current_title_len(current_title: &[LinePart]) -> usize {
current_title
.iter()
.fold(0, |acc, title_part| acc + title_part.len)
}
fn populate_tabs_in_tab_line(
tabs_before_active: &mut Vec<LinePart>,
tabs_after_active: &mut Vec<LinePart>,
tabs_to_render: &mut Vec<LinePart>,
cols: usize,
) {
let mut take_next_tab_from_tabs_after = true;
loop {
if tabs_before_active.is_empty() && tabs_after_active.is_empty() {
break;
}
let current_title_len = get_current_title_len(&tabs_to_render);
if current_title_len >= cols {
break;
}
let should_take_next_tab = take_next_tab_from_tabs_after;
let can_take_next_tab = !tabs_after_active.is_empty()
&& tabs_after_active.get(0).unwrap().len + current_title_len <= cols;
let can_take_previous_tab = !tabs_before_active.is_empty()
&& tabs_before_active.last().unwrap().len + current_title_len <= cols;
if should_take_next_tab && can_take_next_tab {
let next_tab = tabs_after_active.remove(0);
tabs_to_render.push(next_tab);
take_next_tab_from_tabs_after = false;
} else if can_take_previous_tab {
let previous_tab = tabs_before_active.pop().unwrap();
tabs_to_render.insert(0, previous_tab);
take_next_tab_from_tabs_after = true;
} else if can_take_next_tab {
let next_tab = tabs_after_active.remove(0);
tabs_to_render.push(next_tab);
take_next_tab_from_tabs_after = false;
} else {
break;
}
}
}
fn left_more_message(tab_count_to_the_left: usize) -> LinePart {
if tab_count_to_the_left == 0 {
return LinePart {
part: String::new(),
len: 0,
};
}
let more_text = if tab_count_to_the_left < 10000 {
format!(" ← +{} ", tab_count_to_the_left)
} else {
format!(" ← +many ")
};
// 238
let more_text_len = more_text.chars().count() + 2; // 2 for the arrows
let left_separator = Style::new().fg(GRAY).on(ORANGE).paint(ARROW_SEPARATOR);
let more_styled_text = Style::new().fg(BLACK).on(ORANGE).bold().paint(more_text);
let right_separator = Style::new().fg(ORANGE).on(GRAY).paint(ARROW_SEPARATOR);
let more_styled_text = format!(
"{}",
ANSIStrings(&[left_separator, more_styled_text, right_separator,])
);
LinePart {
part: more_styled_text,
len: more_text_len,
}
}
fn right_more_message(tab_count_to_the_right: usize) -> LinePart {
if tab_count_to_the_right == 0 {
return LinePart {
part: String::new(),
len: 0,
};
};
let more_text = if tab_count_to_the_right < 10000 {
format!(" +{}", tab_count_to_the_right)
} else {
format!(" +many → ")
};
let more_text_len = more_text.chars().count() + 1; // 2 for the arrow
let left_separator = Style::new().fg(GRAY).on(ORANGE).paint(ARROW_SEPARATOR);
let more_styled_text = Style::new().fg(BLACK).on(ORANGE).bold().paint(more_text);
let right_separator = Style::new().fg(ORANGE).on(GRAY).paint(ARROW_SEPARATOR);
let more_styled_text = format!(
"{}",
ANSIStrings(&[left_separator, more_styled_text, right_separator,])
);
LinePart {
part: more_styled_text,
len: more_text_len,
}
}
fn add_previous_tabs_msg(
tabs_before_active: &mut Vec<LinePart>,
tabs_to_render: &mut Vec<LinePart>,
title_bar: &mut Vec<LinePart>,
cols: usize,
) {
while get_current_title_len(&tabs_to_render) + left_more_message(tabs_before_active.len()).len
>= cols
{
tabs_before_active.push(tabs_to_render.remove(0));
}
let left_more_message = left_more_message(tabs_before_active.len());
title_bar.push(left_more_message);
}
fn add_next_tabs_msg(
tabs_after_active: &mut Vec<LinePart>,
title_bar: &mut Vec<LinePart>,
cols: usize,
) {
while get_current_title_len(&title_bar) + right_more_message(tabs_after_active.len()).len
>= cols
{
tabs_after_active.insert(0, title_bar.pop().unwrap());
}
let right_more_message = right_more_message(tabs_after_active.len());
title_bar.push(right_more_message);
}
fn tab_line_prefix() -> LinePart {
let prefix_text = format!(" Zellij ");
let prefix_text_len = prefix_text.chars().count();
let prefix_styled_text = Style::new().fg(WHITE).on(GRAY).bold().paint(prefix_text);
LinePart {
part: format!("{}", prefix_styled_text),
len: prefix_text_len,
}
}
pub fn tab_line(
mut all_tabs: Vec<LinePart>,
active_tab_index: usize,
cols: usize,
) -> Vec<LinePart> {
let mut tabs_to_render: Vec<LinePart> = vec![];
let mut tabs_after_active = all_tabs.split_off(active_tab_index);
let mut tabs_before_active = all_tabs;
let active_tab = if !tabs_after_active.is_empty() {
tabs_after_active.remove(0)
} else {
tabs_before_active.pop().unwrap()
};
tabs_to_render.push(active_tab);
let prefix = tab_line_prefix();
populate_tabs_in_tab_line(
&mut tabs_before_active,
&mut tabs_after_active,
&mut tabs_to_render,
cols - prefix.len,
);
let mut tab_line: Vec<LinePart> = vec![];
if !tabs_before_active.is_empty() {
add_previous_tabs_msg(
&mut tabs_before_active,
&mut tabs_to_render,
&mut tab_line,
cols - prefix.len,
);
}
tab_line.append(&mut tabs_to_render);
if !tabs_after_active.is_empty() {
add_next_tabs_msg(&mut tabs_after_active, &mut tab_line, cols - prefix.len);
}
tab_line.insert(0, prefix);
tab_line
}

View file

@ -1,10 +1,49 @@
use colored::*;
mod line;
mod tab;
use zellij_tile::*;
use crate::line::tab_line;
use crate::tab::tab_style;
#[derive(Debug)]
pub struct LinePart {
part: String,
len: usize,
}
#[derive(PartialEq)]
enum BarMode {
Normal,
Rename,
}
impl Default for BarMode {
fn default() -> Self {
BarMode::Normal
}
}
#[derive(Default)]
struct State {
active_tab_index: usize,
num_tabs: usize,
tabs: Vec<TabData>,
mode: BarMode,
new_name: String,
}
static ARROW_SEPARATOR: &str = "";
pub mod colors {
use ansi_term::Colour::{self, Fixed};
pub const WHITE: Colour = Fixed(255);
pub const BLACK: Colour = Fixed(16);
pub const GREEN: Colour = Fixed(154);
pub const ORANGE: Colour = Fixed(166);
pub const GRAY: Colour = Fixed(238);
pub const BRIGHT_GRAY: Colour = Fixed(245);
pub const RED: Colour = Fixed(88);
}
register_tile!(State);
@ -16,25 +55,52 @@ impl ZellijTile for State {
set_max_height(1);
self.active_tab_index = 0;
self.num_tabs = 0;
self.mode = BarMode::Normal;
self.new_name = String::new();
}
fn draw(&mut self, _rows: usize, _cols: usize) {
let mut s = String::new();
let active_tab = self.active_tab_index + 1;
for i in 1..=self.num_tabs {
let tab;
if i == active_tab {
tab = format!("*{} ", i).black().bold().on_magenta();
} else {
tab = format!("-{} ", i).white();
}
s = format!("{}{}", s, tab);
fn draw(&mut self, _rows: usize, cols: usize) {
if self.tabs.is_empty() {
return;
}
println!("Tabs: {}\u{1b}[40m\u{1b}[0K", s);
let mut all_tabs: Vec<LinePart> = vec![];
let mut active_tab_index = 0;
for t in self.tabs.iter_mut() {
let mut tabname = t.name.clone();
if t.active && self.mode == BarMode::Rename {
if self.new_name.is_empty() {
tabname = String::from("Enter name...");
} else {
tabname = self.new_name.clone();
}
active_tab_index = t.position;
} else if t.active {
active_tab_index = t.position;
}
let tab = tab_style(tabname, t.active, t.position);
all_tabs.push(tab);
}
let tab_line = tab_line(all_tabs, active_tab_index, cols);
let mut s = String::new();
for bar_part in tab_line {
s = format!("{}{}", s, bar_part.part);
}
println!("{}\u{1b}[48;5;238m\u{1b}[0K", s);
}
fn update_tabs(&mut self, active_tab_index: usize, num_tabs: usize) {
self.active_tab_index = active_tab_index;
self.num_tabs = num_tabs;
fn update_tabs(&mut self) {
self.tabs = get_tabs();
}
fn handle_tab_rename_keypress(&mut self, key: Key) {
self.mode = BarMode::Rename;
match key {
Key::Char('\n') | Key::Esc => {
self.mode = BarMode::Normal;
self.new_name.clear();
}
Key::Char(c) => self.new_name = format!("{}{}", self.new_name, c),
_ => {}
}
}
}

View file

@ -0,0 +1,54 @@
use crate::colors::{BLACK, BRIGHT_GRAY, GRAY, GREEN};
use crate::{LinePart, ARROW_SEPARATOR};
use ansi_term::{ANSIStrings, Style};
pub fn active_tab(text: String) -> LinePart {
let left_separator = Style::new().fg(GRAY).on(GREEN).paint(ARROW_SEPARATOR);
let tab_text_len = text.chars().count() + 4; // 2 for left and right separators, 2 for the text padding
let tab_styled_text = Style::new()
.fg(BLACK)
.on(GREEN)
.bold()
.paint(format!(" {} ", text));
let right_separator = Style::new().fg(GREEN).on(GRAY).paint(ARROW_SEPARATOR);
let tab_styled_text = format!(
"{}",
ANSIStrings(&[left_separator, tab_styled_text, right_separator,])
);
LinePart {
part: tab_styled_text,
len: tab_text_len,
}
}
pub fn non_active_tab(text: String) -> LinePart {
let left_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
let tab_text_len = text.chars().count() + 4; // 2 for left and right separators, 2 for the padding
let tab_styled_text = Style::new()
.fg(BLACK)
.on(BRIGHT_GRAY)
.bold()
.paint(format!(" {} ", text));
let right_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
let tab_styled_text = format!(
"{}",
ANSIStrings(&[left_separator, tab_styled_text, right_separator,])
);
LinePart {
part: tab_styled_text,
len: tab_text_len,
}
}
pub fn tab_style(text: String, is_active_tab: bool, position: usize) -> LinePart {
let tab_text = if text.is_empty() {
format!("Tab #{}", position + 1)
} else {
text
};
if is_active_tab {
active_tab(tab_text)
} else {
non_active_tab(tab_text)
}
}

View file

@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::{fs::File, io::prelude::*};
use crate::common::wasm_vm::EventType;
use crate::panes::PositionAndSize;
fn split_space_to_parts_vertically(
@ -180,6 +181,8 @@ pub struct Layout {
pub plugin: Option<PathBuf>,
#[serde(default)]
pub expansion_boundary: bool,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub events: Vec<EventType>,
}
impl Layout {

View file

@ -2,11 +2,13 @@
//! as well as how they should be resized
use crate::common::{AppInstruction, SenderWithContext};
use crate::layout::Layout;
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
use crate::pty_bus::{PtyInstruction, VteEvent};
use crate::wasm_vm::{PluginInputType, PluginInstruction};
use crate::{boundaries::Boundaries, panes::PluginPane};
use crate::{layout::Layout, wasm_vm::PluginInstruction};
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
use serde::{Deserialize, Serialize};
use std::os::unix::io::RawFd;
use std::{
cmp::Reverse,
@ -51,6 +53,7 @@ fn split_horizontally_with_gap(rect: &PositionAndSize) -> (PositionAndSize, Posi
pub struct Tab {
pub index: usize,
pub position: usize,
pub name: String,
panes: BTreeMap<PaneId, Box<dyn Pane>>,
panes_to_hide: HashSet<PaneId>,
active_terminal: Option<PaneId>,
@ -64,6 +67,14 @@ pub struct Tab {
expansion_boundary: Option<PositionAndSize>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct TabData {
/* subset of fields to publish to plugins */
pub position: usize,
pub name: String,
pub active: bool,
}
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
pub trait Pane {
fn x(&self) -> usize;
@ -170,6 +181,7 @@ impl Tab {
pub fn new(
index: usize,
position: usize,
name: String,
full_screen_ws: &PositionAndSize,
mut os_api: Box<dyn OsApi>,
send_pty_instructions: SenderWithContext<PtyInstruction>,
@ -195,6 +207,7 @@ impl Tab {
index,
position,
panes,
name,
max_panes,
panes_to_hide: HashSet::new(),
active_terminal: pane_id,
@ -249,7 +262,11 @@ impl Tab {
if let Some(plugin) = &layout.plugin {
let (pid_tx, pid_rx) = channel();
self.send_plugin_instructions
.send(PluginInstruction::Load(pid_tx, plugin.clone()))
.send(PluginInstruction::Load(
pid_tx,
plugin.clone(),
layout.events.clone(),
))
.unwrap();
let pid = pid_rx.recv().unwrap();
let new_plugin = PluginPane::new(
@ -546,7 +563,10 @@ impl Tab {
}
Some(PaneId::Plugin(pid)) => {
self.send_plugin_instructions
.send(PluginInstruction::Input(pid, input_bytes))
.send(PluginInstruction::Input(
PluginInputType::Normal(pid),
input_bytes,
))
.unwrap();
}
_ => {}

View file

@ -198,6 +198,7 @@ pub enum ScreenContext {
SwitchTabPrev,
CloseTab,
GoToTab,
UpdateTabName,
}
impl From<&ScreenInstruction> for ScreenContext {
@ -236,6 +237,7 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::SwitchTabPrev => ScreenContext::SwitchTabPrev,
ScreenInstruction::CloseTab => ScreenContext::CloseTab,
ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab,
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
}
}
}

View file

@ -50,4 +50,6 @@ pub enum Action {
/// Close the current tab.
CloseTab,
GoToTab(u32),
TabNameInput(Vec<u8>),
SaveTabName,
}

View file

@ -8,7 +8,7 @@ use crate::errors::ContextType;
use crate::os_input_output::OsApi;
use crate::pty_bus::PtyInstruction;
use crate::screen::ScreenInstruction;
use crate::wasm_vm::PluginInstruction;
use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction};
use crate::CommandIsExecuting;
use serde::{Deserialize, Serialize};
@ -231,6 +231,28 @@ impl InputHandler {
.send(ScreenInstruction::GoToTab(i))
.unwrap();
}
Action::TabNameInput(c) => {
self.send_plugin_instructions
.send(PluginInstruction::Input(
PluginInputType::Event(EventType::Tab),
c.clone(),
))
.unwrap();
self.send_screen_instructions
.send(ScreenInstruction::UpdateTabName(c))
.unwrap();
}
Action::SaveTabName => {
self.send_plugin_instructions
.send(PluginInstruction::Input(
PluginInputType::Event(EventType::Tab),
vec![b'\n'],
))
.unwrap();
self.send_screen_instructions
.send(ScreenInstruction::UpdateTabName(vec![b'\n']))
.unwrap();
}
Action::NoOp => {}
}
@ -249,13 +271,12 @@ impl InputHandler {
/// Describes the different input modes, which change the way that keystrokes will be interpreted.
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)]
pub enum InputMode {
/// In `Normal` mode, input is always written to the terminal, except for one special input that
/// triggers the switch to [`InputMode::Command`] mode.
/// In `Normal` mode, input is always written to the terminal, except for the shortcuts leading
/// to other modes
Normal,
/// In `Command` mode, input is bound to actions (more precisely, sequences of actions).
/// `Command` mode gives access to the other modes non-`InputMode::Normal` modes.
/// etc.
Command,
/// In `Locked` mode, input is always written to the terminal and all shortcuts are disabled
/// except the one leading back to normal mode
Locked,
/// `Resize` mode allows resizing the different existing panes.
Resize,
/// `Pane` mode allows creating and closing panes, as well as moving between them.
@ -264,6 +285,7 @@ pub enum InputMode {
Tab,
/// `Scroll` mode allows scrolling up and down within a pane.
Scroll,
RenameTab,
}
/// Represents the contents of the help message that is printed in the status bar,
@ -287,12 +309,7 @@ impl Default for InputMode {
pub fn get_help(mode: InputMode) -> Help {
let mut keybinds: Vec<(String, String)> = vec![];
match mode {
InputMode::Normal | InputMode::Command => {
keybinds.push(("p".to_string(), "PANE".to_string()));
keybinds.push(("t".to_string(), "TAB".to_string()));
keybinds.push(("r".to_string(), "RESIZE".to_string()));
keybinds.push(("s".to_string(), "SCROLL".to_string()));
}
InputMode::Normal | InputMode::Locked => {}
InputMode::Resize => {
keybinds.push(("←↓↑→".to_string(), "Resize".to_string()));
}
@ -300,8 +317,8 @@ pub fn get_help(mode: InputMode) -> Help {
keybinds.push(("←↓↑→".to_string(), "Move focus".to_string()));
keybinds.push(("p".to_string(), "Next".to_string()));
keybinds.push(("n".to_string(), "New".to_string()));
keybinds.push(("d".to_string(), "Split down".to_string()));
keybinds.push(("r".to_string(), "Split right".to_string()));
keybinds.push(("d".to_string(), "Down split".to_string()));
keybinds.push(("r".to_string(), "Right split".to_string()));
keybinds.push(("x".to_string(), "Close".to_string()));
keybinds.push(("f".to_string(), "Fullscreen".to_string()));
}
@ -309,13 +326,15 @@ pub fn get_help(mode: InputMode) -> Help {
keybinds.push(("←↓↑→".to_string(), "Move focus".to_string()));
keybinds.push(("n".to_string(), "New".to_string()));
keybinds.push(("x".to_string(), "Close".to_string()));
keybinds.push(("r".to_string(), "Rename".to_string()));
}
InputMode::Scroll => {
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
}
InputMode::RenameTab => {
keybinds.push(("Enter".to_string(), "when done".to_string()));
}
}
keybinds.push(("ESC".to_string(), "BACK".to_string()));
keybinds.push(("q".to_string(), "QUIT".to_string()));
Help { mode, keybinds }
}

View file

@ -77,28 +77,52 @@ impl Keybinds {
InputMode::Normal => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Command)],
vec![Action::SwitchToMode(InputMode::Locked)],
);
}
InputMode::Command => {
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
defaults.insert(
Key::Char('r'),
Key::Ctrl('r'),
vec![Action::SwitchToMode(InputMode::Resize)],
);
defaults.insert(Key::Char('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
defaults.insert(Key::Char('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
defaults.insert(
Key::Char('s'),
Key::Ctrl('s'),
vec![Action::SwitchToMode(InputMode::Scroll)],
);
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
}
InputMode::Locked => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
defaults.insert(Key::Char('q'), vec![Action::Quit]);
}
InputMode::Resize => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Locked)],
);
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
defaults.insert(
Key::Ctrl('r'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
defaults.insert(
Key::Ctrl('s'),
vec![Action::SwitchToMode(InputMode::Scroll)],
);
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
defaults.insert(
Key::Char('\n'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Char(' '),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Char('h'), vec![Action::Resize(Direction::Left)]);
defaults.insert(Key::Char('j'), vec![Action::Resize(Direction::Down)]);
defaults.insert(Key::Char('k'), vec![Action::Resize(Direction::Up)]);
@ -108,20 +132,36 @@ impl Keybinds {
defaults.insert(Key::Down, vec![Action::Resize(Direction::Down)]);
defaults.insert(Key::Up, vec![Action::Resize(Direction::Up)]);
defaults.insert(Key::Right, vec![Action::Resize(Direction::Right)]);
defaults.insert(Key::Ctrl('b'), vec![Action::Resize(Direction::Left)]);
defaults.insert(Key::Ctrl('n'), vec![Action::Resize(Direction::Down)]);
defaults.insert(Key::Ctrl('p'), vec![Action::Resize(Direction::Up)]);
defaults.insert(Key::Ctrl('f'), vec![Action::Resize(Direction::Right)]);
defaults.insert(Key::Char('q'), vec![Action::Quit]);
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
}
InputMode::Pane => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Locked)],
);
defaults.insert(
Key::Ctrl('p'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Ctrl('r'),
vec![Action::SwitchToMode(InputMode::Resize)],
);
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
defaults.insert(
Key::Ctrl('s'),
vec![Action::SwitchToMode(InputMode::Scroll)],
);
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
defaults.insert(
Key::Char('\n'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Char(' '),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Char('h'), vec![Action::MoveFocus(Direction::Left)]);
defaults.insert(Key::Char('j'), vec![Action::MoveFocus(Direction::Down)]);
defaults.insert(Key::Char('k'), vec![Action::MoveFocus(Direction::Up)]);
@ -132,11 +172,6 @@ impl Keybinds {
defaults.insert(Key::Up, vec![Action::MoveFocus(Direction::Up)]);
defaults.insert(Key::Right, vec![Action::MoveFocus(Direction::Right)]);
defaults.insert(Key::Ctrl('b'), vec![Action::MoveFocus(Direction::Left)]);
defaults.insert(Key::Ctrl('n'), vec![Action::MoveFocus(Direction::Down)]);
defaults.insert(Key::Ctrl('p'), vec![Action::MoveFocus(Direction::Up)]);
defaults.insert(Key::Ctrl('f'), vec![Action::MoveFocus(Direction::Right)]);
defaults.insert(Key::Char('p'), vec![Action::SwitchFocus(Direction::Right)]);
defaults.insert(Key::Char('n'), vec![Action::NewPane(None)]);
defaults.insert(Key::Char('d'), vec![Action::NewPane(Some(Direction::Down))]);
@ -145,17 +180,37 @@ impl Keybinds {
vec![Action::NewPane(Some(Direction::Right))],
);
defaults.insert(Key::Char('x'), vec![Action::CloseFocus]);
defaults.insert(Key::Char('f'), vec![Action::ToggleFocusFullscreen]);
defaults.insert(Key::Char('q'), vec![Action::Quit]);
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
}
InputMode::Tab => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Locked)],
);
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
defaults.insert(
Key::Ctrl('r'),
vec![Action::SwitchToMode(InputMode::Resize)],
);
defaults.insert(
Key::Ctrl('t'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Ctrl('s'),
vec![Action::SwitchToMode(InputMode::Scroll)],
);
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
defaults.insert(
Key::Char('\n'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Char(' '),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Char('h'), vec![Action::GoToPreviousTab]);
defaults.insert(Key::Char('j'), vec![Action::GoToNextTab]);
defaults.insert(Key::Char('k'), vec![Action::GoToPreviousTab]);
@ -166,14 +221,16 @@ impl Keybinds {
defaults.insert(Key::Up, vec![Action::GoToPreviousTab]);
defaults.insert(Key::Right, vec![Action::GoToNextTab]);
defaults.insert(Key::Ctrl('b'), vec![Action::GoToPreviousTab]);
defaults.insert(Key::Ctrl('n'), vec![Action::GoToNextTab]);
defaults.insert(Key::Ctrl('p'), vec![Action::GoToPreviousTab]);
defaults.insert(Key::Ctrl('f'), vec![Action::GoToNextTab]);
defaults.insert(Key::Char('n'), vec![Action::NewTab]);
defaults.insert(Key::Char('x'), vec![Action::CloseTab]);
defaults.insert(
Key::Char('r'),
vec![
Action::SwitchToMode(InputMode::RenameTab),
Action::TabNameInput(vec![0]),
],
);
defaults.insert(Key::Char('q'), vec![Action::Quit]);
defaults.insert(
Key::Ctrl('g'),
@ -182,24 +239,55 @@ impl Keybinds {
for i in '1'..='9' {
defaults.insert(Key::Char(i), vec![Action::GoToTab(i.to_digit(10).unwrap())]);
}
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
}
InputMode::Scroll => {
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Locked)],
);
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
defaults.insert(
Key::Ctrl('r'),
vec![Action::SwitchToMode(InputMode::Resize)],
);
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
defaults.insert(
Key::Ctrl('s'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
defaults.insert(
Key::Char('\n'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(
Key::Char(' '),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
defaults.insert(Key::Down, vec![Action::ScrollDown]);
defaults.insert(Key::Up, vec![Action::ScrollUp]);
defaults.insert(Key::Ctrl('n'), vec![Action::ScrollDown]);
defaults.insert(Key::Ctrl('p'), vec![Action::ScrollUp]);
defaults.insert(Key::Char('q'), vec![Action::Quit]);
}
InputMode::RenameTab => {
defaults.insert(
Key::Char('\n'),
vec![Action::SaveTabName, Action::SwitchToMode(InputMode::Tab)],
);
defaults.insert(
Key::Ctrl('g'),
vec![Action::SwitchToMode(InputMode::Normal)],
);
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
defaults.insert(
Key::Esc,
vec![
Action::TabNameInput(vec![0x1b]),
Action::SwitchToMode(InputMode::Tab),
],
);
}
}
ModeKeybinds(defaults)
@ -224,7 +312,8 @@ impl Keybinds {
.unwrap_or_else(|| vec![action])
};
match *mode {
InputMode::Normal => mode_keybind_or_action(Action::Write(input)),
InputMode::Normal | InputMode::Locked => mode_keybind_or_action(Action::Write(input)),
InputMode::RenameTab => mode_keybind_or_action(Action::TabNameInput(input)),
_ => mode_keybind_or_action(Action::NoOp),
}
}

View file

@ -37,7 +37,9 @@ use os_input_output::OsApi;
use pty_bus::{PtyBus, PtyInstruction};
use screen::{Screen, ScreenInstruction};
use utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_ROOT_PLUGIN_DIR};
use wasm_vm::{wasi_stdout, wasi_write_string, zellij_imports, PluginInstruction};
use wasm_vm::{
wasi_stdout, wasi_write_string, zellij_imports, EventType, PluginInputType, PluginInstruction,
};
#[derive(Serialize, Deserialize, Debug)]
pub enum ApiCommand {
@ -440,6 +442,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
ScreenInstruction::GoToTab(tab_index) => {
screen.go_to_tab(tab_index as usize)
}
ScreenInstruction::UpdateTabName(c) => {
screen.update_active_tab_name(c);
}
ScreenInstruction::Quit => {
break;
}
@ -459,6 +464,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let store = Store::default();
let mut plugin_id = 0;
let mut plugin_map = HashMap::new();
let handler_map: HashMap<EventType, String> =
[(EventType::Tab, "handle_tab_rename_keypress".to_string())]
.iter()
.cloned()
.collect();
move || loop {
let (event, mut err_ctx) = receive_plugin_instructions
@ -469,7 +479,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
send_pty_instructions.update(err_ctx);
send_app_instructions.update(err_ctx);
match event {
PluginInstruction::Load(pid_tx, path) => {
PluginInstruction::Load(pid_tx, path, events) => {
let project_dirs =
ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
let plugin_dir = project_dirs.data_dir().join("plugins/");
@ -511,6 +521,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
send_screen_instructions: send_screen_instructions.clone(),
send_app_instructions: send_app_instructions.clone(),
wasi_env,
events,
};
let zellij = zellij_imports(&store, &plugin_env);
@ -535,32 +546,58 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap();
}
PluginInstruction::UpdateTabs(active_tab_index, num_tabs) => {
for (instance, _) in plugin_map.values() {
PluginInstruction::UpdateTabs(mut tabs) => {
for (instance, plugin_env) in plugin_map.values() {
if !plugin_env.events.contains(&EventType::Tab) {
continue;
}
let handler = instance.exports.get_function("update_tabs").unwrap();
handler
.call(&[
Value::I32(active_tab_index as i32),
Value::I32(num_tabs as i32),
])
.unwrap();
tabs.sort_by(|a, b| a.position.cmp(&b.position));
wasi_write_string(
&plugin_env.wasi_env,
&serde_json::to_string(&tabs).unwrap(),
);
handler.call(&[]).unwrap();
}
}
// FIXME: Deduplicate this with the callback below!
PluginInstruction::Input(pid, input_bytes) => {
let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
let handle_key = instance.exports.get_function("handle_key").unwrap();
for key in input_bytes.keys() {
if let Ok(key) = key {
wasi_write_string(
&plugin_env.wasi_env,
&serde_json::to_string(&key).unwrap(),
);
handle_key.call(&[]).unwrap();
PluginInstruction::Input(input_type, input_bytes) => {
match input_type {
PluginInputType::Normal(pid) => {
let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
let handle_key =
instance.exports.get_function("handle_key").unwrap();
for key in input_bytes.keys() {
if let Ok(key) = key {
wasi_write_string(
&plugin_env.wasi_env,
&serde_json::to_string(&key).unwrap(),
);
handle_key.call(&[]).unwrap();
}
}
}
PluginInputType::Event(event) => {
for (instance, plugin_env) in plugin_map.values() {
if !plugin_env.events.contains(&event) {
continue;
}
let handle_key = instance
.exports
.get_function(handler_map.get(&event).unwrap())
.unwrap();
for key in input_bytes.keys() {
if let Ok(key) = key {
wasi_write_string(
&plugin_env.wasi_env,
&serde_json::to_string(&key).unwrap(),
);
handle_key.call(&[]).unwrap();
}
}
}
}
}
drop(send_screen_instructions.send(ScreenInstruction::Render));
}
PluginInstruction::GlobalInput(input_bytes) => {

View file

@ -2,13 +2,14 @@
use std::collections::BTreeMap;
use std::os::unix::io::RawFd;
use std::str;
use std::sync::mpsc::Receiver;
use super::{AppInstruction, SenderWithContext};
use crate::os_input_output::OsApi;
use crate::panes::PositionAndSize;
use crate::pty_bus::{PtyInstruction, VteEvent};
use crate::tab::Tab;
use crate::tab::{Tab, TabData};
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
use crate::{layout::Layout, panes::PaneId};
@ -46,6 +47,7 @@ pub enum ScreenInstruction {
SwitchTabPrev,
CloseTab,
GoToTab(u32),
UpdateTabName(Vec<u8>),
}
/// A [`Screen`] holds multiple [`Tab`]s, each one holding multiple [`panes`](crate::client::panes).
@ -69,6 +71,7 @@ pub struct Screen {
active_tab_index: Option<usize>,
/// The [`OsApi`] this [`Screen`] uses.
os_api: Box<dyn OsApi>,
tabname_buf: String,
}
impl Screen {
@ -92,6 +95,7 @@ impl Screen {
active_tab_index: None,
tabs: BTreeMap::new(),
os_api,
tabname_buf: String::new(),
}
}
@ -103,6 +107,7 @@ impl Screen {
let tab = Tab::new(
tab_index,
position,
String::new(),
&self.full_screen_ws,
self.os_api.clone(),
self.send_pty_instructions.clone(),
@ -246,6 +251,7 @@ impl Screen {
let mut tab = Tab::new(
tab_index,
position,
String::new(),
&self.full_screen_ws,
self.os_api.clone(),
self.send_pty_instructions.clone(),
@ -261,13 +267,36 @@ impl Screen {
}
fn update_tabs(&self) {
if let Some(active_tab) = self.get_active_tab() {
self.send_plugin_instructions
.send(PluginInstruction::UpdateTabs(
active_tab.position,
self.tabs.len(),
))
.unwrap();
let mut tab_data = vec![];
let active_tab_index = self.active_tab_index.unwrap();
for tab in self.tabs.values() {
tab_data.push(TabData {
position: tab.position,
name: tab.name.clone(),
active: active_tab_index == tab.index,
});
}
self.send_plugin_instructions
.send(PluginInstruction::UpdateTabs(tab_data))
.unwrap();
}
pub fn update_active_tab_name(&mut self, buf: Vec<u8>) {
let s = str::from_utf8(&buf).unwrap();
match s {
"\0" => {
self.tabname_buf = String::new();
}
"\n" => {
let new_name = self.tabname_buf.clone();
let active_tab = self.get_active_tab_mut().unwrap();
active_tab.name = new_name;
self.update_tabs();
self.render();
}
c => {
self.tabname_buf.push_str(c);
}
}
}
}

View file

@ -1,24 +1,36 @@
use crate::tab::TabData;
use serde::{Deserialize, Serialize};
use std::{
path::PathBuf,
sync::mpsc::{channel, Sender},
};
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
use wasmer_wasi::WasiEnv;
// use crate::utils::logging::debug_log_to_file;
use super::{
input::handler::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction,
PaneId, SenderWithContext,
};
#[derive(Clone, Debug, PartialEq, Hash, Eq, Serialize, Deserialize)]
pub enum EventType {
Tab,
}
#[derive(Clone, Debug)]
pub enum PluginInputType {
Normal(u32),
Event(EventType),
}
#[derive(Clone, Debug)]
pub enum PluginInstruction {
Load(Sender<u32>, PathBuf),
Load(Sender<u32>, PathBuf, Vec<EventType>),
Draw(Sender<String>, u32, usize, usize), // String buffer, plugin id, rows, cols
Input(u32, Vec<u8>), // plugin id, input bytes
Input(PluginInputType, Vec<u8>), // plugin id, input bytes
GlobalInput(Vec<u8>), // input bytes
Unload(u32),
UpdateTabs(usize, usize), // num tabs, active tab
UpdateTabs(Vec<TabData>), // num tabs, active tab
Quit,
}
@ -29,6 +41,7 @@ pub struct PluginEnv {
pub send_app_instructions: SenderWithContext<AppInstruction>,
pub send_pty_instructions: SenderWithContext<PtyInstruction>, // FIXME: This should be a big bundle of all of the channels
pub wasi_env: WasiEnv,
pub events: Vec<EventType>,
}
// Plugin API ---------------------------------------------------------------------------------------------------------

View file

@ -3,12 +3,11 @@ use ::insta::assert_snapshot;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, SCROLL_MODE,
SCROLL_UP_IN_SCROLL_MODE, SPAWN_TERMINAL_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE,
SPLIT_RIGHT_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
PANE_MODE, QUIT, SCROLL_DOWN_IN_SCROLL_MODE, SCROLL_MODE, SCROLL_UP_IN_SCROLL_MODE,
SPAWN_TERMINAL_IN_PANE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
};
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::utils::logging::debug_log_to_file;
use crate::{start, CliArgs};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@ -24,7 +23,7 @@ pub fn starts_with_one_terminal() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -46,12 +45,7 @@ pub fn split_terminals_vertically() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_RIGHT_IN_PANE_MODE, &QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -73,12 +67,7 @@ pub fn split_terminals_horizontally() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_DOWN_IN_PANE_MODE, &QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -102,7 +91,6 @@ pub fn split_largest_terminal() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
@ -130,12 +118,7 @@ pub fn cannot_split_terminals_vertically_when_active_terminal_is_too_small() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_RIGHT_IN_PANE_MODE, &QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -157,12 +140,7 @@ pub fn cannot_split_terminals_horizontally_when_active_terminal_is_too_small() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPLIT_DOWN_IN_PANE_MODE, &QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -184,12 +162,7 @@ pub fn cannot_split_largest_terminal_when_there_is_no_room() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPAWN_TERMINAL_IN_PANE_MODE, &QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -212,11 +185,9 @@ pub fn scrolling_up_inside_a_pane() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&SCROLL_MODE,
&SCROLL_UP_IN_SCROLL_MODE,
&SCROLL_UP_IN_SCROLL_MODE,
@ -244,11 +215,9 @@ pub fn scrolling_down_inside_a_pane() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&SCROLL_MODE,
&SCROLL_UP_IN_SCROLL_MODE,
&SCROLL_UP_IN_SCROLL_MODE,
@ -280,7 +249,6 @@ pub fn max_panes() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
@ -312,7 +280,6 @@ pub fn toggle_focused_pane_fullscreen() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,

View file

@ -33,7 +33,6 @@ pub fn close_pane_with_another_pane_above_it() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&CLOSE_PANE_IN_PANE_MODE,
@ -70,7 +69,6 @@ pub fn close_pane_with_another_pane_below_it() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -106,7 +104,6 @@ pub fn close_pane_with_another_pane_to_the_left() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&CLOSE_PANE_IN_PANE_MODE,
@ -141,7 +138,6 @@ pub fn close_pane_with_another_pane_to_the_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -179,7 +175,6 @@ pub fn close_pane_with_multiple_panes_above_it() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -220,7 +215,6 @@ pub fn close_pane_with_multiple_panes_below_it() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -259,7 +253,6 @@ pub fn close_pane_with_multiple_panes_to_the_left() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -300,7 +293,6 @@ pub fn close_pane_with_multiple_panes_to_the_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -339,7 +331,6 @@ pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -400,7 +391,6 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -408,16 +398,12 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -463,7 +449,6 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -471,16 +456,12 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() {
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -526,7 +507,6 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -534,16 +514,12 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -579,7 +555,6 @@ pub fn closing_last_pane_exits_app() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,

View file

@ -7,7 +7,7 @@ use crate::tests::possible_tty_inputs::Bytes;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs};
use crate::tests::utils::commands::{COMMAND_TOGGLE, QUIT};
use crate::tests::utils::commands::QUIT;
/*
* These tests are general compatibility tests for non-trivial scenarios running in the terminal.
@ -39,7 +39,7 @@ pub fn run_bandwhich_from_fish_shell() {
};
let fixture_name = "fish_and_bandwhich";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -62,7 +62,7 @@ pub fn fish_tab_completion_options() {
};
let fixture_name = "fish_tab_completion_options";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -90,7 +90,7 @@ pub fn fish_select_tab_completion_options() {
};
let fixture_name = "fish_select_tab_completion_options";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -122,7 +122,7 @@ pub fn vim_scroll_region_down() {
};
let fixture_name = "vim_scroll_region_down";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]); // quit (ctrl-q)
fake_input_output.add_terminal_input(&[&QUIT]); // quit (ctrl-q)
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -151,7 +151,7 @@ pub fn vim_ctrl_d() {
};
let fixture_name = "vim_ctrl_d";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -179,7 +179,7 @@ pub fn vim_ctrl_u() {
};
let fixture_name = "vim_ctrl_u";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -202,7 +202,7 @@ pub fn htop() {
};
let fixture_name = "htop";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -225,7 +225,7 @@ pub fn htop_scrolling() {
};
let fixture_name = "htop_scrolling";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -248,7 +248,7 @@ pub fn htop_right_scrolling() {
};
let fixture_name = "htop_right_scrolling";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -279,7 +279,7 @@ pub fn vim_overwrite() {
};
let fixture_name = "vim_overwrite";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -305,7 +305,7 @@ pub fn clear_scroll_region() {
};
let fixture_name = "clear_scroll_region";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -328,7 +328,7 @@ pub fn display_tab_characters_properly() {
};
let fixture_name = "tab_characters";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -351,7 +351,7 @@ pub fn neovim_insert_mode() {
};
let fixture_name = "nvim_insert";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -376,7 +376,7 @@ pub fn bash_cursor_linewrap() {
};
let fixture_name = "bash_cursor_linewrap";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -401,7 +401,7 @@ pub fn fish_paste_multiline() {
};
let fixture_name = "fish_paste_multiline";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -424,7 +424,7 @@ pub fn git_log() {
};
let fixture_name = "git_log";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -449,7 +449,7 @@ pub fn git_diff_scrollup() {
};
let fixture_name = "git_diff_scrollup";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -472,7 +472,7 @@ pub fn emacs_longbuf() {
};
let fixture_name = "emacs_longbuf_tutorial";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -495,7 +495,7 @@ pub fn top_and_quit() {
};
let fixture_name = "top_and_quit";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer
@ -524,7 +524,7 @@ pub fn exa_plus_omf_theme() {
};
let fixture_name = "exa_plus_omf_theme";
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
start(Box::new(fake_input_output.clone()), CliArgs::default());
let output_frames = fake_input_output
.stdout_writer

View file

@ -4,8 +4,8 @@ use std::path::PathBuf;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_MODE,
SPAWN_TERMINAL_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_MODE, SPAWN_TERMINAL_IN_PANE_MODE,
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
};
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::{start, CliArgs};
@ -23,12 +23,7 @@ pub fn new_panes_are_open_inside_expansion_border() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&QUIT,
]);
fake_input_output.add_terminal_input(&[&PANE_MODE, &SPAWN_TERMINAL_IN_PANE_MODE, &QUIT]);
let mut opts = CliArgs::default();
opts.layout = Some(PathBuf::from(
"src/tests/fixtures/layouts/expansion-boundary-in-the-middle.yaml",
@ -56,10 +51,8 @@ pub fn resize_pane_inside_expansion_border() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -91,7 +84,6 @@ pub fn toggling_fullcsreen_in_expansion_border_expands_only_until_border() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPAWN_TERMINAL_IN_PANE_MODE,
&TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use crate::panes::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::utils::commands::{COMMAND_TOGGLE, QUIT};
use crate::tests::utils::commands::QUIT;
use crate::tests::utils::get_output_frame_snapshots;
use crate::{start, CliArgs};
@ -20,7 +20,7 @@ pub fn accepts_basic_layout() {
y: 0,
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &QUIT]);
fake_input_output.add_terminal_input(&[&QUIT]);
let mut opts = CliArgs::default();
opts.layout = Some(PathBuf::from(
"src/tests/fixtures/layouts/three-panes-with-nesting.yaml",

View file

@ -6,7 +6,7 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
@ -24,7 +24,6 @@ pub fn move_focus_down() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_UP_IN_PANE_MODE,
@ -54,7 +53,6 @@ pub fn move_focus_down_to_the_largest_overlap() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,

View file

@ -6,7 +6,7 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, PANE_MODE, QUIT,
MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
@ -24,7 +24,6 @@ pub fn move_focus_left() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_LEFT_IN_PANE_MODE,
@ -53,7 +52,6 @@ pub fn move_focus_left_to_the_largest_overlap() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_LEFT_IN_PANE_MODE,

View file

@ -6,7 +6,7 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, PANE_MODE, QUIT,
MOVE_FOCUS_LEFT_IN_PANE_MODE, MOVE_FOCUS_RIGHT_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
@ -24,7 +24,6 @@ pub fn move_focus_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_LEFT_IN_PANE_MODE,
@ -54,7 +53,6 @@ pub fn move_focus_right_to_the_largest_overlap() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,

View file

@ -6,7 +6,7 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
MOVE_FOCUS_DOWN_IN_PANE_MODE, MOVE_FOCUS_UP_IN_PANE_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
@ -24,7 +24,6 @@ pub fn move_focus_up() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_UP_IN_PANE_MODE,
@ -53,7 +52,6 @@ pub fn move_focus_up_to_the_largest_overlap() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_UP_IN_PANE_MODE,

View file

@ -6,7 +6,7 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE,
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE,
RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
@ -33,10 +33,8 @@ pub fn resize_down_with_pane_above() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -72,11 +70,9 @@ pub fn resize_down_with_pane_below() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -115,13 +111,11 @@ pub fn resize_down_with_panes_above_and_below() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -158,14 +152,12 @@ pub fn resize_down_with_multiple_panes_above() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -203,7 +195,6 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -212,7 +203,6 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -250,7 +240,6 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -258,7 +247,6 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -296,13 +284,11 @@ pub fn resize_down_with_panes_above_aligned_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -340,14 +326,12 @@ pub fn resize_down_with_panes_below_aligned_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -385,7 +369,6 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -395,7 +378,6 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -433,7 +415,6 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -445,7 +426,6 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,
@ -483,17 +463,14 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -512,7 +489,6 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
@ -552,17 +528,14 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -583,7 +556,6 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
@ -620,10 +592,8 @@ pub fn cannot_resize_down_when_pane_below_is_at_minimum_height() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_DOWN_IN_RESIZE_MODE,
&QUIT,

View file

@ -6,8 +6,8 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE,
RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@ -30,10 +30,8 @@ pub fn resize_left_with_pane_to_the_left() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -67,11 +65,9 @@ pub fn resize_left_with_pane_to_the_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -105,13 +101,11 @@ pub fn resize_left_with_panes_to_the_left_and_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -146,14 +140,12 @@ pub fn resize_left_with_multiple_panes_to_the_left() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -189,7 +181,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -198,7 +189,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -234,13 +224,11 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -276,7 +264,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -284,7 +271,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -320,14 +306,12 @@ pub fn resize_left_with_panes_to_the_right_aligned_bottom_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -365,7 +349,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -375,7 +358,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -413,7 +395,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -425,7 +406,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,
@ -463,17 +443,14 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -492,7 +469,6 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
@ -533,17 +509,14 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_abo
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -564,7 +537,6 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_abo
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
@ -601,10 +573,8 @@ pub fn cannot_resize_left_when_pane_to_the_left_is_at_minimum_width() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&QUIT,

View file

@ -6,9 +6,8 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE,
RESIZE_RIGHT_IN_RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE,
SPLIT_RIGHT_IN_PANE_MODE,
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@ -31,10 +30,8 @@ pub fn resize_right_with_pane_to_the_left() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -68,11 +65,9 @@ pub fn resize_right_with_pane_to_the_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -106,13 +101,11 @@ pub fn resize_right_with_panes_to_the_left_and_right() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -147,14 +140,12 @@ pub fn resize_right_with_multiple_panes_to_the_left() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -190,7 +181,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -199,7 +189,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -235,13 +224,11 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -277,7 +264,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -285,7 +271,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -321,14 +306,12 @@ pub fn resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -366,7 +349,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -376,7 +358,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -414,7 +395,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -426,7 +406,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,
@ -464,17 +443,14 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -493,7 +469,6 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
@ -533,17 +508,14 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_ab
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -564,7 +536,6 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_ab
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
@ -601,10 +572,8 @@ pub fn cannot_resize_right_when_pane_to_the_left_is_at_minimum_width() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_RIGHT_IN_RESIZE_MODE,
&QUIT,

View file

@ -6,8 +6,8 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE,
RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE,
RESIZE_UP_IN_RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@ -32,10 +32,8 @@ pub fn resize_up_with_pane_above() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -71,11 +69,9 @@ pub fn resize_up_with_pane_below() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -114,13 +110,11 @@ pub fn resize_up_with_panes_above_and_below() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -156,14 +150,12 @@ pub fn resize_up_with_multiple_panes_above() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -199,7 +191,6 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -208,7 +199,6 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -246,7 +236,6 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
@ -254,7 +243,6 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -292,13 +280,11 @@ pub fn resize_up_with_panes_above_aligned_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -336,14 +322,12 @@ pub fn resize_up_with_panes_below_aligned_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -381,7 +365,6 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -391,7 +374,6 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() {
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -429,7 +411,6 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() {
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
@ -441,7 +422,6 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() {
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,
@ -479,17 +459,14 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -508,7 +485,6 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
@ -548,17 +524,14 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
@ -579,7 +552,6 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&MOVE_FOCUS_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
&RESIZE_LEFT_IN_RESIZE_MODE,
@ -616,10 +588,8 @@ pub fn cannot_resize_up_when_pane_above_is_at_minimum_height() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&RESIZE_MODE,
&RESIZE_UP_IN_RESIZE_MODE,
&QUIT,

View file

@ -6,8 +6,8 @@ use crate::{panes::PositionAndSize, tests::utils::commands::CLOSE_PANE_IN_PANE_M
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
CLOSE_TAB_IN_TAB_MODE, COMMAND_TOGGLE, ESC, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT,
SPLIT_DOWN_IN_PANE_MODE, SWITCH_NEXT_TAB_IN_TAB_MODE, SWITCH_PREV_TAB_IN_TAB_MODE, TAB_MODE,
CLOSE_TAB_IN_TAB_MODE, NEW_TAB_IN_TAB_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE,
SWITCH_NEXT_TAB_IN_TAB_MODE, SWITCH_PREV_TAB_IN_TAB_MODE, TAB_MODE,
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
};
@ -25,10 +25,8 @@ pub fn open_new_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&QUIT,
@ -56,10 +54,8 @@ pub fn switch_to_prev_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&SWITCH_PREV_TAB_IN_TAB_MODE,
@ -88,10 +84,8 @@ pub fn switch_to_next_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&SWITCH_NEXT_TAB_IN_TAB_MODE,
@ -120,10 +114,8 @@ pub fn close_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&CLOSE_TAB_IN_TAB_MODE,
@ -152,10 +144,8 @@ pub fn close_last_pane_in_a_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&CLOSE_PANE_IN_PANE_MODE,
@ -185,13 +175,10 @@ pub fn close_the_middle_tab() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&SWITCH_PREV_TAB_IN_TAB_MODE,
@ -221,23 +208,17 @@ pub fn close_the_tab_that_has_a_pane_in_fullscreen() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&ESC,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&SWITCH_PREV_TAB_IN_TAB_MODE,
&ESC,
&PANE_MODE,
&TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&CLOSE_TAB_IN_TAB_MODE,
&QUIT,
@ -265,10 +246,8 @@ pub fn closing_last_tab_exits_the_app() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_DOWN_IN_PANE_MODE,
&ESC,
&TAB_MODE,
&NEW_TAB_IN_TAB_MODE,
&CLOSE_TAB_IN_TAB_MODE,

View file

@ -6,8 +6,8 @@ use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots}
use crate::{start, CliArgs};
use crate::tests::utils::commands::{
COMMAND_TOGGLE, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE,
SPLIT_RIGHT_IN_PANE_MODE, TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
};
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
@ -24,7 +24,6 @@ pub fn adding_new_terminal_in_fullscreen() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,
@ -54,7 +53,6 @@ pub fn move_focus_is_disabled_in_fullscreen() {
};
let mut fake_input_output = get_fake_os_input(&fake_win_size);
fake_input_output.add_terminal_input(&[
&COMMAND_TOGGLE,
&PANE_MODE,
&SPLIT_RIGHT_IN_PANE_MODE,
&TOGGLE_ACTIVE_TERMINAL_FULLSCREEN_IN_PANE_MODE,

View file

@ -46,10 +46,10 @@ pub fn get_next_to_last_snapshot(mut snapshots: Vec<String>) -> Option<String> {
pub mod commands {
pub const COMMAND_TOGGLE: [u8; 1] = [7]; // ctrl-g
pub const QUIT: [u8; 1] = [113]; // q
pub const QUIT: [u8; 1] = [17]; // ctrl-q
pub const ESC: [u8; 1] = [27];
pub const PANE_MODE: [u8; 1] = [112]; // p
pub const PANE_MODE: [u8; 1] = [16]; // ctrl-p
pub const SPAWN_TERMINAL_IN_PANE_MODE: [u8; 1] = [110]; // n
pub const MOVE_FOCUS_IN_PANE_MODE: [u8; 1] = [112]; // p
pub const SPLIT_DOWN_IN_PANE_MODE: [u8; 1] = [100]; // d
@ -61,17 +61,17 @@ pub mod commands {
pub const MOVE_FOCUS_LEFT_IN_PANE_MODE: [u8; 1] = [104]; // h
pub const MOVE_FOCUS_RIGHT_IN_PANE_MODE: [u8; 1] = [108]; // l
pub const SCROLL_MODE: [u8; 1] = [115]; // s
pub const SCROLL_MODE: [u8; 1] = [19]; // ctrl-s
pub const SCROLL_UP_IN_SCROLL_MODE: [u8; 1] = [107]; // k
pub const SCROLL_DOWN_IN_SCROLL_MODE: [u8; 1] = [106]; // j
pub const RESIZE_MODE: [u8; 1] = [114]; // r
pub const RESIZE_MODE: [u8; 1] = [18]; // ctrl-r
pub const RESIZE_DOWN_IN_RESIZE_MODE: [u8; 1] = [106]; // j
pub const RESIZE_UP_IN_RESIZE_MODE: [u8; 1] = [107]; // k
pub const RESIZE_LEFT_IN_RESIZE_MODE: [u8; 1] = [104]; // h
pub const RESIZE_RIGHT_IN_RESIZE_MODE: [u8; 1] = [108]; // l
pub const TAB_MODE: [u8; 1] = [116]; // t
pub const TAB_MODE: [u8; 1] = [20]; // ctrl-t
pub const NEW_TAB_IN_TAB_MODE: [u8; 1] = [110]; // n
pub const SWITCH_NEXT_TAB_IN_TAB_MODE: [u8; 1] = [108]; // l
pub const SWITCH_PREV_TAB_IN_TAB_MODE: [u8; 1] = [104]; // h

View file

@ -7,7 +7,8 @@ pub trait ZellijTile {
fn draw(&mut self, rows: usize, cols: usize) {}
fn handle_key(&mut self, key: Key) {}
fn handle_global_key(&mut self, key: Key) {}
fn update_tabs(&mut self, active_tab_index: usize, num_active_tabs: usize) {}
fn update_tabs(&mut self) {}
fn handle_tab_rename_keypress(&mut self, key: Key) {}
}
#[macro_export]
@ -45,11 +46,18 @@ macro_rules! register_tile {
}
#[no_mangle]
pub fn update_tabs(active_tab_index: i32, num_active_tabs: i32) {
pub fn update_tabs() {
STATE.with(|state| {
state.borrow_mut().update_tabs();
})
}
#[no_mangle]
pub fn handle_tab_rename_keypress() {
STATE.with(|state| {
state
.borrow_mut()
.update_tabs(active_tab_index as usize, num_active_tabs as usize);
.handle_tab_rename_keypress($crate::get_key());
})
}
};

View file

@ -34,14 +34,23 @@ pub struct Help {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum InputMode {
Normal,
Command,
Locked,
Resize,
Pane,
Tab,
RenameTab,
Scroll,
Exiting,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct TabData {
/* subset of fields to publish to plugins */
pub position: usize,
pub name: String,
pub active: bool,
}
impl Default for InputMode {
fn default() -> InputMode {
InputMode::Normal
@ -76,6 +85,10 @@ pub fn get_help() -> Help {
deserialize_from_stdin().unwrap_or_default()
}
pub fn get_tabs() -> Vec<TabData> {
deserialize_from_stdin().unwrap_or_default()
}
fn deserialize_from_stdin<T: DeserializeOwned>() -> Option<T> {
let mut json = String::new();
io::stdin().read_line(&mut json).unwrap();