fix(compatibility): ansi scroll down (#1279)
* fix(compatibility): ansi scroll down * style(fmt): rustfmt
This commit is contained in:
parent
a4ad296875
commit
6443a727ea
4 changed files with 94 additions and 16 deletions
3
src/tests/fixtures/scroll_down
vendored
Executable file
3
src/tests/fixtures/scroll_down
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
line1[Sline2
|
||||||
|
|
@ -814,30 +814,31 @@ impl Grid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn rotate_scroll_region_up(&mut self, count: usize) {
|
pub fn rotate_scroll_region_up(&mut self, count: usize) {
|
||||||
if let Some((scroll_region_top, scroll_region_bottom)) = self.scroll_region {
|
if let Some((scroll_region_top, scroll_region_bottom)) = self
|
||||||
|
.scroll_region
|
||||||
|
.or(Some((0, self.height.saturating_sub(1))))
|
||||||
|
{
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
let columns = VecDeque::from(vec![EMPTY_TERMINAL_CHARACTER; self.width]);
|
if self.cursor.y >= scroll_region_top && self.cursor.y <= scroll_region_bottom {
|
||||||
if scroll_region_bottom < self.viewport.len() {
|
self.pad_lines_until(scroll_region_bottom, EMPTY_TERMINAL_CHARACTER);
|
||||||
|
if self.viewport.get(scroll_region_bottom).is_some() {
|
||||||
self.viewport.remove(scroll_region_bottom);
|
self.viewport.remove(scroll_region_bottom);
|
||||||
}
|
}
|
||||||
if scroll_region_top < self.viewport.len() {
|
|
||||||
self.viewport
|
|
||||||
.insert(scroll_region_top, Row::from_columns(columns).canonical());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.output_buffer.update_all_lines(); // TODO: only update scroll region lines
|
self.output_buffer.update_all_lines(); // TODO: only update scroll region lines
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn rotate_scroll_region_down(&mut self, count: usize) {
|
pub fn rotate_scroll_region_down(&mut self, count: usize) {
|
||||||
if let Some((scroll_region_top, scroll_region_bottom)) = self.scroll_region {
|
if let Some((scroll_region_top, scroll_region_bottom)) = self
|
||||||
|
.scroll_region
|
||||||
|
.or(Some((0, self.height.saturating_sub(1))))
|
||||||
|
{
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
let columns = VecDeque::from(vec![EMPTY_TERMINAL_CHARACTER; self.width]);
|
if self.cursor.y >= scroll_region_top && self.cursor.y <= scroll_region_bottom {
|
||||||
|
self.pad_lines_until(scroll_region_top, EMPTY_TERMINAL_CHARACTER);
|
||||||
self.viewport.remove(scroll_region_top);
|
self.viewport.remove(scroll_region_top);
|
||||||
if self.viewport.len() > scroll_region_top {
|
self.pad_lines_until(scroll_region_bottom, EMPTY_TERMINAL_CHARACTER);
|
||||||
self.viewport
|
|
||||||
.insert(scroll_region_bottom, Row::from_columns(columns).canonical());
|
|
||||||
} else {
|
|
||||||
self.viewport.push(Row::from_columns(columns).canonical());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.output_buffer.update_all_lines(); // TODO: only update scroll region lines
|
self.output_buffer.update_all_lines(); // TODO: only update scroll region lines
|
||||||
|
|
|
||||||
|
|
@ -1602,3 +1602,20 @@ pub fn replace_non_wide_characters_with_wide_characters() {
|
||||||
}
|
}
|
||||||
assert_snapshot!(format!("{:?}", grid));
|
assert_snapshot!(format!("{:?}", grid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn scroll_down_ansi() {
|
||||||
|
let mut vte_parser = vte::Parser::new();
|
||||||
|
let mut grid = Grid::new(
|
||||||
|
51,
|
||||||
|
112,
|
||||||
|
Palette::default(),
|
||||||
|
Rc::new(RefCell::new(LinkHandler::new())),
|
||||||
|
);
|
||||||
|
let fixture_name = "scroll_down";
|
||||||
|
let content = read_fixture(fixture_name);
|
||||||
|
for byte in content {
|
||||||
|
vte_parser.advance(&mut grid, byte);
|
||||||
|
}
|
||||||
|
assert_snapshot!(format!("{:?}", grid));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
---
|
||||||
|
source: zellij-server/src/panes/./unit/grid_tests.rs
|
||||||
|
assertion_line: 1620
|
||||||
|
expression: "format!(\"{:?}\", grid)"
|
||||||
|
---
|
||||||
|
00 (C):
|
||||||
|
01 (C): line1
|
||||||
|
02 (C): line2
|
||||||
|
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):
|
||||||
|
24 (C):
|
||||||
|
25 (C):
|
||||||
|
26 (C):
|
||||||
|
27 (C):
|
||||||
|
28 (C):
|
||||||
|
29 (C):
|
||||||
|
30 (C):
|
||||||
|
31 (C):
|
||||||
|
32 (C):
|
||||||
|
33 (C):
|
||||||
|
34 (C):
|
||||||
|
35 (C):
|
||||||
|
36 (C):
|
||||||
|
37 (C):
|
||||||
|
38 (C):
|
||||||
|
39 (C):
|
||||||
|
40 (C):
|
||||||
|
41 (C):
|
||||||
|
42 (C):
|
||||||
|
43 (C):
|
||||||
|
44 (C):
|
||||||
|
45 (C):
|
||||||
|
46 (C):
|
||||||
|
47 (C):
|
||||||
|
48 (C):
|
||||||
|
49 (C):
|
||||||
|
50 (C):
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue