mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-23 19:10:09 +03:00
parent
5ddf95a16c
commit
cf43736656
@ -432,7 +432,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: Opt) {
|
||||
}
|
||||
// cleanup();
|
||||
let reset_style = "\u{1b}[m";
|
||||
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.ws_row, 1);
|
||||
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1);
|
||||
let goodbye_message = format!(
|
||||
"{}\n{}Bye from Mosaic!",
|
||||
goto_start_of_last_line, reset_style
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use nix::fcntl::{fcntl, FcntlArg, OFlag};
|
||||
use nix::pty::{forkpty, Winsize};
|
||||
use nix::sys::signal::{kill, Signal};
|
||||
@ -28,7 +29,7 @@ fn unset_raw_mode(pid: RawFd, mut orig_termios: Termios) {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_terminal_size_using_fd(fd: RawFd) -> Winsize {
|
||||
pub fn get_terminal_size_using_fd(fd: RawFd) -> PositionAndSize {
|
||||
// TODO: do this with the nix ioctl
|
||||
use libc::ioctl;
|
||||
use libc::TIOCGWINSZ;
|
||||
@ -41,7 +42,7 @@ pub fn get_terminal_size_using_fd(fd: RawFd) -> Winsize {
|
||||
};
|
||||
|
||||
unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut winsize) };
|
||||
winsize
|
||||
PositionAndSize::from(winsize)
|
||||
}
|
||||
|
||||
pub fn set_terminal_size_using_fd(fd: RawFd, columns: u16, rows: u16) {
|
||||
@ -137,7 +138,7 @@ pub struct OsInputOutput {
|
||||
}
|
||||
|
||||
pub trait OsApi: Send + Sync {
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> Winsize;
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> PositionAndSize;
|
||||
fn set_terminal_size_using_fd(&mut self, pid: RawFd, cols: u16, rows: u16);
|
||||
fn into_raw_mode(&mut self, pid: RawFd);
|
||||
fn unset_raw_mode(&mut self, pid: RawFd);
|
||||
@ -152,7 +153,7 @@ pub trait OsApi: Send + Sync {
|
||||
}
|
||||
|
||||
impl OsApi for OsInputOutput {
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> Winsize {
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> PositionAndSize {
|
||||
get_terminal_size_using_fd(pid)
|
||||
}
|
||||
fn set_terminal_size_using_fd(&mut self, pid: RawFd, cols: u16, rows: u16) {
|
||||
|
137
src/screen.rs
137
src/screen.rs
@ -1,4 +1,3 @@
|
||||
use nix::pty::Winsize;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::io::Write;
|
||||
use std::os::unix::io::RawFd;
|
||||
@ -23,29 +22,29 @@ const CURSOR_HEIGHT_WIDTH_RATIO: usize = 4; // this is not accurate and kind of
|
||||
|
||||
type BorderAndPaneIds = (usize, Vec<RawFd>);
|
||||
|
||||
fn split_vertically_with_gap(rect: &Winsize) -> (Winsize, Winsize) {
|
||||
let width_of_each_half = (rect.ws_col - 1) / 2;
|
||||
fn split_vertically_with_gap(rect: &PositionAndSize) -> (PositionAndSize, PositionAndSize) {
|
||||
let width_of_each_half = (rect.columns - 1) / 2;
|
||||
let mut first_rect = rect.clone();
|
||||
let mut second_rect = rect.clone();
|
||||
if rect.ws_col % 2 == 0 {
|
||||
first_rect.ws_col = width_of_each_half + 1;
|
||||
if rect.columns % 2 == 0 {
|
||||
first_rect.columns = width_of_each_half + 1;
|
||||
} else {
|
||||
first_rect.ws_col = width_of_each_half;
|
||||
first_rect.columns = width_of_each_half;
|
||||
}
|
||||
second_rect.ws_col = width_of_each_half;
|
||||
second_rect.columns = width_of_each_half;
|
||||
(first_rect, second_rect)
|
||||
}
|
||||
|
||||
fn split_horizontally_with_gap(rect: &Winsize) -> (Winsize, Winsize) {
|
||||
let height_of_each_half = (rect.ws_row - 1) / 2;
|
||||
fn split_horizontally_with_gap(rect: &PositionAndSize) -> (PositionAndSize, PositionAndSize) {
|
||||
let height_of_each_half = (rect.rows - 1) / 2;
|
||||
let mut first_rect = rect.clone();
|
||||
let mut second_rect = rect.clone();
|
||||
if rect.ws_row % 2 == 0 {
|
||||
first_rect.ws_row = height_of_each_half + 1;
|
||||
if rect.rows % 2 == 0 {
|
||||
first_rect.rows = height_of_each_half + 1;
|
||||
} else {
|
||||
first_rect.ws_row = height_of_each_half;
|
||||
first_rect.rows = height_of_each_half;
|
||||
}
|
||||
second_rect.ws_row = height_of_each_half;
|
||||
second_rect.rows = height_of_each_half;
|
||||
(first_rect, second_rect)
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ pub struct Screen {
|
||||
max_panes: Option<usize>,
|
||||
send_pty_instructions: Sender<PtyInstruction>,
|
||||
send_app_instructions: Sender<AppInstruction>,
|
||||
full_screen_ws: Winsize,
|
||||
full_screen_ws: PositionAndSize,
|
||||
terminals: BTreeMap<RawFd, TerminalPane>, // BTreeMap because we need a predictable order when changing focus
|
||||
panes_to_hide: HashSet<RawFd>,
|
||||
active_terminal: Option<RawFd>,
|
||||
@ -90,7 +89,7 @@ impl Screen {
|
||||
receive_screen_instructions: Receiver<ScreenInstruction>,
|
||||
send_pty_instructions: Sender<PtyInstruction>,
|
||||
send_app_instructions: Sender<AppInstruction>,
|
||||
full_screen_ws: &Winsize,
|
||||
full_screen_ws: &PositionAndSize,
|
||||
os_api: Box<dyn OsApi>,
|
||||
max_panes: Option<usize>,
|
||||
) -> Self {
|
||||
@ -114,8 +113,8 @@ impl Screen {
|
||||
let free_space = PositionAndSize {
|
||||
x: 0,
|
||||
y: 0,
|
||||
rows: self.full_screen_ws.ws_row as usize,
|
||||
columns: self.full_screen_ws.ws_col as usize,
|
||||
rows: self.full_screen_ws.rows,
|
||||
columns: self.full_screen_ws.columns,
|
||||
};
|
||||
let positions_in_layout = layout.position_panes_in_space(&free_space);
|
||||
let mut positions_and_size = positions_in_layout.iter();
|
||||
@ -204,56 +203,48 @@ impl Screen {
|
||||
},
|
||||
);
|
||||
let terminal_to_split = self.terminals.get_mut(&terminal_id_to_split).unwrap();
|
||||
let terminal_ws = Winsize {
|
||||
ws_row: terminal_to_split.get_rows() as u16,
|
||||
ws_col: terminal_to_split.get_columns() as u16,
|
||||
ws_xpixel: terminal_to_split.get_x() as u16,
|
||||
ws_ypixel: terminal_to_split.get_y() as u16,
|
||||
let terminal_ws = PositionAndSize {
|
||||
rows: terminal_to_split.get_rows(),
|
||||
columns: terminal_to_split.get_columns(),
|
||||
x: terminal_to_split.get_x(),
|
||||
y: terminal_to_split.get_y(),
|
||||
};
|
||||
if terminal_to_split.get_rows() * CURSOR_HEIGHT_WIDTH_RATIO
|
||||
> terminal_to_split.get_columns()
|
||||
{
|
||||
let (top_winsize, bottom_winsize) = split_horizontally_with_gap(&terminal_ws);
|
||||
let bottom_half_y = terminal_ws.ws_ypixel + top_winsize.ws_row + 1;
|
||||
let new_terminal = TerminalPane::new(
|
||||
pid,
|
||||
bottom_winsize,
|
||||
terminal_ws.ws_xpixel as usize,
|
||||
bottom_half_y as usize,
|
||||
);
|
||||
let bottom_half_y = terminal_ws.y + top_winsize.rows + 1;
|
||||
let new_terminal =
|
||||
TerminalPane::new(pid, bottom_winsize, terminal_ws.x, bottom_half_y);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
new_terminal.pid,
|
||||
bottom_winsize.ws_col,
|
||||
bottom_winsize.ws_row,
|
||||
bottom_winsize.columns as u16,
|
||||
bottom_winsize.rows as u16,
|
||||
);
|
||||
terminal_to_split.change_size(&top_winsize);
|
||||
self.terminals.insert(pid, new_terminal);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
terminal_id_to_split,
|
||||
top_winsize.ws_col,
|
||||
top_winsize.ws_row,
|
||||
top_winsize.columns as u16,
|
||||
top_winsize.rows as u16,
|
||||
);
|
||||
self.active_terminal = Some(pid);
|
||||
} else {
|
||||
let (left_winszie, right_winsize) = split_vertically_with_gap(&terminal_ws);
|
||||
let right_side_x = (terminal_ws.ws_xpixel + left_winszie.ws_col + 1) as usize;
|
||||
let new_terminal = TerminalPane::new(
|
||||
pid,
|
||||
right_winsize,
|
||||
right_side_x,
|
||||
terminal_ws.ws_ypixel as usize,
|
||||
);
|
||||
let right_side_x = (terminal_ws.x + left_winszie.columns + 1) as usize;
|
||||
let new_terminal =
|
||||
TerminalPane::new(pid, right_winsize, right_side_x, terminal_ws.y);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
new_terminal.pid,
|
||||
right_winsize.ws_col,
|
||||
right_winsize.ws_row,
|
||||
right_winsize.columns as u16,
|
||||
right_winsize.rows as u16,
|
||||
);
|
||||
terminal_to_split.change_size(&left_winszie);
|
||||
self.terminals.insert(pid, new_terminal);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
terminal_id_to_split,
|
||||
left_winszie.ws_col,
|
||||
left_winszie.ws_row,
|
||||
left_winszie.columns as u16,
|
||||
left_winszie.rows as u16,
|
||||
);
|
||||
}
|
||||
self.active_terminal = Some(pid);
|
||||
@ -281,24 +272,24 @@ impl Screen {
|
||||
let (active_terminal_ws, active_terminal_x, active_terminal_y) = {
|
||||
let active_terminal = &self.get_active_terminal().unwrap();
|
||||
(
|
||||
Winsize {
|
||||
ws_row: active_terminal.get_rows() as u16,
|
||||
ws_col: active_terminal.get_columns() as u16,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
PositionAndSize {
|
||||
rows: active_terminal.get_rows(),
|
||||
columns: active_terminal.get_columns(),
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
active_terminal.get_x(),
|
||||
active_terminal.get_y(),
|
||||
)
|
||||
};
|
||||
let (top_winsize, bottom_winsize) = split_horizontally_with_gap(&active_terminal_ws);
|
||||
let bottom_half_y = active_terminal_y + top_winsize.ws_row as usize + 1;
|
||||
let bottom_half_y = active_terminal_y + top_winsize.rows + 1;
|
||||
let new_terminal =
|
||||
TerminalPane::new(pid, bottom_winsize, active_terminal_x, bottom_half_y);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
new_terminal.pid,
|
||||
bottom_winsize.ws_col,
|
||||
bottom_winsize.ws_row,
|
||||
bottom_winsize.columns as u16,
|
||||
bottom_winsize.rows as u16,
|
||||
);
|
||||
|
||||
{
|
||||
@ -311,8 +302,8 @@ impl Screen {
|
||||
let active_terminal_pid = self.get_active_terminal_id().unwrap();
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
active_terminal_pid,
|
||||
top_winsize.ws_col,
|
||||
top_winsize.ws_row,
|
||||
top_winsize.columns as u16,
|
||||
top_winsize.rows as u16,
|
||||
);
|
||||
self.active_terminal = Some(pid);
|
||||
self.render();
|
||||
@ -339,24 +330,24 @@ impl Screen {
|
||||
let (active_terminal_ws, active_terminal_x, active_terminal_y) = {
|
||||
let active_terminal = &self.get_active_terminal().unwrap();
|
||||
(
|
||||
Winsize {
|
||||
ws_row: active_terminal.get_rows() as u16,
|
||||
ws_col: active_terminal.get_columns() as u16,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
PositionAndSize {
|
||||
rows: active_terminal.get_rows(),
|
||||
columns: active_terminal.get_columns(),
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
active_terminal.get_x(),
|
||||
active_terminal.get_y(),
|
||||
)
|
||||
};
|
||||
let (left_winszie, right_winsize) = split_vertically_with_gap(&active_terminal_ws);
|
||||
let right_side_x = active_terminal_x + left_winszie.ws_col as usize + 1;
|
||||
let right_side_x = active_terminal_x + left_winszie.columns + 1;
|
||||
let new_terminal =
|
||||
TerminalPane::new(pid, right_winsize, right_side_x, active_terminal_y);
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
new_terminal.pid,
|
||||
right_winsize.ws_col,
|
||||
right_winsize.ws_row,
|
||||
right_winsize.columns as u16,
|
||||
right_winsize.rows as u16,
|
||||
);
|
||||
|
||||
{
|
||||
@ -369,8 +360,8 @@ impl Screen {
|
||||
let active_terminal_pid = self.get_active_terminal_id().unwrap();
|
||||
self.os_api.set_terminal_size_using_fd(
|
||||
active_terminal_pid,
|
||||
left_winszie.ws_col,
|
||||
left_winszie.ws_row,
|
||||
left_winszie.columns as u16,
|
||||
left_winszie.rows as u16,
|
||||
);
|
||||
self.active_terminal = Some(pid);
|
||||
self.render();
|
||||
@ -464,8 +455,10 @@ impl Screen {
|
||||
return;
|
||||
}
|
||||
let mut stdout = self.os_api.get_stdout_writer();
|
||||
let mut boundaries =
|
||||
Boundaries::new(self.full_screen_ws.ws_col, self.full_screen_ws.ws_row);
|
||||
let mut boundaries = Boundaries::new(
|
||||
self.full_screen_ws.columns as u16,
|
||||
self.full_screen_ws.rows as u16,
|
||||
);
|
||||
for (pid, terminal) in self.terminals.iter_mut() {
|
||||
if !self.panes_to_hide.contains(pid) {
|
||||
boundaries.add_rect(&terminal);
|
||||
@ -658,7 +651,7 @@ impl Screen {
|
||||
}
|
||||
}
|
||||
// bottom-most border aligned with a pane border to the right
|
||||
let mut bottom_resize_border = self.full_screen_ws.ws_row as usize;
|
||||
let mut bottom_resize_border = self.full_screen_ws.rows;
|
||||
for terminal in &terminals {
|
||||
let top_terminal_boundary = terminal.get_y();
|
||||
if terminal_borders_to_the_right
|
||||
@ -736,7 +729,7 @@ impl Screen {
|
||||
}
|
||||
}
|
||||
// bottom-most border aligned with a pane border to the left
|
||||
let mut bottom_resize_border = self.full_screen_ws.ws_row as usize;
|
||||
let mut bottom_resize_border = self.full_screen_ws.rows;
|
||||
for terminal in &terminals {
|
||||
let top_terminal_boundary = terminal.get_y();
|
||||
if terminal_borders_to_the_left
|
||||
@ -817,7 +810,7 @@ impl Screen {
|
||||
}
|
||||
}
|
||||
// rightmost border aligned with a pane border above
|
||||
let mut right_resize_border = self.full_screen_ws.ws_col as usize;
|
||||
let mut right_resize_border = self.full_screen_ws.columns;
|
||||
for terminal in &terminals {
|
||||
let left_terminal_boundary = terminal.get_x();
|
||||
if terminal_borders_above
|
||||
@ -896,7 +889,7 @@ impl Screen {
|
||||
}
|
||||
}
|
||||
// leftmost border aligned with a pane border above
|
||||
let mut right_resize_border = self.full_screen_ws.ws_col as usize;
|
||||
let mut right_resize_border = self.full_screen_ws.columns;
|
||||
for terminal in &terminals {
|
||||
let left_terminal_boundary = terminal.get_x();
|
||||
if terminal_borders_below
|
||||
@ -1217,11 +1210,11 @@ impl Screen {
|
||||
}
|
||||
fn panes_exist_below(&self, pane_id: &RawFd) -> bool {
|
||||
let pane = self.terminals.get(pane_id).expect("pane does not exist");
|
||||
pane.get_y() + pane.get_rows() < self.full_screen_ws.ws_row as usize
|
||||
pane.get_y() + pane.get_rows() < self.full_screen_ws.rows
|
||||
}
|
||||
fn panes_exist_to_the_right(&self, pane_id: &RawFd) -> bool {
|
||||
let pane = self.terminals.get(pane_id).expect("pane does not exist");
|
||||
pane.get_x() + pane.get_columns() < self.full_screen_ws.ws_col as usize
|
||||
pane.get_x() + pane.get_columns() < self.full_screen_ws.columns
|
||||
}
|
||||
fn panes_exist_to_the_left(&self, pane_id: &RawFd) -> bool {
|
||||
let pane = self.terminals.get(pane_id).expect("pane does not exist");
|
||||
|
@ -18,6 +18,17 @@ pub struct PositionAndSize {
|
||||
pub columns: usize,
|
||||
}
|
||||
|
||||
impl PositionAndSize {
|
||||
pub fn from(winsize: Winsize) -> PositionAndSize {
|
||||
PositionAndSize {
|
||||
columns: winsize.ws_col as usize,
|
||||
rows: winsize.ws_row as usize,
|
||||
x: winsize.ws_xpixel as usize,
|
||||
y: winsize.ws_ypixel as usize,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TerminalPane {
|
||||
pub pid: RawFd,
|
||||
@ -44,14 +55,14 @@ impl Rect for &mut TerminalPane {
|
||||
}
|
||||
|
||||
impl TerminalPane {
|
||||
pub fn new(pid: RawFd, ws: Winsize, x: usize, y: usize) -> TerminalPane {
|
||||
let scroll = Scroll::new(ws.ws_col as usize, ws.ws_row as usize);
|
||||
pub fn new(pid: RawFd, ws: PositionAndSize, x: usize, y: usize) -> TerminalPane {
|
||||
let scroll = Scroll::new(ws.columns, ws.rows);
|
||||
let pending_styles = CharacterStyles::new();
|
||||
let position_and_size = PositionAndSize {
|
||||
x,
|
||||
y,
|
||||
rows: ws.ws_row as usize,
|
||||
columns: ws.ws_col as usize,
|
||||
rows: ws.rows,
|
||||
columns: ws.columns,
|
||||
};
|
||||
TerminalPane {
|
||||
pid,
|
||||
@ -145,9 +156,9 @@ impl TerminalPane {
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
// TODO: merge these two methods
|
||||
pub fn change_size(&mut self, ws: &Winsize) {
|
||||
self.position_and_size.columns = ws.ws_col as usize;
|
||||
self.position_and_size.rows = ws.ws_row as usize;
|
||||
pub fn change_size(&mut self, ws: &PositionAndSize) {
|
||||
self.position_and_size.columns = ws.columns;
|
||||
self.position_and_size.rows = ws.rows;
|
||||
self.reflow_lines();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
@ -247,12 +258,12 @@ impl TerminalPane {
|
||||
self.scroll.reset_viewport();
|
||||
self.mark_for_rerender();
|
||||
}
|
||||
pub fn override_size_and_position(&mut self, x: usize, y: usize, size: &Winsize) {
|
||||
pub fn override_size_and_position(&mut self, x: usize, y: usize, size: &PositionAndSize) {
|
||||
let position_and_size_override = PositionAndSize {
|
||||
x,
|
||||
y,
|
||||
rows: size.ws_row as usize,
|
||||
columns: size.ws_col as usize,
|
||||
rows: size.rows,
|
||||
columns: size.columns,
|
||||
};
|
||||
self.position_and_size_override = Some(position_and_size_override);
|
||||
self.reflow_lines();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use ::nix::pty::Winsize;
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use ::std::collections::HashMap;
|
||||
use ::std::io::{Read, Write};
|
||||
use ::std::os::unix::io::RawFd;
|
||||
@ -80,12 +80,12 @@ pub struct FakeInputOutput {
|
||||
stdin_writes: Arc<Mutex<HashMap<RawFd, Vec<u8>>>>,
|
||||
pub stdout_writer: FakeStdoutWriter, // stdout_writer.output is already an arc/mutex
|
||||
io_events: Arc<Mutex<Vec<IoEvent>>>,
|
||||
win_sizes: Arc<Mutex<HashMap<RawFd, Winsize>>>,
|
||||
win_sizes: Arc<Mutex<HashMap<RawFd, PositionAndSize>>>,
|
||||
possible_tty_inputs: HashMap<u16, Bytes>,
|
||||
}
|
||||
|
||||
impl FakeInputOutput {
|
||||
pub fn new(winsize: Winsize) -> Self {
|
||||
pub fn new(winsize: PositionAndSize) -> Self {
|
||||
let mut win_sizes = HashMap::new();
|
||||
win_sizes.insert(0, winsize); // 0 is the current terminal
|
||||
FakeInputOutput {
|
||||
@ -111,7 +111,7 @@ impl FakeInputOutput {
|
||||
}
|
||||
|
||||
impl OsApi for FakeInputOutput {
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> Winsize {
|
||||
fn get_terminal_size_using_fd(&self, pid: RawFd) -> PositionAndSize {
|
||||
let win_sizes = self.win_sizes.lock().unwrap();
|
||||
let winsize = win_sizes.get(&pid).unwrap();
|
||||
*winsize
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::commands::{
|
||||
@ -9,17 +9,17 @@ use crate::tests::utils::commands::{
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn starts_with_one_terminal() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[QUIT]);
|
||||
@ -37,11 +37,11 @@ pub fn starts_with_one_terminal() {
|
||||
|
||||
#[test]
|
||||
pub fn split_terminals_vertically() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, QUIT]);
|
||||
@ -59,11 +59,11 @@ pub fn split_terminals_vertically() {
|
||||
|
||||
#[test]
|
||||
pub fn split_terminals_horizontally() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, QUIT]);
|
||||
@ -82,11 +82,11 @@ pub fn split_terminals_horizontally() {
|
||||
#[test]
|
||||
pub fn split_largest_terminal() {
|
||||
// this finds the largest pane and splits along its longest edge (vertically or horizontally)
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPAWN_TERMINAL, SPAWN_TERMINAL, SPAWN_TERMINAL, QUIT]);
|
||||
@ -119,11 +119,11 @@ pub fn resize_right_and_up_on_the_same_axis() {
|
||||
// │█████│ │ │█████│ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -153,11 +153,11 @@ pub fn resize_right_and_up_on_the_same_axis() {
|
||||
|
||||
#[test]
|
||||
pub fn scrolling_inside_a_pane() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -185,11 +185,11 @@ pub fn scrolling_inside_a_pane() {
|
||||
pub fn max_panes() {
|
||||
// with the --max-panes option, we only allow a certain amount of panes on screen
|
||||
// simultaneously, new panes beyond this limit will close older panes on screen
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -215,11 +215,11 @@ pub fn max_panes() {
|
||||
|
||||
#[test]
|
||||
pub fn toggle_focused_pane_fullscreen() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
@ -10,7 +10,7 @@ use crate::tests::utils::commands::{
|
||||
SPLIT_VERTICALLY,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
@ -24,11 +24,11 @@ pub fn close_pane_with_another_pane_above_it() {
|
||||
// │███████████│ │xxxxxxxxxxx│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, CLOSE_FOCUSED_PANE, QUIT]);
|
||||
@ -55,11 +55,11 @@ pub fn close_pane_with_another_pane_below_it() {
|
||||
// │xxxxxxxxxxx│ │xxxxxxxxxxx│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -89,11 +89,11 @@ pub fn close_pane_with_another_pane_to_the_left() {
|
||||
// │xxxxx│█████│ │xxxxxxxxxx│
|
||||
// └─────┴─────┘ └──────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, CLOSE_FOCUSED_PANE, QUIT]);
|
||||
@ -118,11 +118,11 @@ pub fn close_pane_with_another_pane_to_the_right() {
|
||||
// │█████│xxxxx│ │xxxxxxxxxx│
|
||||
// └─────┴─────┘ └──────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, MOVE_FOCUS, CLOSE_FOCUSED_PANE, QUIT]);
|
||||
@ -149,11 +149,11 @@ pub fn close_pane_with_multiple_panes_above_it() {
|
||||
// │███████████│ │xxxxx│xxxxx│
|
||||
// └───────────┘ └─────┴─────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -188,11 +188,11 @@ pub fn close_pane_with_multiple_panes_below_it() {
|
||||
// │xxxxx│xxxxx│ │xxxxx│xxxxx│
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -225,11 +225,11 @@ pub fn close_pane_with_multiple_panes_to_the_left() {
|
||||
// │xxxxx│█████│ │xxxxxxxxxx│
|
||||
// └─────┴─────┘ └──────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -264,11 +264,11 @@ pub fn close_pane_with_multiple_panes_to_the_right() {
|
||||
// │█████│xxxxx│ │xxxxxxxxxx│
|
||||
// └─────┴─────┘ └──────────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -301,11 +301,11 @@ pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() {
|
||||
// │xxx│███████│xxx│ │xxx│xxx│xxx│xxx│
|
||||
// └───┴───────┴───┘ └───┴───┴───┴───┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -352,11 +352,11 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() {
|
||||
// │xxx│xxx│xxx│xxx│ │xxx│xxx│xxx│xxx│
|
||||
// └───┴───┴───┴───┘ └───┴───┴───┴───┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -405,11 +405,11 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() {
|
||||
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
||||
// └────┴──────┘ └────┴──────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -458,11 +458,11 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
|
||||
// │xxxx│xxxxxx│ │xxxx│xxxxxx│
|
||||
// └────┴──────┘ └────┴──────┘
|
||||
// █ == pane being closed
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -501,11 +501,11 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() {
|
||||
|
||||
#[test]
|
||||
pub fn closing_last_pane_exits_app() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
|
@ -1,14 +1,13 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
use ::std::collections::HashMap;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::possible_tty_inputs::Bytes;
|
||||
use crate::tests::utils::commands::QUIT;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
|
||||
use crate::tests::utils::commands::QUIT;
|
||||
|
||||
/*
|
||||
* These tests are general compatibility tests for non-trivial scenarios running in the terminal.
|
||||
* They use fake TTY input replicated from these scenarios (and so don't actually interact with the
|
||||
@ -22,20 +21,20 @@ use crate::tests::utils::commands::QUIT;
|
||||
*
|
||||
*/
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize, fixture_name: &str) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize, fixture_name: &str) -> FakeInputOutput {
|
||||
let mut tty_inputs = HashMap::new();
|
||||
let fixture_bytes = Bytes::from_file_in_fixtures(&fixture_name);
|
||||
tty_inputs.insert(fake_win_size.ws_col, fixture_bytes);
|
||||
tty_inputs.insert(fake_win_size.columns as u16, fixture_bytes);
|
||||
FakeInputOutput::new(fake_win_size.clone()).with_tty_inputs(tty_inputs)
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn run_bandwhich_from_fish_shell() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "fish_and_bandwhich";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
@ -54,11 +53,11 @@ pub fn run_bandwhich_from_fish_shell() {
|
||||
|
||||
#[test]
|
||||
pub fn fish_tab_completion_options() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "fish_tab_completion_options";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
@ -82,11 +81,11 @@ pub fn fish_select_tab_completion_options() {
|
||||
// changes.
|
||||
// this is not clearly seen in the snapshot because it does not include styles,
|
||||
// but we can see the command line change and the cursor staying in place
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "fish_select_tab_completion_options";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
@ -114,11 +113,11 @@ pub fn vim_scroll_region_down() {
|
||||
// this tests also has other steps afterwards that fills the line with the next line in the
|
||||
// file
|
||||
// experience appear to the user
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "vim_scroll_region_down";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
@ -144,11 +143,11 @@ pub fn vim_ctrl_d() {
|
||||
// what happens here is that 13 lines are deleted and instead 13 empty lines are added at the
|
||||
// end of the scroll region
|
||||
// vim makes sure to fill these empty lines with the rest of the file
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "vim_ctrl_d";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
@ -172,11 +171,11 @@ pub fn vim_ctrl_u() {
|
||||
// this case) lines at the cursor, pushing away (deleting) the last line in the scroll region
|
||||
// this causes the effect of scrolling up X lines (vim replaces the lines with the ones in the
|
||||
// file above the current content)
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 116,
|
||||
ws_row: 28,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 116,
|
||||
rows: 28,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let fixture_name = "vim_ctrl_u";
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
|
||||
|
@ -1,22 +1,22 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::commands::QUIT;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn accepts_basic_layout() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[QUIT]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
@ -9,7 +9,7 @@ use crate::tests::utils::commands::{
|
||||
MOVE_FOCUS, QUIT, RESIZE_DOWN, RESIZE_LEFT, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
@ -24,11 +24,11 @@ pub fn resize_down_with_pane_above() {
|
||||
// │███████████│ │███████████│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, RESIZE_DOWN, QUIT]);
|
||||
@ -55,11 +55,11 @@ pub fn resize_down_with_pane_below() {
|
||||
// │ │ │ │
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, MOVE_FOCUS, RESIZE_DOWN, QUIT]);
|
||||
@ -89,11 +89,11 @@ pub fn resize_down_with_panes_above_and_below() {
|
||||
// │ │ │ │
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -127,11 +127,11 @@ pub fn resize_down_with_multiple_panes_above() {
|
||||
// │███████████│ │███████████│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -168,11 +168,11 @@ pub fn resize_down_with_panes_above_aligned_left_with_current_pane() {
|
||||
// │ │█████│ │ │█████│
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -211,11 +211,11 @@ pub fn resize_down_with_panes_below_aligned_left_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -253,11 +253,11 @@ pub fn resize_down_with_panes_above_aligned_right_with_current_pane() {
|
||||
// │█████│ │ │█████│ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -293,11 +293,11 @@ pub fn resize_down_with_panes_below_aligned_right_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -334,11 +334,11 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() {
|
||||
// │ │███│ │ │ │███│ │
|
||||
// └───┴───┴───┘ └───┴───┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -378,11 +378,11 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() {
|
||||
// │ │ │ │ │ │ │ │
|
||||
// └───┴───┴───┘ └───┴───┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -424,11 +424,11 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef
|
||||
// │ │ │███│ │ │ │ │ │███│ │ │
|
||||
// └─┴─┴───┴─┴─┘ └─┴─┴───┴─┴─┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -485,11 +485,11 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_
|
||||
// │ │ │ │ │ │ │ │
|
||||
// └─┴───────┴─┘ └─┴───────┴─┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
@ -9,7 +9,7 @@ use crate::tests::utils::commands::{
|
||||
MOVE_FOCUS, QUIT, RESIZE_LEFT, RESIZE_UP, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
@ -21,11 +21,11 @@ pub fn resize_left_with_pane_to_the_left() {
|
||||
// │ │█████│ │ │███████│
|
||||
// └─────┴─────┘ └───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, RESIZE_LEFT, QUIT]);
|
||||
@ -50,11 +50,11 @@ pub fn resize_left_with_pane_to_the_right() {
|
||||
// │█████│ │ │███│ │
|
||||
// └─────┴─────┘ └───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, MOVE_FOCUS, RESIZE_LEFT, QUIT]);
|
||||
@ -79,11 +79,11 @@ pub fn resize_left_with_panes_to_the_left_and_right() {
|
||||
// │ │█████│ │ │ │███│ │
|
||||
// └─────┴─────┴─────┘ └─────┴───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -115,11 +115,11 @@ pub fn resize_left_with_multiple_panes_to_the_left() {
|
||||
// │ │█████│ │ │███████│
|
||||
// └─────┴─────┘ └───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -154,11 +154,11 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_with_current_pane() {
|
||||
// │ │█████│ │ │███████│
|
||||
// └─────┴─────┘ └───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -195,11 +195,11 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_with_current_pane() {
|
||||
// │█████│ │ │███│ │
|
||||
// └─────┴─────┘ └───┴───────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -233,11 +233,11 @@ pub fn resize_left_with_panes_to_the_left_aligned_bottom_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -273,11 +273,11 @@ pub fn resize_left_with_panes_to_the_right_aligned_bottom_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -314,11 +314,11 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -358,11 +358,11 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -404,11 +404,11 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov
|
||||
// ├─────┼─────┤ ├───┴─┬─────┤
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -465,12 +465,12 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_panes_abo
|
||||
// ├─────┼─────┤ ├───┴─┬─────┤
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
let fake_win_size = PositionAndSize {
|
||||
// TODO: combine with above
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
@ -9,7 +9,7 @@ use crate::tests::utils::commands::{
|
||||
MOVE_FOCUS, QUIT, RESIZE_RIGHT, RESIZE_UP, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
@ -21,11 +21,11 @@ pub fn resize_right_with_pane_to_the_left() {
|
||||
// │ │█████│ │ │███│
|
||||
// └─────┴─────┘ └───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, RESIZE_RIGHT, QUIT]);
|
||||
@ -50,11 +50,11 @@ pub fn resize_right_with_pane_to_the_right() {
|
||||
// │█████│ │ │███████│ │
|
||||
// └─────┴─────┘ └───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_VERTICALLY, MOVE_FOCUS, RESIZE_RIGHT, QUIT]);
|
||||
@ -79,11 +79,11 @@ pub fn resize_right_with_panes_to_the_left_and_right() {
|
||||
// │ │█████│ │ │ │███████│ │
|
||||
// └─────┴─────┴─────┘ └─────┴───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -115,11 +115,11 @@ pub fn resize_right_with_multiple_panes_to_the_left() {
|
||||
// │ │█████│ │ │███│
|
||||
// └─────┴─────┘ └───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -154,11 +154,11 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_with_current_pane() {
|
||||
// │ │█████│ │ │███│
|
||||
// └─────┴─────┘ └───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -195,11 +195,11 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_with_current_pane() {
|
||||
// │█████│ │ │███████│ │
|
||||
// └─────┴─────┘ └───────┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -233,11 +233,11 @@ pub fn resize_right_with_panes_to_the_left_aligned_bottom_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -273,11 +273,11 @@ pub fn resize_right_with_panes_to_the_right_aligned_bottom_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -314,11 +314,11 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -358,11 +358,11 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -404,11 +404,11 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo
|
||||
// ├─────┼─────┤ ├─────┬─┴───┤
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -465,11 +465,11 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_panes_ab
|
||||
// ├─────┼─────┤ ├─────┬─┴───┤
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
@ -9,7 +9,7 @@ use crate::tests::utils::commands::{
|
||||
MOVE_FOCUS, QUIT, RESIZE_LEFT, RESIZE_UP, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
@ -23,11 +23,11 @@ pub fn resize_up_with_pane_above() {
|
||||
// │███████████│ │███████████│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, RESIZE_UP, QUIT]);
|
||||
@ -54,11 +54,11 @@ pub fn resize_up_with_pane_below() {
|
||||
// │ │ │ │
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[SPLIT_HORIZONTALLY, MOVE_FOCUS, RESIZE_UP, QUIT]);
|
||||
@ -88,11 +88,11 @@ pub fn resize_up_with_panes_above_and_below() {
|
||||
// │ │ │ │
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -125,11 +125,11 @@ pub fn resize_up_with_multiple_panes_above() {
|
||||
// │███████████│ │███████████│
|
||||
// └───────────┘ └───────────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -164,11 +164,11 @@ pub fn resize_up_with_panes_above_aligned_left_with_current_pane() {
|
||||
// │ │█████│ │ │█████│
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -207,11 +207,11 @@ pub fn resize_up_with_panes_below_aligned_left_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -249,11 +249,11 @@ pub fn resize_up_with_panes_above_aligned_right_with_current_pane() {
|
||||
// │█████│ │ │█████│ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -289,11 +289,11 @@ pub fn resize_up_with_panes_below_aligned_right_with_current_pane() {
|
||||
// │ │ │ │ │ │
|
||||
// └─────┴─────┘ └─────┴─────┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -330,11 +330,11 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() {
|
||||
// │ │███│ │ │ │███│ │
|
||||
// └───┴───┴───┘ └───┴───┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -374,11 +374,11 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() {
|
||||
// │ │ │ │ │ │ │ │
|
||||
// └───┴───┴───┘ └───┴───┴───┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -420,11 +420,11 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_
|
||||
// │ │ │███│ │ │ │ │ │███│ │ │
|
||||
// └─┴─┴───┴─┴─┘ └─┴─┴───┴─┴─┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
@ -481,11 +481,11 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri
|
||||
// │ │ │ │ │ │ │ │
|
||||
// └─┴───────┴─┘ └─┴───────┴─┘
|
||||
// █ == focused pane
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 40,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 40,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use ::insta::assert_snapshot;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::tests::fakes::FakeInputOutput;
|
||||
use crate::tests::utils::get_output_frame_snapshots;
|
||||
use crate::{start, Opt};
|
||||
@ -10,17 +10,17 @@ use crate::tests::utils::commands::{
|
||||
TOGGLE_ACTIVE_TERMINAL_FULLSCREEN,
|
||||
};
|
||||
|
||||
fn get_fake_os_input(fake_win_size: &Winsize) -> FakeInputOutput {
|
||||
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
||||
FakeInputOutput::new(fake_win_size.clone())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn adding_new_terminal_in_fullscreen() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
@ -45,11 +45,11 @@ pub fn adding_new_terminal_in_fullscreen() {
|
||||
|
||||
#[test]
|
||||
pub fn move_focus_is_disabled_in_fullscreen() {
|
||||
let fake_win_size = Winsize {
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
let fake_win_size = PositionAndSize {
|
||||
columns: 121,
|
||||
rows: 20,
|
||||
x: 0,
|
||||
y: 0,
|
||||
};
|
||||
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
||||
fake_input_output.add_terminal_input(&[
|
||||
|
@ -1,7 +1,10 @@
|
||||
use crate::terminal_pane::PositionAndSize;
|
||||
use crate::terminal_pane::TerminalPane;
|
||||
use ::nix::pty::Winsize;
|
||||
|
||||
pub fn get_output_frame_snapshots(output_frames: &[Vec<u8>], win_size: &Winsize) -> Vec<String> {
|
||||
pub fn get_output_frame_snapshots(
|
||||
output_frames: &[Vec<u8>],
|
||||
win_size: &PositionAndSize,
|
||||
) -> Vec<String> {
|
||||
let mut vte_parser = vte::Parser::new();
|
||||
let main_pid = 0;
|
||||
let x = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user