vte/
table.rs

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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/// This is the state change table. It's indexed first by current state and then by the next
/// character in the pty stream.
use crate::definitions::{pack, Action, State};

use vte_generate_state_changes::generate_state_changes;

// Generate state changes at compile-time
pub static STATE_CHANGES: [[u8; 256]; 16] = state_changes();
generate_state_changes!(state_changes, {
    Anywhere {
        0x18 => (Ground, Execute),
        0x1a => (Ground, Execute),
        0x1b => (Escape, None),
    },

    Ground {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x20..=0x7f => (Anywhere, Print),
        0x80..=0x8f => (Anywhere, Execute),
        0x91..=0x9a => (Anywhere, Execute),
        0x9c        => (Anywhere, Execute),
        // Beginning of UTF-8 2 byte sequence
        0xc2..=0xdf => (Utf8, BeginUtf8),
        // Beginning of UTF-8 3 byte sequence
        0xe0..=0xef => (Utf8, BeginUtf8),
        // Beginning of UTF-8 4 byte sequence
        0xf0..=0xf4 => (Utf8, BeginUtf8),
    },

    Escape {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x7f        => (Anywhere, Ignore),
        0x20..=0x2f => (EscapeIntermediate, Collect),
        0x30..=0x4f => (Ground, EscDispatch),
        0x51..=0x57 => (Ground, EscDispatch),
        0x59        => (Ground, EscDispatch),
        0x5a        => (Ground, EscDispatch),
        0x5c        => (Ground, EscDispatch),
        0x60..=0x7e => (Ground, EscDispatch),
        0x5b        => (CsiEntry, None),
        0x5d        => (OscString, None),
        0x50        => (DcsEntry, None),
        0x58        => (SosPmApcString, None),
        0x5e        => (SosPmApcString, None),
        0x5f        => (SosPmApcString, None),
    },

    EscapeIntermediate {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x20..=0x2f => (Anywhere, Collect),
        0x7f        => (Anywhere, Ignore),
        0x30..=0x7e => (Ground, EscDispatch),
    },

    CsiEntry {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x7f        => (Anywhere, Ignore),
        0x20..=0x2f => (CsiIntermediate, Collect),
        0x30..=0x39 => (CsiParam, Param),
        0x3a..=0x3b => (CsiParam, Param),
        0x3c..=0x3f => (CsiParam, Collect),
        0x40..=0x7e => (Ground, CsiDispatch),
    },

    CsiIgnore {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x20..=0x3f => (Anywhere, Ignore),
        0x7f        => (Anywhere, Ignore),
        0x40..=0x7e => (Ground, None),
    },

    CsiParam {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x30..=0x39 => (Anywhere, Param),
        0x3a..=0x3b => (Anywhere, Param),
        0x7f        => (Anywhere, Ignore),
        0x3c..=0x3f => (CsiIgnore, None),
        0x20..=0x2f => (CsiIntermediate, Collect),
        0x40..=0x7e => (Ground, CsiDispatch),
    },

    CsiIntermediate {
        0x00..=0x17 => (Anywhere, Execute),
        0x19        => (Anywhere, Execute),
        0x1c..=0x1f => (Anywhere, Execute),
        0x20..=0x2f => (Anywhere, Collect),
        0x7f        => (Anywhere, Ignore),
        0x30..=0x3f => (CsiIgnore, None),
        0x40..=0x7e => (Ground, CsiDispatch),
    },

    DcsEntry {
        0x00..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x7f        => (Anywhere, Ignore),
        0x20..=0x2f => (DcsIntermediate, Collect),
        0x30..=0x39 => (DcsParam, Param),
        0x3a..=0x3b => (DcsParam, Param),
        0x3c..=0x3f => (DcsParam, Collect),
        0x40..=0x7e => (DcsPassthrough, None),
    },

    DcsIntermediate {
        0x00..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x20..=0x2f => (Anywhere, Collect),
        0x7f        => (Anywhere, Ignore),
        0x30..=0x3f => (DcsIgnore, None),
        0x40..=0x7e => (DcsPassthrough, None),
    },

    DcsIgnore {
        0x00..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x20..=0x7f => (Anywhere, Ignore),
        0x9c        => (Ground, None),
    },

    DcsParam {
        0x00..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x30..=0x39 => (Anywhere, Param),
        0x3a..=0x3b => (Anywhere, Param),
        0x7f        => (Anywhere, Ignore),
        0x3c..=0x3f => (DcsIgnore, None),
        0x20..=0x2f => (DcsIntermediate, Collect),
        0x40..=0x7e => (DcsPassthrough, None),
    },

    DcsPassthrough {
        0x00..=0x17 => (Anywhere, Put),
        0x19        => (Anywhere, Put),
        0x1c..=0x1f => (Anywhere, Put),
        0x20..=0x7e => (Anywhere, Put),
        0x7f        => (Anywhere, Ignore),
        0x9c        => (Ground, None),
    },

    SosPmApcString {
        0x00..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x20..=0x7f => (Anywhere, Ignore),
        0x9c        => (Ground, None),
    },

    OscString {
        0x00..=0x06 => (Anywhere, Ignore),
        0x07        => (Ground, None),
        0x08..=0x17 => (Anywhere, Ignore),
        0x19        => (Anywhere, Ignore),
        0x1c..=0x1f => (Anywhere, Ignore),
        0x20..=0xff => (Anywhere, OscPut),
    }
});