test(layout): horizontal split
This commit is contained in:
parent
29a12b5b2d
commit
f42c13da8e
9 changed files with 146 additions and 6 deletions
|
|
@ -866,7 +866,7 @@ impl Screen {
|
|||
if terminal.x_coords + terminal.display_cols < self.full_screen_ws.ws_col {
|
||||
let boundary_x_coords = terminal.x_coords + terminal.display_cols;
|
||||
let mut vte_output_boundaries = String::new();
|
||||
for row in terminal.y_coords..=terminal.y_coords + terminal.display_rows {
|
||||
for row in terminal.y_coords..terminal.y_coords + terminal.display_rows {
|
||||
vte_output_boundaries.push_str(&format!("\u{1b}[{};{}H\u{1b}[m", row + 1, boundary_x_coords + 1)); // goto row/col
|
||||
vte_output_boundaries.push_str(&self.vertical_separator.to_string());
|
||||
}
|
||||
|
|
@ -875,7 +875,7 @@ impl Screen {
|
|||
if terminal.y_coords + terminal.display_rows < self.full_screen_ws.ws_row {
|
||||
let boundary_y_coords = terminal.y_coords + terminal.display_rows;
|
||||
let mut vte_output_boundaries = String::new();
|
||||
for col in terminal.x_coords..=terminal.x_coords + terminal.display_cols {
|
||||
for col in terminal.x_coords..terminal.x_coords + terminal.display_cols {
|
||||
vte_output_boundaries.push_str(&format!("\u{1b}[{};{}H\u{1b}[m", boundary_y_coords + 1, col + 1)); // goto row/col
|
||||
vte_output_boundaries.push_str(&self.horizontal_separator.to_string());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,3 +99,47 @@ pub fn split_terminals_vertically() {
|
|||
assert_snapshot!(snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn split_terminals_horizontally() {
|
||||
// TODO: this test is a little flaky - there's some sort of race condition that makes the
|
||||
// second terminal in the split appear blank sometimes - fix this
|
||||
let mut fake_input_output = get_fake_os_input();
|
||||
fake_input_output.add_terminal_input(&[8, 17]); // split-horizontally and quit (ctrl-n + ctrl-q)
|
||||
start(Box::new(fake_input_output.clone()));
|
||||
|
||||
let output_frames = fake_input_output.stdout_writer.output_frames.lock().unwrap();
|
||||
let mut vte_parser = vte::Parser::new();
|
||||
let main_pid = 0;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
let fake_win_size = Winsize { // TODO: combine with above
|
||||
ws_col: 121,
|
||||
ws_row: 20,
|
||||
ws_xpixel: 0,
|
||||
ws_ypixel: 0,
|
||||
};
|
||||
let mut terminal_output = TerminalOutput::new(main_pid, fake_win_size, x, y);
|
||||
|
||||
for frame in output_frames.iter() {
|
||||
for byte in frame.iter() {
|
||||
vte_parser.advance(&mut terminal_output, *byte);
|
||||
}
|
||||
let output_lines = terminal_output.read_buffer_as_lines();
|
||||
let cursor_position_in_last_line = terminal_output.cursor_position_in_last_line();
|
||||
let mut snapshot = String::new();
|
||||
for (line_index, line) in output_lines.iter().enumerate() {
|
||||
for (character_index, terminal_character) in line.iter().enumerate() {
|
||||
if line_index == output_lines.len() - 1 && character_index == cursor_position_in_last_line {
|
||||
snapshot.push('█');
|
||||
} else {
|
||||
snapshot.push(terminal_character.character);
|
||||
}
|
||||
}
|
||||
if line_index != output_lines.len() - 1 {
|
||||
snapshot.push('\n');
|
||||
}
|
||||
}
|
||||
assert_snapshot!(snapshot);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
source: src/tests/integration.rs
|
||||
expression: snapshot
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ 10:47:03
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
source: src/tests/integration.rs
|
||||
expression: snapshot
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ 10:47:03
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ █ 10:47:03
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
source: src/tests/integration.rs
|
||||
expression: snapshot
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ 10:47:03
|
||||
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ 10:47:03
|
||||
Bye from Mosaic!
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
source: src/tests/integration.rs
|
||||
expression: snapshot
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ █ 10:47:03
|
||||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
|||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
Welcome to fish, the friendly interactive shell │
|
||||
│
|
||||
│
|
||||
⋊> ~/c/mosaic on main ⨯ │
|
||||
│
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
|||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
Welcome to fish, the friendly interactive shell │
|
||||
│
|
||||
│Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ │⋊> ~/c/mosaic on main ⨯ 19:40:00
|
||||
│
|
||||
⋊> ~/c/mosaic on main ⨯ │⋊> ~/c/mosaic on main ⨯ █ 19:40:00
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ expression: snapshot
|
|||
│
|
||||
│
|
||||
│
|
||||
│
|
||||
Welcome to fish, the friendly interactive shell │
|
||||
│
|
||||
│Welcome to fish, the friendly interactive shell
|
||||
⋊> ~/c/mosaic on main ⨯ │⋊> ~/c/mosaic on main ⨯ 19:40:00
|
||||
│
|
||||
Bye from Mosaic!
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue