mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-23 08:57:14 +03:00
Merge changes from main
This commit is contained in:
commit
9bc7a268ce
13
Cargo.lock
generated
13
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
BIN
assets/demo.gif
BIN
assets/demo.gif
Binary file not shown.
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 4.4 MiB |
@ -11,5 +11,5 @@ parts:
|
||||
expansion_boundary: true
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Fixed: 1
|
||||
Fixed: 2
|
||||
plugin: status-bar
|
||||
|
@ -1,6 +1,12 @@
|
||||
---
|
||||
direction: Horizontal
|
||||
parts:
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Fixed: 1
|
||||
plugin: tab-bar
|
||||
events:
|
||||
- Tab
|
||||
- direction: Vertical
|
||||
parts:
|
||||
- direction: Horizontal
|
||||
@ -11,5 +17,5 @@ parts:
|
||||
expansion_boundary: true
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Fixed: 1
|
||||
Fixed: 2
|
||||
plugin: status-bar
|
||||
|
@ -7,4 +7,5 @@ license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
colored = "2"
|
||||
zellij-tile = { path = "../../zellij-tile" }
|
||||
ansi_term = "0.12"
|
||||
zellij-tile = { path = "../../zellij-tile" }
|
||||
|
359
default-tiles/status-bar/src/first_line.rs
Normal file
359
default-tiles/status-bar/src/first_line.rs
Normal file
@ -0,0 +1,359 @@
|
||||
use ansi_term::{ANSIStrings, Style};
|
||||
use zellij_tile::prelude::*;
|
||||
|
||||
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),
|
||||
],
|
||||
),
|
||||
}
|
||||
}
|
@ -1,9 +1,25 @@
|
||||
use colored::*;
|
||||
mod first_line;
|
||||
mod second_line;
|
||||
|
||||
use std::fmt::{Display, Error, Formatter};
|
||||
use zellij_tile::prelude::*;
|
||||
|
||||
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 | InputMode::RenameTab => {
|
||||
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 load(&mut self) {
|
||||
set_selectable(false);
|
||||
set_invisible_borders(true);
|
||||
set_max_height(1);
|
||||
set_max_height(2);
|
||||
}
|
||||
|
||||
fn render(&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);
|
||||
}
|
||||
}
|
||||
|
182
default-tiles/status-bar/src/second_line.rs
Normal file
182
default-tiles/status-bar/src/second_line.rs
Normal file
@ -0,0 +1,182 @@
|
||||
// use colored::*;
|
||||
use ansi_term::{ANSIStrings, Style};
|
||||
use zellij_tile::prelude::*;
|
||||
|
||||
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);
|
||||
}
|
@ -7,4 +7,5 @@ license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
colored = "2"
|
||||
ansi_term = "0.12"
|
||||
zellij-tile = { path = "../../zellij-tile" }
|
||||
|
@ -1,4 +1,5 @@
|
||||
use colored::*;
|
||||
use crate::colors::{BLACK, GRAY, ORANGE, WHITE};
|
||||
use ansi_term::{ANSIStrings, Style};
|
||||
|
||||
use crate::{LinePart, ARROW_SEPARATOR};
|
||||
|
||||
@ -58,14 +59,18 @@ fn left_more_message(tab_count_to_the_left: usize) -> LinePart {
|
||||
} else {
|
||||
" ← +many ".to_string()
|
||||
};
|
||||
// 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!(
|
||||
"{}{}",
|
||||
more_text.black().on_yellow(),
|
||||
ARROW_SEPARATOR.yellow().on_black(),
|
||||
"{}",
|
||||
ANSIStrings(&[left_separator, more_styled_text, right_separator,])
|
||||
);
|
||||
LinePart {
|
||||
part: more_styled_text,
|
||||
len: more_text.chars().count() + 1, // 1 for the arrow
|
||||
len: more_text_len,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,15 +86,17 @@ fn right_more_message(tab_count_to_the_right: usize) -> LinePart {
|
||||
} else {
|
||||
" +many → ".to_string()
|
||||
};
|
||||
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!(
|
||||
"{}{}{}",
|
||||
ARROW_SEPARATOR.black().on_yellow(),
|
||||
more_text.black().on_yellow(),
|
||||
ARROW_SEPARATOR.yellow().on_black(),
|
||||
"{}",
|
||||
ANSIStrings(&[left_separator, more_styled_text, right_separator,])
|
||||
);
|
||||
LinePart {
|
||||
part: more_styled_text,
|
||||
len: more_text.chars().count() + 2, // 2 for the arrows
|
||||
len: more_text_len,
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,9 +106,7 @@ fn add_previous_tabs_msg(
|
||||
title_bar: &mut Vec<LinePart>,
|
||||
cols: usize,
|
||||
) {
|
||||
while get_current_title_len(&tabs_to_render) +
|
||||
// get_tabs_before_len(tabs_before_active.len()) >= cols {
|
||||
left_more_message(tabs_before_active.len()).len
|
||||
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));
|
||||
@ -124,6 +129,16 @@ fn add_next_tabs_msg(
|
||||
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,
|
||||
@ -139,11 +154,12 @@ pub fn tab_line(
|
||||
};
|
||||
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,
|
||||
cols - prefix.len,
|
||||
);
|
||||
|
||||
let mut tab_line: Vec<LinePart> = vec![];
|
||||
@ -152,12 +168,13 @@ pub fn tab_line(
|
||||
&mut tabs_before_active,
|
||||
&mut tabs_to_render,
|
||||
&mut tab_line,
|
||||
cols,
|
||||
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);
|
||||
add_next_tabs_msg(&mut tabs_after_active, &mut tab_line, cols - prefix.len);
|
||||
}
|
||||
tab_line.insert(0, prefix);
|
||||
tab_line
|
||||
}
|
||||
|
@ -33,6 +33,17 @@ struct State {
|
||||
|
||||
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);
|
||||
|
||||
impl ZellijTile for State {
|
||||
@ -70,7 +81,7 @@ impl ZellijTile for State {
|
||||
for bar_part in tab_line {
|
||||
s = format!("{}{}", s, bar_part.part);
|
||||
}
|
||||
println!("{}\u{1b}[40m\u{1b}[0K", s);
|
||||
println!("{}\u{1b}[48;5;238m\u{1b}[0K", s);
|
||||
}
|
||||
|
||||
fn update_tabs(&mut self) {
|
||||
@ -85,6 +96,9 @@ impl ZellijTile for State {
|
||||
self.new_name.clear();
|
||||
}
|
||||
Key::Char(c) => self.new_name = format!("{}{}", self.new_name, c),
|
||||
Key::Backspace | Key::Delete => {
|
||||
self.new_name.pop();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +1,54 @@
|
||||
use colored::*;
|
||||
|
||||
use crate::colors::{BLACK, BRIGHT_GRAY, GRAY, GREEN};
|
||||
use crate::{LinePart, ARROW_SEPARATOR};
|
||||
use ansi_term::{ANSIStrings, Style};
|
||||
|
||||
pub fn active_tab(text: String, is_furthest_to_the_left: bool) -> LinePart {
|
||||
let left_separator = if is_furthest_to_the_left {
|
||||
" ".black().on_magenta()
|
||||
} else {
|
||||
ARROW_SEPARATOR.black().on_magenta()
|
||||
};
|
||||
let right_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let tab_styled_text = format!("{} {} {}", left_separator, text, right_separator)
|
||||
.black()
|
||||
.bold()
|
||||
.on_magenta();
|
||||
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: format!("{}", tab_styled_text),
|
||||
part: tab_styled_text,
|
||||
len: tab_text_len,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn non_active_tab(text: String, is_furthest_to_the_left: bool) -> LinePart {
|
||||
let left_separator = if is_furthest_to_the_left {
|
||||
" ".black().on_green()
|
||||
} else {
|
||||
ARROW_SEPARATOR.black().on_green()
|
||||
};
|
||||
let right_separator = ARROW_SEPARATOR.green().on_black();
|
||||
let tab_styled_text = format!("{} {} {}", left_separator, text, right_separator)
|
||||
.black()
|
||||
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()
|
||||
.on_green();
|
||||
let tab_text_len = text.chars().count() + 4; // 2 for the left and right separators, 2 for the text padding
|
||||
.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: format!("{}", tab_styled_text),
|
||||
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() {
|
||||
tab_text = format!("Tab #{}", position + 1);
|
||||
let tab_text = if text.is_empty() {
|
||||
format!("Tab #{}", position + 1)
|
||||
} else {
|
||||
tab_text = text;
|
||||
}
|
||||
text
|
||||
};
|
||||
if is_active_tab {
|
||||
active_tab(tab_text, position == 0)
|
||||
active_tab(tab_text)
|
||||
} else {
|
||||
non_active_tab(tab_text, position == 0)
|
||||
non_active_tab(tab_text)
|
||||
}
|
||||
}
|
||||
|
@ -70,13 +70,11 @@ impl Pane for TerminalPane {
|
||||
fn reset_size_and_position_override(&mut self) {
|
||||
self.position_and_size_override = None;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn change_pos_and_size(&mut self, position_and_size: &PositionAndSize) {
|
||||
self.position_and_size.columns = position_and_size.columns;
|
||||
self.position_and_size.rows = position_and_size.rows;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn override_size_and_position(&mut self, x: usize, y: usize, size: &PositionAndSize) {
|
||||
let position_and_size_override = PositionAndSize {
|
||||
@ -87,7 +85,6 @@ impl Pane for TerminalPane {
|
||||
};
|
||||
self.position_and_size_override = Some(position_and_size_override);
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn handle_event(&mut self, event: VteEvent) {
|
||||
match event {
|
||||
@ -191,12 +188,7 @@ impl Pane for TerminalPane {
|
||||
self.max_height
|
||||
}
|
||||
fn render(&mut self) -> Option<String> {
|
||||
// if self.should_render {
|
||||
if true {
|
||||
// while checking should_render rather than rendering each pane every time
|
||||
// is more performant, it causes some problems when the pane to the left should be
|
||||
// rendered and has wide characters (eg. Chinese characters or emoji)
|
||||
// as a (hopefully) temporary hack, we render all panes until we find a better solution
|
||||
if self.should_render || cfg!(test) {
|
||||
let mut vte_output = String::new();
|
||||
let buffer_lines = &self.read_buffer_as_lines();
|
||||
let display_cols = self.get_columns();
|
||||
@ -205,12 +197,11 @@ impl Pane for TerminalPane {
|
||||
for line_index in 0..self.grid.height {
|
||||
let x = self.get_x();
|
||||
let y = self.get_y();
|
||||
vte_output = format!(
|
||||
"{}\u{1b}[{};{}H\u{1b}[m",
|
||||
vte_output,
|
||||
vte_output.push_str(&format!(
|
||||
"\u{1b}[{};{}H\u{1b}[m",
|
||||
y + line_index + 1,
|
||||
x + 1
|
||||
); // goto row/col and reset styles
|
||||
)); // goto row/col and reset styles
|
||||
for _col_index in 0..self.grid.width {
|
||||
vte_output.push(EMPTY_TERMINAL_CHARACTER.character);
|
||||
}
|
||||
@ -220,7 +211,7 @@ impl Pane for TerminalPane {
|
||||
for (row, line) in buffer_lines.iter().enumerate() {
|
||||
let x = self.get_x();
|
||||
let y = self.get_y();
|
||||
vte_output = format!("{}\u{1b}[{};{}H\u{1b}[m", vte_output, y + row + 1, x + 1); // goto row/col and reset styles
|
||||
vte_output.push_str(&format!("\u{1b}[{};{}H\u{1b}[m", y + row + 1, x + 1)); // goto row/col and reset styles
|
||||
for (col, t_character) in line.iter().enumerate() {
|
||||
if col < display_cols {
|
||||
// in some cases (eg. while resizing) some characters will spill over
|
||||
@ -232,14 +223,14 @@ impl Pane for TerminalPane {
|
||||
// the terminal keeps the previous styles as long as we're in the same
|
||||
// line, so we only want to update the new styles here (this also
|
||||
// includes resetting previous styles as needed)
|
||||
vte_output = format!("{}{}", vte_output, new_styles);
|
||||
vte_output.push_str(&new_styles.to_string());
|
||||
}
|
||||
vte_output.push(t_character.character);
|
||||
}
|
||||
}
|
||||
character_styles.clear();
|
||||
}
|
||||
self.mark_for_rerender();
|
||||
self.should_render = false;
|
||||
Some(vte_output)
|
||||
} else {
|
||||
None
|
||||
@ -252,45 +243,37 @@ impl Pane for TerminalPane {
|
||||
self.position_and_size.y += count;
|
||||
self.position_and_size.rows -= count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn increase_height_down(&mut self, count: usize) {
|
||||
self.position_and_size.rows += count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn increase_height_up(&mut self, count: usize) {
|
||||
self.position_and_size.y -= count;
|
||||
self.position_and_size.rows += count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn reduce_height_up(&mut self, count: usize) {
|
||||
self.position_and_size.rows -= count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn reduce_width_right(&mut self, count: usize) {
|
||||
self.position_and_size.x += count;
|
||||
self.position_and_size.columns -= count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn reduce_width_left(&mut self, count: usize) {
|
||||
self.position_and_size.columns -= count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn increase_width_left(&mut self, count: usize) {
|
||||
self.position_and_size.x -= count;
|
||||
self.position_and_size.columns += count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn increase_width_right(&mut self, count: usize) {
|
||||
self.position_and_size.columns += count;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
fn scroll_up(&mut self, count: usize) {
|
||||
self.grid.move_viewport_up(count);
|
||||
|
@ -1670,7 +1670,6 @@ impl Tab {
|
||||
} else if self.can_reduce_pane_and_surroundings_right(&active_pane_id, count) {
|
||||
self.reduce_pane_and_surroundings_right(&active_pane_id, count);
|
||||
}
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn resize_left(&mut self) {
|
||||
@ -1682,7 +1681,6 @@ impl Tab {
|
||||
} else if self.can_reduce_pane_and_surroundings_left(&active_pane_id, count) {
|
||||
self.reduce_pane_and_surroundings_left(&active_pane_id, count);
|
||||
}
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn resize_down(&mut self) {
|
||||
@ -1694,7 +1692,6 @@ impl Tab {
|
||||
} else if self.can_reduce_pane_and_surroundings_down(&active_pane_id, count) {
|
||||
self.reduce_pane_and_surroundings_down(&active_pane_id, count);
|
||||
}
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn resize_up(&mut self) {
|
||||
@ -1706,7 +1703,6 @@ impl Tab {
|
||||
} else if self.can_reduce_pane_and_surroundings_up(&active_pane_id, count) {
|
||||
self.reduce_pane_and_surroundings_up(&active_pane_id, count);
|
||||
}
|
||||
self.render();
|
||||
}
|
||||
}
|
||||
pub fn move_focus(&mut self) {
|
||||
|
@ -271,12 +271,7 @@ impl InputHandler {
|
||||
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()));
|
||||
}
|
||||
@ -284,8 +279,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()));
|
||||
}
|
||||
@ -302,8 +297,6 @@ pub fn get_help(mode: InputMode) -> Help {
|
||||
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 }
|
||||
}
|
||||
|
||||
|
@ -31,28 +31,52 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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)]);
|
||||
@ -62,20 +86,36 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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)]);
|
||||
@ -86,11 +126,6 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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))]);
|
||||
@ -99,17 +134,37 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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]);
|
||||
@ -120,11 +175,6 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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]);
|
||||
|
||||
@ -143,24 +193,38 @@ fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
|
||||
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]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
|
||||
}
|
||||
InputMode::RenameTab => {
|
||||
defaults.insert(
|
||||
@ -201,7 +265,7 @@ pub fn key_to_actions(
|
||||
.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),
|
||||
}
|
||||
|
@ -293,6 +293,10 @@ impl Screen {
|
||||
self.update_tabs();
|
||||
self.render();
|
||||
}
|
||||
"\u{007F}" | "\u{0008}" => {
|
||||
//delete and backspace keys
|
||||
self.tabname_buf.pop();
|
||||
}
|
||||
c => {
|
||||
self.tabname_buf.push_str(c);
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ use std::time::{Duration, Instant};
|
||||
use crate::os_input_output::OsApi;
|
||||
use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes};
|
||||
|
||||
use crate::tests::utils::commands::SLEEP;
|
||||
|
||||
const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(50);
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -189,11 +191,16 @@ impl OsApi for FakeInputOutput {
|
||||
::std::thread::sleep(MIN_TIME_BETWEEN_SNAPSHOTS - last_snapshot_time.elapsed());
|
||||
}
|
||||
}
|
||||
self.stdin_commands
|
||||
let command = self
|
||||
.stdin_commands
|
||||
.lock()
|
||||
.unwrap()
|
||||
.pop_front()
|
||||
.unwrap_or(vec![])
|
||||
.unwrap_or(vec![]);
|
||||
if command == SLEEP {
|
||||
std::thread::sleep(std::time::Duration::from_millis(200));
|
||||
}
|
||||
command
|
||||
}
|
||||
fn get_stdout_writer(&self) -> Box<dyn Write> {
|
||||
Box::new(self.stdout_writer.clone())
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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, SLEEP, 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};
|
||||
@ -24,9 +24,9 @@ pub fn new_panes_are_open_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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
let mut opts = CliArgs::default();
|
||||
@ -56,12 +56,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
let mut opts = CliArgs::default();
|
||||
@ -91,10 +90,10 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
let mut opts = CliArgs::default();
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -6,8 +6,9 @@ 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,
|
||||
RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE,
|
||||
RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, SLEEP, SPLIT_DOWN_IN_PANE_MODE,
|
||||
SPLIT_RIGHT_IN_PANE_MODE,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
@ -33,12 +34,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -72,13 +72,12 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -115,15 +114,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -158,16 +156,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -203,7 +200,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,9 +208,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -250,7 +246,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,9 +253,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -296,15 +291,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -340,16 +334,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -385,7 +378,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,9 +387,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -433,7 +425,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,9 +436,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -483,17 +474,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,11 +500,11 @@ 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,
|
||||
&RESIZE_DOWN_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -552,17 +540,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,11 +568,11 @@ 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,
|
||||
&RESIZE_DOWN_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -620,12 +605,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
|
@ -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, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
@ -30,12 +30,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -67,13 +66,12 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -105,15 +103,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -146,16 +143,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -189,7 +185,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,9 +193,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -234,15 +229,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -276,7 +270,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,9 +277,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -320,16 +313,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -365,7 +357,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,9 +366,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -413,7 +404,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,9 +415,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -463,17 +453,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,11 +479,11 @@ 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,
|
||||
&RESIZE_LEFT_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -533,17 +520,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,11 +548,11 @@ 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,
|
||||
&RESIZE_LEFT_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -601,12 +585,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
|
@ -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, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
@ -31,12 +30,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -68,13 +66,12 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -106,15 +103,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -147,16 +143,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -190,7 +185,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,9 +193,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -235,15 +229,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -277,7 +270,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,9 +277,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -321,16 +313,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -366,7 +357,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,9 +366,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -414,7 +404,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,9 +415,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -464,17 +453,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,11 +479,11 @@ 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,
|
||||
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -533,17 +519,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,11 +547,11 @@ 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,
|
||||
&RESIZE_RIGHT_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -601,12 +584,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
|
@ -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, SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
@ -32,12 +32,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -71,13 +70,12 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -114,15 +112,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
@ -156,16 +153,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -199,7 +195,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,9 +203,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -246,7 +241,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,9 +248,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -292,15 +286,14 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -336,16 +329,15 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -381,7 +373,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,9 +382,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -429,7 +420,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,9 +431,9 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -479,17 +469,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,11 +495,11 @@ 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,
|
||||
&RESIZE_UP_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -548,17 +535,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,11 +563,11 @@ 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,
|
||||
&RESIZE_UP_IN_RESIZE_MODE,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
|
||||
@ -616,12 +600,11 @@ 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,
|
||||
&SLEEP,
|
||||
&QUIT,
|
||||
]);
|
||||
start(Box::new(fake_input_output.clone()), CliArgs::default());
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,19 +61,20 @@ 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
|
||||
pub const CLOSE_TAB_IN_TAB_MODE: [u8; 1] = [120]; // x
|
||||
pub const SLEEP: [u8; 0] = [];
|
||||
}
|
||||
|
@ -35,13 +35,12 @@ pub enum Event {
|
||||
/// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user