comparison src/libvterm/src/parser.c @ 20518:a4652d7ec99f v8.2.0813

patch 8.2.0813: libvterm code is slightly different from upstream Commit: https://github.com/vim/vim/commit/591cec8366e87a172495c362477cbf5de8d399f0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 22:06:06 2020 +0200 patch 8.2.0813: libvterm code is slightly different from upstream Problem: libvterm code is slightly different from upstream. Solution: Use upstream text to avoid future merge problems. Mainly comment style changes.
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 22:15:04 +0200
parents 55a373a243c0
children f93337ae0612
comparison
equal deleted inserted replaced
20517:a7c6cd0d7ba0 20518:a4652d7ec99f
32 } 32 }
33 #endif 33 #endif
34 34
35 if(vt->parser.callbacks && vt->parser.callbacks->csi) 35 if(vt->parser.callbacks && vt->parser.callbacks->csi)
36 if((*vt->parser.callbacks->csi)( 36 if((*vt->parser.callbacks->csi)(
37 vt->parser.v.csi.leaderlen ? vt->parser.v.csi.leader : NULL, 37 vt->parser.v.csi.leaderlen ? vt->parser.v.csi.leader : NULL,
38 vt->parser.v.csi.args, 38 vt->parser.v.csi.args,
39 vt->parser.v.csi.argi, 39 vt->parser.v.csi.argi,
40 vt->parser.intermedlen ? vt->parser.intermed : NULL, 40 vt->parser.intermedlen ? vt->parser.intermed : NULL,
41 command, 41 command,
42 vt->parser.cbdata)) 42 vt->parser.cbdata))
185 } 185 }
186 } 186 }
187 187
188 switch(vt->parser.state) { 188 switch(vt->parser.state) {
189 case CSI_LEADER: 189 case CSI_LEADER:
190 // Extract leader bytes 0x3c to 0x3f 190 /* Extract leader bytes 0x3c to 0x3f */
191 if(c >= 0x3c && c <= 0x3f) { 191 if(c >= 0x3c && c <= 0x3f) {
192 if(vt->parser.v.csi.leaderlen < CSI_LEADER_MAX-1) 192 if(vt->parser.v.csi.leaderlen < CSI_LEADER_MAX-1)
193 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen++] = c; 193 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen++] = c;
194 break; 194 break;
195 } 195 }
196 196
197 // else fallthrough 197 /* else fallthrough */
198 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen] = 0; 198 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen] = 0;
199 199
200 vt->parser.v.csi.argi = 0; 200 vt->parser.v.csi.argi = 0;
201 vt->parser.v.csi.args[0] = CSI_ARG_MISSING; 201 vt->parser.v.csi.args[0] = CSI_ARG_MISSING;
202 vt->parser.state = CSI_ARGS; 202 vt->parser.state = CSI_ARGS;
203 203
204 // fallthrough 204 /* fallthrough */
205 case CSI_ARGS: 205 case CSI_ARGS:
206 // Numerical value of argument 206 /* Numerical value of argument */
207 if(c >= '0' && c <= '9') { 207 if(c >= '0' && c <= '9') {
208 if(vt->parser.v.csi.args[vt->parser.v.csi.argi] == CSI_ARG_MISSING) 208 if(vt->parser.v.csi.args[vt->parser.v.csi.argi] == CSI_ARG_MISSING)
209 vt->parser.v.csi.args[vt->parser.v.csi.argi] = 0; 209 vt->parser.v.csi.args[vt->parser.v.csi.argi] = 0;
210 vt->parser.v.csi.args[vt->parser.v.csi.argi] *= 10; 210 vt->parser.v.csi.args[vt->parser.v.csi.argi] *= 10;
211 vt->parser.v.csi.args[vt->parser.v.csi.argi] += c - '0'; 211 vt->parser.v.csi.args[vt->parser.v.csi.argi] += c - '0';
219 vt->parser.v.csi.argi++; 219 vt->parser.v.csi.argi++;
220 vt->parser.v.csi.args[vt->parser.v.csi.argi] = CSI_ARG_MISSING; 220 vt->parser.v.csi.args[vt->parser.v.csi.argi] = CSI_ARG_MISSING;
221 break; 221 break;
222 } 222 }
223 223
224 // else fallthrough 224 /* else fallthrough */
225 vt->parser.v.csi.argi++; 225 vt->parser.v.csi.argi++;
226 vt->parser.intermedlen = 0; 226 vt->parser.intermedlen = 0;
227 vt->parser.state = CSI_INTERMED; 227 vt->parser.state = CSI_INTERMED;
228 // fallthrough 228 // fallthrough
229 case CSI_INTERMED: 229 case CSI_INTERMED:
231 if(vt->parser.intermedlen < INTERMED_MAX-1) 231 if(vt->parser.intermedlen < INTERMED_MAX-1)
232 vt->parser.intermed[vt->parser.intermedlen++] = c; 232 vt->parser.intermed[vt->parser.intermedlen++] = c;
233 break; 233 break;
234 } 234 }
235 else if(c == 0x1b) { 235 else if(c == 0x1b) {
236 // ESC in CSI cancels 236 /* ESC in CSI cancels */
237 } 237 }
238 else if(c >= 0x40 && c <= 0x7e) { 238 else if(c >= 0x40 && c <= 0x7e) {
239 vt->parser.intermed[vt->parser.intermedlen] = 0; 239 vt->parser.intermed[vt->parser.intermedlen] = 0;
240 do_csi(vt, c); 240 do_csi(vt, c);
241 } 241 }
242 // else was invalid CSI 242 /* else was invalid CSI */
243 243
244 ENTER_NORMAL_STATE(); 244 ENTER_NORMAL_STATE();
245 break; 245 break;
246 246
247 case OSC_COMMAND: 247 case OSC_COMMAND:
328 if(vt->parser.callbacks && vt->parser.callbacks->text) 328 if(vt->parser.callbacks && vt->parser.callbacks->text)
329 eaten = (*vt->parser.callbacks->text)(bytes + pos, len - pos, vt->parser.cbdata); 329 eaten = (*vt->parser.callbacks->text)(bytes + pos, len - pos, vt->parser.cbdata);
330 330
331 if(!eaten) { 331 if(!eaten) {
332 DEBUG_LOG("libvterm: Text callback did not consume any input\n"); 332 DEBUG_LOG("libvterm: Text callback did not consume any input\n");
333 // force it to make progress 333 /* force it to make progress */
334 eaten = 1; 334 eaten = 1;
335 } 335 }
336 336
337 pos += (eaten - 1); // we'll ++ it again in a moment 337 pos += (eaten - 1); // we'll ++ it again in a moment
338 } 338 }