Merge branch 'main' into focused-pane
This commit is contained in:
commit
448c426c2b
42 changed files with 1193 additions and 702 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1503,6 +1503,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||
name = "status-bar"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"colored",
|
||||
"zellij-tile",
|
||||
]
|
||||
|
|
@ -1594,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 |
|
|
@ -5,9 +5,11 @@ parts:
|
|||
split_size:
|
||||
Fixed: 1
|
||||
plugin: tab-bar
|
||||
events:
|
||||
- Tab
|
||||
- direction: Vertical
|
||||
expansion_boundary: true
|
||||
- direction: Vertical
|
||||
split_size:
|
||||
Fixed: 1
|
||||
Fixed: 2
|
||||
plugin: status-bar
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ total=6
|
|||
|
||||
echo "Building zellij-tile (1/$total)..."
|
||||
cd zellij-tile
|
||||
cargo build --release --target-dir ../../target
|
||||
cargo build --release --target-dir ../target
|
||||
|
||||
echo "Building status-bar (2/$total)..."
|
||||
cd ../default-tiles/status-bar
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ license = "MIT"
|
|||
|
||||
[dependencies]
|
||||
colored = "2"
|
||||
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::*;
|
||||
|
||||
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::*;
|
||||
|
||||
use first_line::{ctrl_keys, superkey};
|
||||
use second_line::keybinds;
|
||||
|
||||
pub mod colors {
|
||||
use ansi_term::Colour::{self, Fixed};
|
||||
pub const WHITE: Colour = Fixed(255);
|
||||
pub const BLACK: Colour = Fixed(16);
|
||||
pub const GREEN: Colour = Fixed(154);
|
||||
pub const ORANGE: Colour = Fixed(166);
|
||||
pub const GRAY: Colour = Fixed(238);
|
||||
pub const BRIGHT_GRAY: Colour = Fixed(245);
|
||||
pub const RED: Colour = Fixed(88);
|
||||
}
|
||||
|
||||
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
|
||||
static ARROW_SEPARATOR: &str = " ";
|
||||
static ARROW_SEPARATOR: &str = "";
|
||||
static MORE_MSG: &str = " ... ";
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -11,7 +27,8 @@ struct State {}
|
|||
|
||||
register_tile!(State);
|
||||
|
||||
struct LinePart {
|
||||
#[derive(Default)]
|
||||
pub struct LinePart {
|
||||
part: String,
|
||||
len: usize,
|
||||
}
|
||||
|
|
@ -22,240 +39,24 @@ impl Display for LinePart {
|
|||
}
|
||||
}
|
||||
|
||||
fn prefix(help: &Help) -> LinePart {
|
||||
let prefix_text = " Zellij ";
|
||||
let part = match &help.mode {
|
||||
InputMode::Command => {
|
||||
let prefix = prefix_text.bold().white().on_black();
|
||||
let separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
format!("{}{}", prefix, separator)
|
||||
}
|
||||
InputMode::Normal => {
|
||||
let prefix = prefix_text.bold().white().on_black();
|
||||
let separator = ARROW_SEPARATOR.black().on_green();
|
||||
format!("{}{}", prefix, separator)
|
||||
}
|
||||
_ => {
|
||||
let prefix = prefix_text.bold().white().on_black();
|
||||
let separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
format!("{}{}", prefix, separator)
|
||||
}
|
||||
};
|
||||
let len = prefix_text.chars().count() + ARROW_SEPARATOR.chars().count();
|
||||
LinePart { part, len }
|
||||
}
|
||||
|
||||
fn key_path(help: &Help) -> LinePart {
|
||||
let superkey_text = "<Ctrl-g> ";
|
||||
let (part, len) = match &help.mode {
|
||||
InputMode::Command => {
|
||||
let key_path = superkey_text.bold().on_magenta();
|
||||
let first_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let len = superkey_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count();
|
||||
(format!("{}{}", key_path, first_separator), len)
|
||||
}
|
||||
InputMode::Resize => {
|
||||
let mode_shortcut_text = "r ";
|
||||
let superkey = superkey_text.bold().on_magenta();
|
||||
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
|
||||
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let len = superkey_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ mode_shortcut_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count();
|
||||
(
|
||||
format!(
|
||||
"{}{}{}{}{}",
|
||||
superkey,
|
||||
first_superkey_separator,
|
||||
second_superkey_separator,
|
||||
mode_shortcut,
|
||||
mode_shortcut_separator
|
||||
),
|
||||
len,
|
||||
)
|
||||
}
|
||||
InputMode::Pane => {
|
||||
let mode_shortcut_text = "p ";
|
||||
let superkey = superkey_text.bold().on_magenta();
|
||||
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
|
||||
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let len = superkey_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ mode_shortcut_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count();
|
||||
(
|
||||
format!(
|
||||
"{}{}{}{}{}",
|
||||
superkey,
|
||||
first_superkey_separator,
|
||||
second_superkey_separator,
|
||||
mode_shortcut,
|
||||
mode_shortcut_separator
|
||||
),
|
||||
len,
|
||||
)
|
||||
}
|
||||
InputMode::Tab => {
|
||||
let mode_shortcut_text = "t ";
|
||||
let superkey = superkey_text.bold().on_magenta();
|
||||
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
|
||||
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let len = superkey_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ mode_shortcut_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count();
|
||||
(
|
||||
format!(
|
||||
"{}{}{}{}{}",
|
||||
superkey,
|
||||
first_superkey_separator,
|
||||
second_superkey_separator,
|
||||
mode_shortcut,
|
||||
mode_shortcut_separator
|
||||
),
|
||||
len,
|
||||
)
|
||||
}
|
||||
InputMode::Scroll => {
|
||||
let mode_shortcut_text = "s ";
|
||||
let superkey = superkey_text.bold().on_magenta();
|
||||
let first_superkey_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
|
||||
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
|
||||
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
|
||||
let len = superkey_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count()
|
||||
+ mode_shortcut_text.chars().count()
|
||||
+ ARROW_SEPARATOR.chars().count();
|
||||
(
|
||||
format!(
|
||||
"{}{}{}{}{}",
|
||||
superkey,
|
||||
first_superkey_separator,
|
||||
second_superkey_separator,
|
||||
mode_shortcut,
|
||||
mode_shortcut_separator
|
||||
),
|
||||
len,
|
||||
)
|
||||
}
|
||||
InputMode::Normal | _ => {
|
||||
let key_path = superkey_text.on_green();
|
||||
let separator = ARROW_SEPARATOR.green().on_black();
|
||||
(
|
||||
format!("{}{}", key_path, separator),
|
||||
superkey_text.chars().count() + ARROW_SEPARATOR.chars().count(),
|
||||
)
|
||||
}
|
||||
};
|
||||
LinePart { part, len }
|
||||
}
|
||||
|
||||
fn keybinds(help: &Help, max_width: usize) -> LinePart {
|
||||
let mut keybinds = String::new();
|
||||
let mut len = 0;
|
||||
let full_keybinds_len =
|
||||
help.keybinds
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(0, |acc, (i, (shortcut, description))| {
|
||||
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
|
||||
let description_length = description.chars().count() + 2;
|
||||
let (_separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
|
||||
acc + shortcut_length + description_length + separator_len
|
||||
});
|
||||
if full_keybinds_len < max_width {
|
||||
for (i, (shortcut, description)) in help.keybinds.iter().enumerate() {
|
||||
let separator = if i > 0 { " / " } else { "" };
|
||||
let shortcut_len = shortcut.chars().count();
|
||||
let shortcut = match help.mode {
|
||||
InputMode::Normal => shortcut.cyan(),
|
||||
_ => shortcut.white().bold(),
|
||||
};
|
||||
keybinds = format!("{}{}<{}> {}", keybinds, separator, shortcut, description);
|
||||
len += shortcut_len + separator.chars().count();
|
||||
}
|
||||
} else {
|
||||
for (i, (shortcut, description)) in help.keybinds.iter().enumerate() {
|
||||
let description_first_word = description.split(' ').next().unwrap_or("");
|
||||
let current_length = keybinds.chars().count();
|
||||
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
|
||||
let description_first_word_length = description_first_word.chars().count();
|
||||
let (separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
|
||||
let shortcut = match help.mode {
|
||||
InputMode::Normal => shortcut.cyan(),
|
||||
_ => shortcut.white().bold(),
|
||||
};
|
||||
if current_length
|
||||
+ shortcut_length
|
||||
+ description_first_word_length
|
||||
+ separator_len
|
||||
+ MORE_MSG.chars().count()
|
||||
< max_width
|
||||
{
|
||||
keybinds = format!(
|
||||
"{}{}<{}> {}",
|
||||
keybinds, separator, shortcut, description_first_word
|
||||
);
|
||||
len += shortcut_length + description_first_word_length + separator_len;
|
||||
} else if current_length + shortcut_length + separator_len + MORE_MSG.chars().count()
|
||||
< max_width
|
||||
{
|
||||
keybinds = format!("{}{}<{}>", keybinds, separator, shortcut);
|
||||
len += shortcut_length + separator_len;
|
||||
} else {
|
||||
keybinds = format!("{}{}", keybinds, MORE_MSG);
|
||||
len += MORE_MSG.chars().count();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
LinePart {
|
||||
part: keybinds,
|
||||
len,
|
||||
}
|
||||
}
|
||||
|
||||
impl ZellijTile for State {
|
||||
fn init(&mut self) {
|
||||
set_selectable(false);
|
||||
set_invisible_borders(true);
|
||||
set_max_height(1);
|
||||
set_max_height(2);
|
||||
}
|
||||
|
||||
fn draw(&mut self, _rows: usize, cols: usize) {
|
||||
let help = get_help();
|
||||
let line_prefix = prefix(&help);
|
||||
let key_path = key_path(&help);
|
||||
let line_len_before_keybinds = line_prefix.len + key_path.len;
|
||||
let status_bar = if line_len_before_keybinds + MORE_MSG.chars().count() < cols {
|
||||
let keybinds = keybinds(&help, cols - line_len_before_keybinds);
|
||||
let keybinds = keybinds.part.cyan().on_black();
|
||||
format!("{}{}{}", line_prefix, key_path, keybinds)
|
||||
} else if line_len_before_keybinds < cols {
|
||||
format!("{}{}", line_prefix, key_path)
|
||||
} else if line_prefix.len < cols {
|
||||
format!("{}", line_prefix)
|
||||
} else {
|
||||
// sorry, too small :(
|
||||
format!("")
|
||||
};
|
||||
// 40m is black background, 0K is so that it fills the rest of the line,
|
||||
// I could not find a way to do this with colored and did not want to have to
|
||||
// manually fill the line with spaces to achieve the same
|
||||
println!("{}\u{1b}[40m\u{1b}[0K", status_bar);
|
||||
let superkey = superkey();
|
||||
let ctrl_keys = ctrl_keys(&help, cols - superkey.len);
|
||||
|
||||
let first_line = format!("{}{}", superkey, ctrl_keys);
|
||||
let second_line = keybinds(&help, cols);
|
||||
|
||||
// [48;5;238m is gray background, [0K is so that it fills the rest of the line
|
||||
// [48;5;16m is black background, [0K is so that it fills the rest of the line
|
||||
println!("{}\u{1b}[48;5;238m\u{1b}[0K", first_line);
|
||||
println!("{}\u{1b}[48;5;16m\u{1b}[0K", second_line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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::*;
|
||||
|
||||
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 {
|
||||
format!(" ← +many ")
|
||||
};
|
||||
// 238
|
||||
let more_text_len = more_text.chars().count() + 2; // 2 for the arrows
|
||||
let left_separator = Style::new().fg(GRAY).on(ORANGE).paint(ARROW_SEPARATOR);
|
||||
let more_styled_text = Style::new().fg(BLACK).on(ORANGE).bold().paint(more_text);
|
||||
let right_separator = Style::new().fg(ORANGE).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
let more_styled_text = format!(
|
||||
"{}{}",
|
||||
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 {
|
||||
format!(" +many → ")
|
||||
};
|
||||
let more_text_len = more_text.chars().count() + 1; // 2 for the arrow
|
||||
let left_separator = Style::new().fg(GRAY).on(ORANGE).paint(ARROW_SEPARATOR);
|
||||
let more_styled_text = Style::new().fg(BLACK).on(ORANGE).bold().paint(more_text);
|
||||
let right_separator = Style::new().fg(ORANGE).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
let more_styled_text = format!(
|
||||
"{}{}{}",
|
||||
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));
|
||||
|
|
@ -115,9 +120,7 @@ fn add_next_tabs_msg(
|
|||
title_bar: &mut Vec<LinePart>,
|
||||
cols: usize,
|
||||
) {
|
||||
while get_current_title_len(&title_bar) +
|
||||
// get_tabs_after_len(tabs_after_active.len()) >= cols {
|
||||
right_more_message(tabs_after_active.len()).len
|
||||
while get_current_title_len(&title_bar) + right_more_message(tabs_after_active.len()).len
|
||||
>= cols
|
||||
{
|
||||
tabs_after_active.insert(0, title_bar.pop().unwrap());
|
||||
|
|
@ -126,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,
|
||||
|
|
@ -141,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![];
|
||||
|
|
@ -154,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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ mod tab;
|
|||
use zellij_tile::*;
|
||||
|
||||
use crate::line::tab_line;
|
||||
use crate::tab::nameless_tab;
|
||||
use crate::tab::tab_style;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LinePart {
|
||||
|
|
@ -12,14 +12,40 @@ pub struct LinePart {
|
|||
len: usize,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum BarMode {
|
||||
Normal,
|
||||
Rename,
|
||||
}
|
||||
|
||||
impl Default for BarMode {
|
||||
fn default() -> Self {
|
||||
BarMode::Normal
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct State {
|
||||
active_tab_index: usize,
|
||||
num_tabs: usize,
|
||||
tabs: Vec<TabData>,
|
||||
mode: BarMode,
|
||||
new_name: String,
|
||||
}
|
||||
|
||||
static ARROW_SEPARATOR: &str = "";
|
||||
|
||||
pub mod colors {
|
||||
use ansi_term::Colour::{self, Fixed};
|
||||
pub const WHITE: Colour = Fixed(255);
|
||||
pub const BLACK: Colour = Fixed(16);
|
||||
pub const GREEN: Colour = Fixed(154);
|
||||
pub const ORANGE: Colour = Fixed(166);
|
||||
pub const GRAY: Colour = Fixed(238);
|
||||
pub const BRIGHT_GRAY: Colour = Fixed(245);
|
||||
pub const RED: Colour = Fixed(88);
|
||||
}
|
||||
|
||||
register_tile!(State);
|
||||
|
||||
impl ZellijTile for State {
|
||||
|
|
@ -29,29 +55,55 @@ impl ZellijTile for State {
|
|||
set_max_height(1);
|
||||
self.active_tab_index = 0;
|
||||
self.num_tabs = 0;
|
||||
self.mode = BarMode::Normal;
|
||||
self.new_name = String::new();
|
||||
}
|
||||
|
||||
fn draw(&mut self, _rows: usize, cols: usize) {
|
||||
if self.num_tabs == 0 {
|
||||
if self.tabs.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut all_tabs: Vec<LinePart> = vec![];
|
||||
for i in 0..self.num_tabs {
|
||||
let tab = nameless_tab(i, i == self.active_tab_index);
|
||||
let mut active_tab_index = 0;
|
||||
for t in self.tabs.iter_mut() {
|
||||
let mut tabname = t.name.clone();
|
||||
if t.active && self.mode == BarMode::Rename {
|
||||
if self.new_name.is_empty() {
|
||||
tabname = String::from("Enter name...");
|
||||
} else {
|
||||
tabname = self.new_name.clone();
|
||||
}
|
||||
active_tab_index = t.position;
|
||||
} else if t.active {
|
||||
active_tab_index = t.position;
|
||||
}
|
||||
let tab = tab_style(tabname, t.active, t.position);
|
||||
all_tabs.push(tab);
|
||||
}
|
||||
|
||||
let tab_line = tab_line(all_tabs, self.active_tab_index, cols);
|
||||
|
||||
let tab_line = tab_line(all_tabs, active_tab_index, cols);
|
||||
let mut s = String::new();
|
||||
for bar_part in tab_line {
|
||||
s = format!("{}{}", s, bar_part.part);
|
||||
}
|
||||
println!("{}\u{1b}[40m\u{1b}[0K", s);
|
||||
println!("{}\u{1b}[48;5;238m\u{1b}[0K", s);
|
||||
}
|
||||
|
||||
fn update_tabs(&mut self, active_tab_index: usize, num_tabs: usize) {
|
||||
self.active_tab_index = active_tab_index;
|
||||
self.num_tabs = num_tabs;
|
||||
fn update_tabs(&mut self) {
|
||||
self.tabs = get_tabs();
|
||||
}
|
||||
|
||||
fn handle_tab_rename_keypress(&mut self, key: Key) {
|
||||
self.mode = BarMode::Rename;
|
||||
match key {
|
||||
Key::Char('\n') | Key::Esc => {
|
||||
self.mode = BarMode::Normal;
|
||||
self.new_name.clear();
|
||||
}
|
||||
Key::Char(c) => self.new_name = format!("{}{}", self.new_name, c),
|
||||
Key::Backspace | Key::Delete => {
|
||||
self.new_name.pop();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +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()
|
||||
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()
|
||||
.on_magenta();
|
||||
let tab_text_len = text.chars().count() + 2; // 2 for left and right separators
|
||||
.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() + 2; // 2 for the left and right separators
|
||||
.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(text: String, is_active_tab: bool, is_furthest_to_the_left: bool) -> LinePart {
|
||||
pub fn tab_style(text: String, is_active_tab: bool, position: usize) -> LinePart {
|
||||
let tab_text = if text.is_empty() {
|
||||
format!("Tab #{}", position + 1)
|
||||
} else {
|
||||
text
|
||||
};
|
||||
if is_active_tab {
|
||||
active_tab(text, is_furthest_to_the_left)
|
||||
active_tab(tab_text)
|
||||
} else {
|
||||
non_active_tab(text, is_furthest_to_the_left)
|
||||
non_active_tab(tab_text)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn nameless_tab(index: usize, is_active_tab: bool) -> LinePart {
|
||||
let tab_text = format!(" Tab #{} ", index + 1);
|
||||
tab(tab_text, is_active_tab, index == 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::{fs::File, io::prelude::*};
|
||||
|
||||
use crate::common::wasm_vm::EventType;
|
||||
use crate::panes::PositionAndSize;
|
||||
|
||||
fn split_space_to_parts_vertically(
|
||||
|
|
@ -180,6 +181,8 @@ pub struct Layout {
|
|||
pub plugin: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub expansion_boundary: bool,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub events: Vec<EventType>,
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
//! as well as how they should be resized
|
||||
|
||||
use crate::common::{AppInstruction, SenderWithContext};
|
||||
use crate::layout::Layout;
|
||||
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
|
||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||
use crate::wasm_vm::{PluginInputType, PluginInstruction};
|
||||
use crate::{boundaries::Boundaries, panes::PluginPane};
|
||||
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
||||
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
|
|
@ -51,6 +53,7 @@ fn split_horizontally_with_gap(rect: &PositionAndSize) -> (PositionAndSize, Posi
|
|||
pub struct Tab {
|
||||
pub index: usize,
|
||||
pub position: usize,
|
||||
pub name: String,
|
||||
panes: BTreeMap<PaneId, Box<dyn Pane>>,
|
||||
panes_to_hide: HashSet<PaneId>,
|
||||
active_terminal: Option<PaneId>,
|
||||
|
|
@ -64,6 +67,14 @@ pub struct Tab {
|
|||
expansion_boundary: Option<PositionAndSize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct TabData {
|
||||
/* subset of fields to publish to plugins */
|
||||
pub position: usize,
|
||||
pub name: String,
|
||||
pub active: bool,
|
||||
}
|
||||
|
||||
// FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication
|
||||
pub trait Pane {
|
||||
fn x(&self) -> usize;
|
||||
|
|
@ -170,6 +181,7 @@ impl Tab {
|
|||
pub fn new(
|
||||
index: usize,
|
||||
position: usize,
|
||||
name: String,
|
||||
full_screen_ws: &PositionAndSize,
|
||||
mut os_api: Box<dyn OsApi>,
|
||||
send_pty_instructions: SenderWithContext<PtyInstruction>,
|
||||
|
|
@ -195,6 +207,7 @@ impl Tab {
|
|||
index,
|
||||
position,
|
||||
panes,
|
||||
name,
|
||||
max_panes,
|
||||
panes_to_hide: HashSet::new(),
|
||||
active_terminal: pane_id,
|
||||
|
|
@ -249,7 +262,11 @@ impl Tab {
|
|||
if let Some(plugin) = &layout.plugin {
|
||||
let (pid_tx, pid_rx) = channel();
|
||||
self.send_plugin_instructions
|
||||
.send(PluginInstruction::Load(pid_tx, plugin.clone()))
|
||||
.send(PluginInstruction::Load(
|
||||
pid_tx,
|
||||
plugin.clone(),
|
||||
layout.events.clone(),
|
||||
))
|
||||
.unwrap();
|
||||
let pid = pid_rx.recv().unwrap();
|
||||
let new_plugin = PluginPane::new(
|
||||
|
|
@ -546,7 +563,10 @@ impl Tab {
|
|||
}
|
||||
Some(PaneId::Plugin(pid)) => {
|
||||
self.send_plugin_instructions
|
||||
.send(PluginInstruction::Input(pid, input_bytes))
|
||||
.send(PluginInstruction::Input(
|
||||
PluginInputType::Normal(pid),
|
||||
input_bytes,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -1662,7 +1682,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) {
|
||||
|
|
@ -1674,7 +1693,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) {
|
||||
|
|
@ -1686,7 +1704,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) {
|
||||
|
|
@ -1698,7 +1715,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) {
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ pub enum ScreenContext {
|
|||
SwitchTabPrev,
|
||||
CloseTab,
|
||||
GoToTab,
|
||||
UpdateTabName,
|
||||
}
|
||||
|
||||
impl From<&ScreenInstruction> for ScreenContext {
|
||||
|
|
@ -236,6 +237,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
|||
ScreenInstruction::SwitchTabPrev => ScreenContext::SwitchTabPrev,
|
||||
ScreenInstruction::CloseTab => ScreenContext::CloseTab,
|
||||
ScreenInstruction::GoToTab(_) => ScreenContext::GoToTab,
|
||||
ScreenInstruction::UpdateTabName(_) => ScreenContext::UpdateTabName,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,6 @@ pub enum Action {
|
|||
/// Close the current tab.
|
||||
CloseTab,
|
||||
GoToTab(u32),
|
||||
TabNameInput(Vec<u8>),
|
||||
SaveTabName,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::errors::ContextType;
|
|||
use crate::os_input_output::OsApi;
|
||||
use crate::pty_bus::PtyInstruction;
|
||||
use crate::screen::ScreenInstruction;
|
||||
use crate::wasm_vm::PluginInstruction;
|
||||
use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction};
|
||||
use crate::CommandIsExecuting;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -232,6 +232,28 @@ impl InputHandler {
|
|||
.send(ScreenInstruction::GoToTab(i))
|
||||
.unwrap();
|
||||
}
|
||||
Action::TabNameInput(c) => {
|
||||
self.send_plugin_instructions
|
||||
.send(PluginInstruction::Input(
|
||||
PluginInputType::Event(EventType::Tab),
|
||||
c.clone(),
|
||||
))
|
||||
.unwrap();
|
||||
self.send_screen_instructions
|
||||
.send(ScreenInstruction::UpdateTabName(c))
|
||||
.unwrap();
|
||||
}
|
||||
Action::SaveTabName => {
|
||||
self.send_plugin_instructions
|
||||
.send(PluginInstruction::Input(
|
||||
PluginInputType::Event(EventType::Tab),
|
||||
vec![b'\n'],
|
||||
))
|
||||
.unwrap();
|
||||
self.send_screen_instructions
|
||||
.send(ScreenInstruction::UpdateTabName(vec![b'\n']))
|
||||
.unwrap();
|
||||
}
|
||||
Action::NoOp => {}
|
||||
}
|
||||
|
||||
|
|
@ -250,13 +272,12 @@ impl InputHandler {
|
|||
/// Describes the different input modes, which change the way that keystrokes will be interpreted.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)]
|
||||
pub enum InputMode {
|
||||
/// In `Normal` mode, input is always written to the terminal, except for one special input that
|
||||
/// triggers the switch to [`InputMode::Command`] mode.
|
||||
/// In `Normal` mode, input is always written to the terminal, except for the shortcuts leading
|
||||
/// to other modes
|
||||
Normal,
|
||||
/// In `Command` mode, input is bound to actions (more precisely, sequences of actions).
|
||||
/// `Command` mode gives access to the other modes non-`InputMode::Normal` modes.
|
||||
/// etc.
|
||||
Command,
|
||||
/// In `Locked` mode, input is always written to the terminal and all shortcuts are disabled
|
||||
/// except the one leading back to normal mode
|
||||
Locked,
|
||||
/// `Resize` mode allows resizing the different existing panes.
|
||||
Resize,
|
||||
/// `Pane` mode allows creating and closing panes, as well as moving between them.
|
||||
|
|
@ -265,6 +286,7 @@ pub enum InputMode {
|
|||
Tab,
|
||||
/// `Scroll` mode allows scrolling up and down within a pane.
|
||||
Scroll,
|
||||
RenameTab,
|
||||
}
|
||||
|
||||
/// Represents the contents of the help message that is printed in the status bar,
|
||||
|
|
@ -288,12 +310,7 @@ impl Default for InputMode {
|
|||
pub fn get_help(mode: InputMode) -> Help {
|
||||
let mut keybinds: Vec<(String, String)> = vec![];
|
||||
match mode {
|
||||
InputMode::Normal | InputMode::Command => {
|
||||
keybinds.push(("p".to_string(), "PANE".to_string()));
|
||||
keybinds.push(("t".to_string(), "TAB".to_string()));
|
||||
keybinds.push(("r".to_string(), "RESIZE".to_string()));
|
||||
keybinds.push(("s".to_string(), "SCROLL".to_string()));
|
||||
}
|
||||
InputMode::Normal | InputMode::Locked => {}
|
||||
InputMode::Resize => {
|
||||
keybinds.push(("←↓↑→".to_string(), "Resize".to_string()));
|
||||
}
|
||||
|
|
@ -301,8 +318,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()));
|
||||
}
|
||||
|
|
@ -310,13 +327,15 @@ pub fn get_help(mode: InputMode) -> Help {
|
|||
keybinds.push(("←↓↑→".to_string(), "Move focus".to_string()));
|
||||
keybinds.push(("n".to_string(), "New".to_string()));
|
||||
keybinds.push(("x".to_string(), "Close".to_string()));
|
||||
keybinds.push(("r".to_string(), "Rename".to_string()));
|
||||
}
|
||||
InputMode::Scroll => {
|
||||
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
|
||||
}
|
||||
InputMode::RenameTab => {
|
||||
keybinds.push(("Enter".to_string(), "when done".to_string()));
|
||||
}
|
||||
}
|
||||
keybinds.push(("ESC".to_string(), "BACK".to_string()));
|
||||
keybinds.push(("q".to_string(), "QUIT".to_string()));
|
||||
Help { mode, keybinds }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,28 +31,52 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> {
|
|||
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) -> Result<ModeKeybinds, String> {
|
|||
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) -> Result<ModeKeybinds, String> {
|
|||
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) -> Result<ModeKeybinds, String> {
|
|||
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,14 +175,16 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> {
|
|||
defaults.insert(Key::Up, vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Right, vec![Action::GoToNextTab]);
|
||||
|
||||
defaults.insert(Key::Ctrl('b'), vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Ctrl('n'), vec![Action::GoToNextTab]);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::GoToPreviousTab]);
|
||||
defaults.insert(Key::Ctrl('f'), vec![Action::GoToNextTab]);
|
||||
|
||||
defaults.insert(Key::Char('n'), vec![Action::NewTab]);
|
||||
defaults.insert(Key::Char('x'), vec![Action::CloseTab]);
|
||||
|
||||
defaults.insert(
|
||||
Key::Char('r'),
|
||||
vec![
|
||||
Action::SwitchToMode(InputMode::RenameTab),
|
||||
Action::TabNameInput(vec![0]),
|
||||
],
|
||||
);
|
||||
defaults.insert(Key::Char('q'), vec![Action::Quit]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
|
|
@ -136,24 +193,55 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> {
|
|||
for i in '1'..='9' {
|
||||
defaults.insert(Key::Char(i), vec![Action::GoToTab(i.to_digit(10).unwrap())]);
|
||||
}
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
|
||||
}
|
||||
InputMode::Scroll => {
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Locked)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::SwitchToMode(InputMode::Pane)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('r'),
|
||||
vec![Action::SwitchToMode(InputMode::Resize)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('t'), vec![Action::SwitchToMode(InputMode::Tab)]);
|
||||
defaults.insert(
|
||||
Key::Ctrl('s'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(Key::Ctrl('q'), vec![Action::Quit]);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Normal)]);
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Char(' '),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
|
||||
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Down, vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Up, vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Ctrl('n'), vec![Action::ScrollDown]);
|
||||
defaults.insert(Key::Ctrl('p'), vec![Action::ScrollUp]);
|
||||
|
||||
defaults.insert(Key::Char('q'), vec![Action::Quit]);
|
||||
}
|
||||
InputMode::RenameTab => {
|
||||
defaults.insert(
|
||||
Key::Char('\n'),
|
||||
vec![Action::SaveTabName, Action::SwitchToMode(InputMode::Tab)],
|
||||
);
|
||||
defaults.insert(
|
||||
Key::Ctrl('g'),
|
||||
vec![Action::SwitchToMode(InputMode::Normal)],
|
||||
);
|
||||
defaults.insert(Key::Esc, vec![Action::SwitchToMode(InputMode::Command)]);
|
||||
defaults.insert(
|
||||
Key::Esc,
|
||||
vec![
|
||||
Action::TabNameInput(vec![0x1b]),
|
||||
Action::SwitchToMode(InputMode::Tab),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +265,8 @@ 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),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ use os_input_output::OsApi;
|
|||
use pty_bus::{PtyBus, PtyInstruction};
|
||||
use screen::{Screen, ScreenInstruction};
|
||||
use utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_ROOT_PLUGIN_DIR};
|
||||
use wasm_vm::{wasi_stdout, wasi_write_string, zellij_imports, PluginInstruction};
|
||||
use wasm_vm::{
|
||||
wasi_stdout, wasi_write_string, zellij_imports, EventType, PluginInputType, PluginInstruction,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum ApiCommand {
|
||||
|
|
@ -419,6 +421,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
ScreenInstruction::GoToTab(tab_index) => {
|
||||
screen.go_to_tab(tab_index as usize)
|
||||
}
|
||||
ScreenInstruction::UpdateTabName(c) => {
|
||||
screen.update_active_tab_name(c);
|
||||
}
|
||||
ScreenInstruction::Quit => {
|
||||
break;
|
||||
}
|
||||
|
|
@ -438,6 +443,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
let store = Store::default();
|
||||
let mut plugin_id = 0;
|
||||
let mut plugin_map = HashMap::new();
|
||||
let handler_map: HashMap<EventType, String> =
|
||||
[(EventType::Tab, "handle_tab_rename_keypress".to_string())]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
move || loop {
|
||||
let (event, mut err_ctx) = receive_plugin_instructions
|
||||
|
|
@ -448,7 +458,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
send_pty_instructions.update(err_ctx);
|
||||
send_app_instructions.update(err_ctx);
|
||||
match event {
|
||||
PluginInstruction::Load(pid_tx, path) => {
|
||||
PluginInstruction::Load(pid_tx, path, events) => {
|
||||
let project_dirs =
|
||||
ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
||||
let plugin_dir = project_dirs.data_dir().join("plugins/");
|
||||
|
|
@ -490,6 +500,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
send_screen_instructions: send_screen_instructions.clone(),
|
||||
send_app_instructions: send_app_instructions.clone(),
|
||||
wasi_env,
|
||||
events,
|
||||
};
|
||||
|
||||
let zellij = zellij_imports(&store, &plugin_env);
|
||||
|
|
@ -514,22 +525,27 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
|
||||
buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap();
|
||||
}
|
||||
PluginInstruction::UpdateTabs(active_tab_index, num_tabs) => {
|
||||
for (instance, _) in plugin_map.values() {
|
||||
PluginInstruction::UpdateTabs(mut tabs) => {
|
||||
for (instance, plugin_env) in plugin_map.values() {
|
||||
if !plugin_env.events.contains(&EventType::Tab) {
|
||||
continue;
|
||||
}
|
||||
let handler = instance.exports.get_function("update_tabs").unwrap();
|
||||
handler
|
||||
.call(&[
|
||||
Value::I32(active_tab_index as i32),
|
||||
Value::I32(num_tabs as i32),
|
||||
])
|
||||
.unwrap();
|
||||
tabs.sort_by(|a, b| a.position.cmp(&b.position));
|
||||
wasi_write_string(
|
||||
&plugin_env.wasi_env,
|
||||
&serde_json::to_string(&tabs).unwrap(),
|
||||
);
|
||||
handler.call(&[]).unwrap();
|
||||
}
|
||||
}
|
||||
// FIXME: Deduplicate this with the callback below!
|
||||
PluginInstruction::Input(pid, input_bytes) => {
|
||||
PluginInstruction::Input(input_type, input_bytes) => {
|
||||
match input_type {
|
||||
PluginInputType::Normal(pid) => {
|
||||
let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
|
||||
|
||||
let handle_key = instance.exports.get_function("handle_key").unwrap();
|
||||
let handle_key =
|
||||
instance.exports.get_function("handle_key").unwrap();
|
||||
for key in input_bytes.keys() {
|
||||
if let Ok(key) = key {
|
||||
wasi_write_string(
|
||||
|
|
@ -539,7 +555,28 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
handle_key.call(&[]).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
PluginInputType::Event(event) => {
|
||||
for (instance, plugin_env) in plugin_map.values() {
|
||||
if !plugin_env.events.contains(&event) {
|
||||
continue;
|
||||
}
|
||||
let handle_key = instance
|
||||
.exports
|
||||
.get_function(handler_map.get(&event).unwrap())
|
||||
.unwrap();
|
||||
for key in input_bytes.keys() {
|
||||
if let Ok(key) = key {
|
||||
wasi_write_string(
|
||||
&plugin_env.wasi_env,
|
||||
&serde_json::to_string(&key).unwrap(),
|
||||
);
|
||||
handle_key.call(&[]).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(send_screen_instructions.send(ScreenInstruction::Render));
|
||||
}
|
||||
PluginInstruction::GlobalInput(input_bytes) => {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
use std::collections::BTreeMap;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::str;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
use super::{AppInstruction, SenderWithContext};
|
||||
use crate::os_input_output::OsApi;
|
||||
use crate::panes::PositionAndSize;
|
||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||
use crate::tab::Tab;
|
||||
use crate::tab::{Tab, TabData};
|
||||
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
||||
use crate::{layout::Layout, panes::PaneId};
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ pub enum ScreenInstruction {
|
|||
SwitchTabPrev,
|
||||
CloseTab,
|
||||
GoToTab(u32),
|
||||
UpdateTabName(Vec<u8>),
|
||||
}
|
||||
|
||||
/// A [`Screen`] holds multiple [`Tab`]s, each one holding multiple [`panes`](crate::client::panes).
|
||||
|
|
@ -69,6 +71,7 @@ pub struct Screen {
|
|||
active_tab_index: Option<usize>,
|
||||
/// The [`OsApi`] this [`Screen`] uses.
|
||||
os_api: Box<dyn OsApi>,
|
||||
tabname_buf: String,
|
||||
}
|
||||
|
||||
impl Screen {
|
||||
|
|
@ -92,6 +95,7 @@ impl Screen {
|
|||
active_tab_index: None,
|
||||
tabs: BTreeMap::new(),
|
||||
os_api,
|
||||
tabname_buf: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +107,7 @@ impl Screen {
|
|||
let tab = Tab::new(
|
||||
tab_index,
|
||||
position,
|
||||
String::new(),
|
||||
&self.full_screen_ws,
|
||||
self.os_api.clone(),
|
||||
self.send_pty_instructions.clone(),
|
||||
|
|
@ -246,6 +251,7 @@ impl Screen {
|
|||
let mut tab = Tab::new(
|
||||
tab_index,
|
||||
position,
|
||||
String::new(),
|
||||
&self.full_screen_ws,
|
||||
self.os_api.clone(),
|
||||
self.send_pty_instructions.clone(),
|
||||
|
|
@ -261,13 +267,40 @@ impl Screen {
|
|||
}
|
||||
|
||||
fn update_tabs(&self) {
|
||||
if let Some(active_tab) = self.get_active_tab() {
|
||||
let mut tab_data = vec![];
|
||||
let active_tab_index = self.active_tab_index.unwrap();
|
||||
for tab in self.tabs.values() {
|
||||
tab_data.push(TabData {
|
||||
position: tab.position,
|
||||
name: tab.name.clone(),
|
||||
active: active_tab_index == tab.index,
|
||||
});
|
||||
}
|
||||
self.send_plugin_instructions
|
||||
.send(PluginInstruction::UpdateTabs(
|
||||
active_tab.position,
|
||||
self.tabs.len(),
|
||||
))
|
||||
.send(PluginInstruction::UpdateTabs(tab_data))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn update_active_tab_name(&mut self, buf: Vec<u8>) {
|
||||
let s = str::from_utf8(&buf).unwrap();
|
||||
match s {
|
||||
"\0" => {
|
||||
self.tabname_buf = String::new();
|
||||
}
|
||||
"\n" => {
|
||||
let new_name = self.tabname_buf.clone();
|
||||
let active_tab = self.get_active_tab_mut().unwrap();
|
||||
active_tab.name = new_name;
|
||||
self.update_tabs();
|
||||
self.render();
|
||||
}
|
||||
"\u{007F}" | "\u{0008}" => {
|
||||
//delete and backspace keys
|
||||
self.tabname_buf.pop();
|
||||
}
|
||||
c => {
|
||||
self.tabname_buf.push_str(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,36 @@
|
|||
use crate::tab::TabData;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::mpsc::{channel, Sender},
|
||||
};
|
||||
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
||||
use wasmer_wasi::WasiEnv;
|
||||
// use crate::utils::logging::debug_log_to_file;
|
||||
|
||||
use super::{
|
||||
input::handler::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction,
|
||||
PaneId, SenderWithContext,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Eq, Serialize, Deserialize)]
|
||||
pub enum EventType {
|
||||
Tab,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PluginInputType {
|
||||
Normal(u32),
|
||||
Event(EventType),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PluginInstruction {
|
||||
Load(Sender<u32>, PathBuf),
|
||||
Load(Sender<u32>, PathBuf, Vec<EventType>),
|
||||
Draw(Sender<String>, u32, usize, usize), // String buffer, plugin id, rows, cols
|
||||
Input(u32, Vec<u8>), // plugin id, input bytes
|
||||
Input(PluginInputType, Vec<u8>), // plugin id, input bytes
|
||||
GlobalInput(Vec<u8>), // input bytes
|
||||
Unload(u32),
|
||||
UpdateTabs(usize, usize), // num tabs, active tab
|
||||
UpdateTabs(Vec<TabData>), // num tabs, active tab
|
||||
Quit,
|
||||
}
|
||||
|
||||
|
|
@ -29,6 +41,7 @@ pub struct PluginEnv {
|
|||
pub send_app_instructions: SenderWithContext<AppInstruction>,
|
||||
pub send_pty_instructions: SenderWithContext<PtyInstruction>, // FIXME: This should be a big bundle of all of the channels
|
||||
pub wasi_env: WasiEnv,
|
||||
pub events: Vec<EventType>,
|
||||
}
|
||||
|
||||
// Plugin API ---------------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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] = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ pub trait ZellijTile {
|
|||
fn draw(&mut self, rows: usize, cols: usize) {}
|
||||
fn handle_key(&mut self, key: Key) {}
|
||||
fn handle_global_key(&mut self, key: Key) {}
|
||||
fn update_tabs(&mut self, active_tab_index: usize, num_active_tabs: usize) {}
|
||||
fn update_tabs(&mut self) {}
|
||||
fn handle_tab_rename_keypress(&mut self, key: Key) {}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
@ -45,11 +46,18 @@ macro_rules! register_tile {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn update_tabs(active_tab_index: i32, num_active_tabs: i32) {
|
||||
pub fn update_tabs() {
|
||||
STATE.with(|state| {
|
||||
state.borrow_mut().update_tabs();
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn handle_tab_rename_keypress() {
|
||||
STATE.with(|state| {
|
||||
state
|
||||
.borrow_mut()
|
||||
.update_tabs(active_tab_index as usize, num_active_tabs as usize);
|
||||
.handle_tab_rename_keypress($crate::get_key());
|
||||
})
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,14 +34,23 @@ pub struct Help {
|
|||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub enum InputMode {
|
||||
Normal,
|
||||
Command,
|
||||
Locked,
|
||||
Resize,
|
||||
Pane,
|
||||
Tab,
|
||||
RenameTab,
|
||||
Scroll,
|
||||
Exiting,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct TabData {
|
||||
/* subset of fields to publish to plugins */
|
||||
pub position: usize,
|
||||
pub name: String,
|
||||
pub active: bool,
|
||||
}
|
||||
|
||||
impl Default for InputMode {
|
||||
fn default() -> InputMode {
|
||||
InputMode::Normal
|
||||
|
|
@ -76,6 +85,10 @@ pub fn get_help() -> Help {
|
|||
deserialize_from_stdin().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn get_tabs() -> Vec<TabData> {
|
||||
deserialize_from_stdin().unwrap_or_default()
|
||||
}
|
||||
|
||||
fn deserialize_from_stdin<T: DeserializeOwned>() -> Option<T> {
|
||||
let mut json = String::new();
|
||||
io::stdin().read_line(&mut json).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue