1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#![allow(clippy::cognitive_complexity)]
#[test]
fn deckpam() {
let mut screen = vt100::Screen::new(24, 80);
assert!(!screen.application_keypad());
screen.process(b"\x1b=");
assert!(screen.application_keypad());
screen.process(b"\x1b>");
assert!(!screen.application_keypad());
}
#[test]
fn ri() {
let mut screen = vt100::Screen::new(24, 80);
screen.process(b"foo\nbar\x1bMbaz");
assert_eq!(
screen.window_contents(0, 0, 23, 79),
"foo baz\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
}
#[test]
fn ris() {
let mut screen = vt100::Screen::new(24, 80);
assert_eq!(screen.cursor_position(), (0, 0));
let cell = screen.cell(0, 0).unwrap();
assert_eq!(cell.contents(), "");
assert_eq!(
screen.window_contents(0, 0, 23, 79),
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(
screen.window_contents_formatted(0, 0, 23, 79),
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.title(), "");
assert_eq!(screen.icon_name(), "");
assert_eq!(screen.fgcolor(), vt100::Color::Default);
assert_eq!(screen.bgcolor(), vt100::Color::Default);
assert!(!screen.bold());
assert!(!screen.italic());
assert!(!screen.underline());
assert!(!screen.inverse());
assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(!screen.application_cursor());
assert!(!screen.mouse_reporting_press());
assert!(!screen.mouse_reporting_press_release());
assert!(!screen.mouse_reporting_button_motion());
assert!(!screen.mouse_reporting_sgr_mode());
assert!(!screen.bracketed_paste());
assert!(!screen.check_visual_bell());
assert!(!screen.check_audible_bell());
screen.process(b"f\x1b[31m\x1b[47;1;3;4moo\x1b[7m\x1b[21;21H\x1b]2;window title\x07\x1b]1;window icon name\x07\x1b[?25l\x1b[?1h\x1b=\x1b[?9h\x1b[?1000h\x1b[?1002h\x1b[?1006h\x1b[?2004h\x07\x1bg");
assert_eq!(screen.cursor_position(), (20, 20));
let cell = screen.cell(0, 0).unwrap();
assert_eq!(cell.contents(), "f");
assert_eq!(
screen.window_contents(0, 0, 23, 79),
"foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(screen.window_contents_formatted(0, 0, 23, 79), "f\x1b[31;47;1;3;4moo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
assert_eq!(screen.title(), "window title");
assert_eq!(screen.icon_name(), "window icon name");
assert_eq!(screen.fgcolor(), vt100::Color::Idx(1));
assert_eq!(screen.bgcolor(), vt100::Color::Idx(7));
assert!(screen.bold());
assert!(screen.italic());
assert!(screen.underline());
assert!(screen.inverse());
assert!(screen.hide_cursor());
assert!(screen.application_keypad());
assert!(screen.application_cursor());
assert!(screen.mouse_reporting_press());
assert!(screen.mouse_reporting_press_release());
assert!(screen.mouse_reporting_button_motion());
assert!(screen.mouse_reporting_sgr_mode());
assert!(screen.bracketed_paste());
assert!(screen.check_visual_bell());
assert!(screen.check_audible_bell());
screen.process(b"\x1bc");
assert_eq!(screen.cursor_position(), (0, 0));
let cell = screen.cell(0, 0).unwrap();
assert_eq!(cell.contents(), "");
assert_eq!(
screen.window_contents(0, 0, 23, 79),
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
assert_eq!(
screen.window_contents_formatted(0, 0, 23, 79),
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
// title and icon name don't change with reset
assert_eq!(screen.title(), "window title");
assert_eq!(screen.icon_name(), "window icon name");
assert_eq!(screen.fgcolor(), vt100::Color::Default);
assert_eq!(screen.bgcolor(), vt100::Color::Default);
assert!(!screen.bold());
assert!(!screen.italic());
assert!(!screen.underline());
assert!(!screen.inverse());
assert!(!screen.hide_cursor());
assert!(!screen.application_keypad());
assert!(!screen.application_cursor());
assert!(!screen.mouse_reporting_press());
assert!(!screen.mouse_reporting_press_release());
assert!(!screen.mouse_reporting_button_motion());
assert!(!screen.mouse_reporting_sgr_mode());
assert!(!screen.bracketed_paste());
assert!(!screen.check_visual_bell());
assert!(!screen.check_audible_bell());
}
#[test]
fn vb() {
let mut screen = vt100::Screen::new(24, 80);
assert!(!screen.check_visual_bell());
screen.process(b"\x1bg");
assert!(screen.check_visual_bell());
assert!(!screen.check_visual_bell());
}
#[test]
fn decsc() {
let mut screen = vt100::Screen::new(24, 80);
screen.process(b"foo\x1b7\r\n\r\n\r\n bar\x1b8baz");
assert_eq!(
screen.window_contents(0, 0, 23, 79),
"foobaz\n\n\n bar\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
);
}
|