aboutsummaryrefslogtreecommitdiffstats
path: root/t/escape_test.py
blob: 25d7f1805d8e070a1e074aeba102ba5a1d8c6860 (plain) (blame)
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
from . import VT100Test

class EscapeTest(VT100Test):
    def test_deckpam(self):
        assert not self.vt.application_keypad()
        self.process("\033=")
        assert self.vt.application_keypad()
        self.process("\033>")
        assert not self.vt.application_keypad()

    def test_ri(self):
        self.process("foo\nbar\033Mbaz")
        assert self.vt.window_contents() == 'foo   baz\n   bar' + ('\n' * 23)

    def test_ris(self):
        row, col = self.vt.cursor_position()
        assert row == 0
        assert col == 0

        cell = self.vt.cell(0, 0)
        assert cell.contents() == ""

        assert self.vt.window_contents() == ('\n' * 24)
        assert self.vt.window_contents_formatted() == ('\n' * 24)

        assert self.vt.title() == ""
        assert self.vt.icon_name() == ""

        assert self.vt.fgcolor() is None
        assert self.vt.bgcolor() is None

        assert not self.vt.bold()
        assert not self.vt.italic()
        assert not self.vt.underline()
        assert not self.vt.inverse()

        assert not self.vt.hide_cursor()
        assert not self.vt.application_keypad()
        assert not self.vt.application_cursor()
        assert not self.vt.mouse_reporting_press()
        assert not self.vt.mouse_reporting_press_release()
        assert not self.vt.mouse_reporting_button_motion()
        assert not self.vt.mouse_reporting_sgr_mode()
        assert not self.vt.bracketed_paste()
        assert not self.vt.seen_visual_bell()
        assert not self.vt.seen_audible_bell()

        self.process("f\033[31m\033[47;1;3;4moo\033[7m\033[21;21H\033]2;window title\007\033]1;window icon name\007\033[?25l\033[?1h\033=\033[?9h\033[?1000h\033[?1002h\033[?1006h\033[?2004h\007\033g")

        row, col = self.vt.cursor_position()
        assert row == 20
        assert col == 20

        cell = self.vt.cell(0, 0)
        assert cell.contents() == "f"

        assert self.vt.window_contents() == 'foo' + ('\n' * 24)
        assert self.vt.window_contents_formatted() == 'f\033[31;47;1;3;4moo' + ('\n' * 24)

        assert self.vt.title() == "window title"
        assert self.vt.icon_name() == "window icon name"

        assert self.vt.fgcolor() == 1
        assert self.vt.bgcolor() == 7

        assert self.vt.bold()
        assert self.vt.italic()
        assert self.vt.underline()
        assert self.vt.inverse()

        assert self.vt.hide_cursor()
        assert self.vt.application_keypad()
        assert self.vt.application_cursor()
        assert self.vt.mouse_reporting_press()
        assert self.vt.mouse_reporting_press_release()
        assert self.vt.mouse_reporting_button_motion()
        assert self.vt.mouse_reporting_sgr_mode()
        assert self.vt.bracketed_paste()
        assert self.vt.seen_visual_bell()
        assert self.vt.seen_audible_bell()

        self.process("\033c")

        row, col = self.vt.cursor_position()
        assert row == 0
        assert col == 0

        cell = self.vt.cell(0, 0)
        assert cell.contents() == ""

        assert self.vt.window_contents() == ('\n' * 24)
        assert self.vt.window_contents_formatted() == ('\n' * 24)

        # title and icon name don't change with reset
        assert self.vt.title() == "window title"
        assert self.vt.icon_name() == "window icon name"

        assert self.vt.fgcolor() is None
        assert self.vt.bgcolor() is None

        assert not self.vt.bold()
        assert not self.vt.italic()
        assert not self.vt.underline()
        assert not self.vt.inverse()

        assert not self.vt.hide_cursor()
        assert not self.vt.application_keypad()
        assert not self.vt.application_cursor()
        assert not self.vt.mouse_reporting_press()
        assert not self.vt.mouse_reporting_press_release()
        assert not self.vt.mouse_reporting_button_motion()
        assert not self.vt.mouse_reporting_sgr_mode()
        assert not self.vt.bracketed_paste()
        assert not self.vt.seen_visual_bell()
        assert not self.vt.seen_audible_bell()

    def test_vb(self):
        assert not self.vt.seen_visual_bell()
        self.process("\033g")
        assert self.vt.seen_visual_bell()
        assert not self.vt.seen_visual_bell()

    def test_decsc(self):
        self.process("foo\0337\r\n\r\n\r\n         bar\0338baz")
        assert self.vt.window_contents() == 'foobaz\n\n\n         bar' + ('\n' * 21)