Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compatibility): pass vttest 8 #461

Merged
merged 3 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/client/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub struct Grid {
pub should_render: bool,
pub cursor_key_mode: bool, // DECCKM - when set, cursor keys should send ANSI direction codes (eg. "OD") instead of the arrow keys (eg. "")
pub erasure_mode: bool, // ERM
pub insert_mode: bool,
pub disable_linewrap: bool,
pub clear_viewport_before_rendering: bool,
pub width: usize,
Expand Down Expand Up @@ -212,6 +213,7 @@ impl Grid {
should_render: true,
cursor_key_mode: false,
erasure_mode: false,
insert_mode: false,
disable_linewrap: false,
alternative_lines_above_viewport_and_cursor: None,
clear_viewport_before_rendering: false,
Expand Down Expand Up @@ -606,7 +608,13 @@ impl Grid {
}
pub fn add_character_at_cursor_position(&mut self, terminal_character: TerminalCharacter) {
match self.viewport.get_mut(self.cursor.y) {
Some(row) => row.add_character_at(terminal_character, self.cursor.x),
Some(row) => {
if self.insert_mode {
row.insert_character_at(terminal_character, self.cursor.x);
} else {
row.add_character_at(terminal_character, self.cursor.x);
}
}
None => {
// pad lines until cursor if they do not exist
for _ in self.viewport.len()..self.cursor.y {
Expand Down Expand Up @@ -1095,6 +1103,8 @@ impl vte::Perform for Grid {
}
_ => {}
};
} else if let Some(&4) = params.get(0) {
self.insert_mode = false;
}
} else if c == 'h' {
let first_intermediate_is_questionmark = match _intermediates.get(0) {
Expand Down Expand Up @@ -1138,6 +1148,8 @@ impl vte::Perform for Grid {
}
_ => {}
};
} else if let Some(&4) = params.get(0) {
self.insert_mode = true;
}
} else if c == 'r' {
if params.len() > 1 {
Expand Down
72 changes: 72 additions & 0 deletions src/client/panes/unit/grid_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,75 @@ fn vttest3_0() {
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_0() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-0";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_1() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-1";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_2() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-2";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_3() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-3";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_4() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-4";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}

#[test]
fn vttest8_5() {
let mut vte_parser = vte::Parser::new();
let mut grid = Grid::new(51, 97);
let fixture_name = "vttest8-5";
let content = read_fixture(fixture_name);
for byte in content {
vte_parser.advance(&mut grid, byte);
}
assert_snapshot!(format!("{:?}", grid));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
01 (C): Top line: A's, bottom line: X's, this line, nothing more. Push <RETURN>
02 (C):
03 (C):
04 (C):
05 (C):
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C): XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): A******************************************************************************BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
01 (C):
02 (C):
03 (C): Test of 'Insert Mode'. The top line should be 'A*** ... ***B'. Push <RETURN>
04 (C):
05 (C):
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
01 (C):
02 (C):
03 (C): Test of 'Delete Character'. The top line should be 'AB'. Push <RETURN>
04 (C):
05 (C):
06 (C):
07 (C):
08 (C):
09 (C):
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
01 (C): BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
02 (C): CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
03 (C): The right column should be staggered DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
04 (C): by one. Push <RETURN>EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
05 (C): FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
06 (C): GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
07 (C): HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
08 (C): IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
09 (C): JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
10 (C): KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
11 (C): LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
12 (C): MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
13 (C): NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
14 (C): OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
15 (C): PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
16 (C): QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
17 (C): RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
18 (C): SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
19 (C): TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
20 (C): UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
21 (C): VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
22 (C): WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
23 (C): XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
01 (C): BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
02 (C): CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
03 (C): The right column should be staggered
04 (C): by one. Push <RETURN>EEEEEEEEEEEEE
05 (C): FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
06 (C): GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
07 (C): HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
08 (C): IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
09 (C): JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
10 (C): KKKKKKKKKKKKKKKKKKKKKKKKKKKKK
11 (C): LLLLLLLLLLLLLLLLLLLLLLLLLLLL
12 (C): MMMMMMMMMMMMMMMMMMMMMMMMMMM
13 (C): NNNNNNNNNNNNNNNNNNNNNNNNNN
14 (C): OOOOOOOOOOOOOOOOOOOOOOOOO
15 (C): PPPPPPPPPPPPPPPPPPPPPPPP
16 (C): QQQQQQQQQQQQQQQQQQQQQQQ
17 (C): RRRRRRRRRRRRRRRRRRRRRR
18 (C): SSSSSSSSSSSSSSSSSSSSS
19 (C): TTTTTTTTTTTTTTTTTTTT
20 (C): UUUUUUUUUUUUUUUUUUU
21 (C): VVVVVVVVVVVVVVVVVV
22 (C): WWWWWWWWWWWWWWWWW
23 (C): XXXXXXXXXXXXXXXX

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: src/client/panes/./unit/grid_tests.rs
expression: "format!(\"{:?}\", grid)"

---
00 (C): If your terminal has the ANSI 'Insert Character' function
01 (C): (the VT102 does not), then you should see a line like this
02 (C): A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
03 (C): below:
04 (C):
05 (C): A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
06 (C):
07 (C):
08 (C):
09 (C): Push <RETURN>
10 (C):
11 (C):
12 (C):
13 (C):
14 (C):
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):
20 (C):
21 (C):
22 (C):
23 (C):

Loading