vte/
table.rs

1/// This is the state change table. It's indexed first by current state and then by the next
2/// character in the pty stream.
3use crate::definitions::{pack, Action, State};
4
5use vte_generate_state_changes::generate_state_changes;
6
7// Generate state changes at compile-time
8pub static STATE_CHANGES: [[u8; 256]; 16] = state_changes();
9generate_state_changes!(state_changes, {
10    Anywhere {
11        0x18 => (Ground, Execute),
12        0x1a => (Ground, Execute),
13        0x1b => (Escape, None),
14    },
15
16    Ground {
17        0x00..=0x17 => (Anywhere, Execute),
18        0x19        => (Anywhere, Execute),
19        0x1c..=0x1f => (Anywhere, Execute),
20        0x20..=0x7f => (Anywhere, Print),
21        0x80..=0x8f => (Anywhere, Execute),
22        0x91..=0x9a => (Anywhere, Execute),
23        0x9c        => (Anywhere, Execute),
24        // Beginning of UTF-8 2 byte sequence
25        0xc2..=0xdf => (Utf8, BeginUtf8),
26        // Beginning of UTF-8 3 byte sequence
27        0xe0..=0xef => (Utf8, BeginUtf8),
28        // Beginning of UTF-8 4 byte sequence
29        0xf0..=0xf4 => (Utf8, BeginUtf8),
30    },
31
32    Escape {
33        0x00..=0x17 => (Anywhere, Execute),
34        0x19        => (Anywhere, Execute),
35        0x1c..=0x1f => (Anywhere, Execute),
36        0x7f        => (Anywhere, Ignore),
37        0x20..=0x2f => (EscapeIntermediate, Collect),
38        0x30..=0x4f => (Ground, EscDispatch),
39        0x51..=0x57 => (Ground, EscDispatch),
40        0x59        => (Ground, EscDispatch),
41        0x5a        => (Ground, EscDispatch),
42        0x5c        => (Ground, EscDispatch),
43        0x60..=0x7e => (Ground, EscDispatch),
44        0x5b        => (CsiEntry, None),
45        0x5d        => (OscString, None),
46        0x50        => (DcsEntry, None),
47        0x58        => (SosPmApcString, None),
48        0x5e        => (SosPmApcString, None),
49        0x5f        => (SosPmApcString, None),
50    },
51
52    EscapeIntermediate {
53        0x00..=0x17 => (Anywhere, Execute),
54        0x19        => (Anywhere, Execute),
55        0x1c..=0x1f => (Anywhere, Execute),
56        0x20..=0x2f => (Anywhere, Collect),
57        0x7f        => (Anywhere, Ignore),
58        0x30..=0x7e => (Ground, EscDispatch),
59    },
60
61    CsiEntry {
62        0x00..=0x17 => (Anywhere, Execute),
63        0x19        => (Anywhere, Execute),
64        0x1c..=0x1f => (Anywhere, Execute),
65        0x7f        => (Anywhere, Ignore),
66        0x20..=0x2f => (CsiIntermediate, Collect),
67        0x30..=0x39 => (CsiParam, Param),
68        0x3a..=0x3b => (CsiParam, Param),
69        0x3c..=0x3f => (CsiParam, Collect),
70        0x40..=0x7e => (Ground, CsiDispatch),
71    },
72
73    CsiIgnore {
74        0x00..=0x17 => (Anywhere, Execute),
75        0x19        => (Anywhere, Execute),
76        0x1c..=0x1f => (Anywhere, Execute),
77        0x20..=0x3f => (Anywhere, Ignore),
78        0x7f        => (Anywhere, Ignore),
79        0x40..=0x7e => (Ground, None),
80    },
81
82    CsiParam {
83        0x00..=0x17 => (Anywhere, Execute),
84        0x19        => (Anywhere, Execute),
85        0x1c..=0x1f => (Anywhere, Execute),
86        0x30..=0x39 => (Anywhere, Param),
87        0x3a..=0x3b => (Anywhere, Param),
88        0x7f        => (Anywhere, Ignore),
89        0x3c..=0x3f => (CsiIgnore, None),
90        0x20..=0x2f => (CsiIntermediate, Collect),
91        0x40..=0x7e => (Ground, CsiDispatch),
92    },
93
94    CsiIntermediate {
95        0x00..=0x17 => (Anywhere, Execute),
96        0x19        => (Anywhere, Execute),
97        0x1c..=0x1f => (Anywhere, Execute),
98        0x20..=0x2f => (Anywhere, Collect),
99        0x7f        => (Anywhere, Ignore),
100        0x30..=0x3f => (CsiIgnore, None),
101        0x40..=0x7e => (Ground, CsiDispatch),
102    },
103
104    DcsEntry {
105        0x00..=0x17 => (Anywhere, Ignore),
106        0x19        => (Anywhere, Ignore),
107        0x1c..=0x1f => (Anywhere, Ignore),
108        0x7f        => (Anywhere, Ignore),
109        0x20..=0x2f => (DcsIntermediate, Collect),
110        0x30..=0x39 => (DcsParam, Param),
111        0x3a..=0x3b => (DcsParam, Param),
112        0x3c..=0x3f => (DcsParam, Collect),
113        0x40..=0x7e => (DcsPassthrough, None),
114    },
115
116    DcsIntermediate {
117        0x00..=0x17 => (Anywhere, Ignore),
118        0x19        => (Anywhere, Ignore),
119        0x1c..=0x1f => (Anywhere, Ignore),
120        0x20..=0x2f => (Anywhere, Collect),
121        0x7f        => (Anywhere, Ignore),
122        0x30..=0x3f => (DcsIgnore, None),
123        0x40..=0x7e => (DcsPassthrough, None),
124    },
125
126    DcsIgnore {
127        0x00..=0x17 => (Anywhere, Ignore),
128        0x19        => (Anywhere, Ignore),
129        0x1c..=0x1f => (Anywhere, Ignore),
130        0x20..=0x7f => (Anywhere, Ignore),
131        0x9c        => (Ground, None),
132    },
133
134    DcsParam {
135        0x00..=0x17 => (Anywhere, Ignore),
136        0x19        => (Anywhere, Ignore),
137        0x1c..=0x1f => (Anywhere, Ignore),
138        0x30..=0x39 => (Anywhere, Param),
139        0x3a..=0x3b => (Anywhere, Param),
140        0x7f        => (Anywhere, Ignore),
141        0x3c..=0x3f => (DcsIgnore, None),
142        0x20..=0x2f => (DcsIntermediate, Collect),
143        0x40..=0x7e => (DcsPassthrough, None),
144    },
145
146    DcsPassthrough {
147        0x00..=0x17 => (Anywhere, Put),
148        0x19        => (Anywhere, Put),
149        0x1c..=0x1f => (Anywhere, Put),
150        0x20..=0x7e => (Anywhere, Put),
151        0x7f        => (Anywhere, Ignore),
152        0x9c        => (Ground, None),
153    },
154
155    SosPmApcString {
156        0x00..=0x17 => (Anywhere, Ignore),
157        0x19        => (Anywhere, Ignore),
158        0x1c..=0x1f => (Anywhere, Ignore),
159        0x20..=0x7f => (Anywhere, Ignore),
160        0x9c        => (Ground, None),
161    },
162
163    OscString {
164        0x00..=0x06 => (Anywhere, Ignore),
165        0x07        => (Ground, None),
166        0x08..=0x17 => (Anywhere, Ignore),
167        0x19        => (Anywhere, Ignore),
168        0x1c..=0x1f => (Anywhere, Ignore),
169        0x20..=0xff => (Anywhere, OscPut),
170    }
171});