aboutsummaryrefslogtreecommitdiff
path: root/src/table.rs.in
blob: 5593283f371784bba048c2f9e172337b5be7cec3 (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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/// This is the state change table. It's indexed first by current state and then by the next
/// character in the pty stream.

use definitions::Action;

pub static STATE_CHANGE: [[u8; 256]; 16] = vt_state_table! {
    State::Anywhere => {
        0x18        => (Action::Execute, State::Ground),
        0x1a        => (Action::Execute, State::Ground),
        0x1b        => State::Escape,
    },

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

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

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

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

    State::CsiIgnore => {
        0x00...0x17 => Action::Execute,
        0x19        => Action::Execute,
        0x1c...0x1f => Action::Execute,
        0x20...0x3f => Action::Ignore,
        0x7f        => Action::Ignore,
        0x40...0x7e => State::Ground,
    },

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

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

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

    State::DcsIntermediate => {
        0x00...0x17 => Action::Ignore,
        0x19        => Action::Ignore,
        0x1c...0x1f => Action::Ignore,
        0x20...0x2f => Action::Collect,
        0x7f        => Action::Ignore,
        0x30...0x3f => State::DcsIgnore,
        0x40...0x7e => State::DcsPassthrough
    },

    State::DcsIgnore => {
        0x00...0x17 => Action::Ignore,
        0x19        => Action::Ignore,
        0x1c...0x1f => Action::Ignore,
        0x20...0x7f => Action::Ignore,
        0x9c        => State::Ground
    },

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

    State::DcsPassthrough => {
        0x00...0x17 => Action::Put,
        0x19        => Action::Put,
        0x1c...0x1f => Action::Put,
        0x20...0x7e => Action::Put,
        0x7f        => Action::Ignore,
        0x9c        => State::Ground,
    },

    State::SosPmApcString => {
        0x00...0x17 => Action::Ignore,
        0x19        => Action::Ignore,
        0x1c...0x1f => Action::Ignore,
        0x20...0x7f => Action::Ignore,
        0x9c       => State::Ground
    },

    State::OscString => {
        0x00...0x06 => Action::Ignore,
        0x07        => State::Ground,
        0x08...0x17 => Action::Ignore,
        0x19        => Action::Ignore,
        0x1c...0x1f => Action::Ignore,
        0x20...0xff => Action::OscPut,
    }
};

pub static ENTRY_ACTIONS: &'static [Action] = &[
   Action::None,     // State::Anywhere
   Action::Clear,    // State::CsiEntry
   Action::None,     // State::CsiIgnore
   Action::None,     // State::CsiIntermediate
   Action::None,     // State::CsiParam
   Action::Clear,    // State::DcsEntry
   Action::None,     // State::DcsIgnore
   Action::None,     // State::DcsIntermediate
   Action::None,     // State::DcsParam
   Action::Hook,     // State::DcsPassthrough
   Action::Clear,    // State::Escape
   Action::None,     // State::EscapeIntermediate
   Action::None,     // State::Ground
   Action::OscStart, // State::OscString
   Action::None,     // State::SosPmApcString
   Action::None,     // State::Utf8
];

pub static EXIT_ACTIONS: &'static [Action] = &[
   Action::None,   // State::Anywhere
   Action::None,   // State::CsiEntry
   Action::None,   // State::CsiIgnore
   Action::None,   // State::CsiIntermediate
   Action::None,   // State::CsiParam
   Action::None,   // State::DcsEntry
   Action::None,   // State::DcsIgnore
   Action::None,   // State::DcsIntermediate
   Action::None,   // State::DcsParam
   Action::Unhook, // State::DcsPassthrough
   Action::None,   // State::Escape
   Action::None,   // State::EscapeIntermediate
   Action::None,   // State::Ground
   Action::OscEnd, // State::OscString
   Action::None,   // State::SosPmApcString
   Action::None,   // State::Utf8
];