annotate src/libvterm/src/parser.c @ 26346:8be6413a8e27 v8.2.3704

patch 8.2.3704: Vim9: cannot use a list declaration in a :def function Commit: https://github.com/vim/vim/commit/ab36e6ae7b87b0295fb19270e4339a734875c6b1 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 30 16:14:49 2021 +0000 patch 8.2.3704: Vim9: cannot use a list declaration in a :def function Problem: Vim9: cannot use a list declaration in a :def function. Solution: Make it work.
author Bram Moolenaar <Bram@vim.org>
date Tue, 30 Nov 2021 17:15:03 +0100
parents f93337ae0612
children 82336c3b679d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 #include "vterm_internal.h"
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 #include <stdio.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 #include <string.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
6 #undef DEBUG_PARSER
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
7
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
8 static int is_intermed(unsigned char c)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
9 {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
10 return c >= 0x20 && c <= 0x2f;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
11 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 static void do_control(VTerm *vt, unsigned char control)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 {
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
15 if(vt->parser.callbacks && vt->parser.callbacks->control)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
16 if((*vt->parser.callbacks->control)(control, vt->parser.cbdata))
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 DEBUG_LOG1("libvterm: Unhandled control 0x%02x\n", control);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
22 static void do_csi(VTerm *vt, char command)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 {
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
24 #ifdef DEBUG_PARSER
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
25 printf("Parsed CSI args as:\n", arglen, args);
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
26 printf(" leader: %s\n", vt->parser.v.csi.leader);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
27 for(int argi = 0; argi < vt->parser.v.csi.argi; argi++) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
28 printf(" %lu", CSI_ARG(vt->parser.v.csi.args[argi]));
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
29 if(!CSI_ARG_HAS_MORE(vt->parser.v.csi.args[argi]))
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 printf("\n");
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
31 printf(" intermed: %s\n", vt->parser.intermed);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
35 if(vt->parser.callbacks && vt->parser.callbacks->csi)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
36 if((*vt->parser.callbacks->csi)(
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
37 vt->parser.v.csi.leaderlen ? vt->parser.v.csi.leader : NULL,
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
38 vt->parser.v.csi.args,
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
39 vt->parser.v.csi.argi,
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
40 vt->parser.intermedlen ? vt->parser.intermed : NULL,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
41 command,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
42 vt->parser.cbdata))
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
45 DEBUG_LOG1("libvterm: Unhandled CSI %c\n", command);
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
46 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
47
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
48 static void do_escape(VTerm *vt, char command)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
49 {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
50 char seq[INTERMED_MAX+1];
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
51
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
52 size_t len = vt->parser.intermedlen;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
53 strncpy(seq, vt->parser.intermed, len);
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
54 seq[len++] = command;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
55 seq[len] = 0;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
56
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
57 if(vt->parser.callbacks && vt->parser.callbacks->escape)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
58 if((*vt->parser.callbacks->escape)(seq, len, vt->parser.cbdata))
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
59 return;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
60
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
61 DEBUG_LOG1("libvterm: Unhandled escape ESC 0x%02x\n", command);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
64 static void string_fragment(VTerm *vt, const char *str, size_t len, int final)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
66 VTermStringFragment frag;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
67
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
68 frag.str = str;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
69 frag.len = len;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
70 frag.initial = vt->parser.string_initial;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
71 frag.final = final;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
72
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
73 switch(vt->parser.state) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
74 case OSC:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
75 if(vt->parser.callbacks && vt->parser.callbacks->osc)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
76 (*vt->parser.callbacks->osc)(vt->parser.v.osc.command, frag, vt->parser.cbdata);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
77 break;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
78
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
79 case DCS:
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
80 if(vt->parser.callbacks && vt->parser.callbacks->dcs)
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
81 (*vt->parser.callbacks->dcs)(vt->parser.v.dcs.command, vt->parser.v.dcs.commandlen, frag, vt->parser.cbdata);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
82 break;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
83
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
84 case APC:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
85 if(vt->parser.callbacks && vt->parser.callbacks->apc)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
86 (*vt->parser.callbacks->apc)(frag, vt->parser.cbdata);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
87 break;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
88
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
89 case PM:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
90 if(vt->parser.callbacks && vt->parser.callbacks->pm)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
91 (*vt->parser.callbacks->pm)(frag, vt->parser.cbdata);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
92 break;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
93
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
94 case SOS:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
95 if(vt->parser.callbacks && vt->parser.callbacks->sos)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
96 (*vt->parser.callbacks->sos)(frag, vt->parser.cbdata);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
97 break;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
98
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
99 case NORMAL:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
100 case CSI_LEADER:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
101 case CSI_ARGS:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
102 case CSI_INTERMED:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
103 case OSC_COMMAND:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
104 case DCS_COMMAND:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
105 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
108 vt->parser.string_initial = FALSE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 size_t pos = 0;
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
114 const char *string_start = NULL; // init to avoid gcc warning
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
116 vt->in_backspace = 0; // Count down with BS key and activate when
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
117 // it reaches 1
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
118
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
119 switch(vt->parser.state) {
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 case NORMAL:
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
121 case CSI_LEADER:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
122 case CSI_ARGS:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
123 case CSI_INTERMED:
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
124 case OSC_COMMAND:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
125 case DCS_COMMAND:
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 string_start = NULL;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 break;
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
128 case OSC:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
129 case DCS:
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
130 case APC:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
131 case PM:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
132 case SOS:
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 string_start = bytes;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
137 #define ENTER_STATE(st) do { vt->parser.state = st; string_start = NULL; } while(0)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
138 #define ENTER_NORMAL_STATE() ENTER_STATE(NORMAL)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
140 #define IS_STRING_STATE() (vt->parser.state >= OSC_COMMAND)
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
141
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 for( ; pos < len; pos++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 unsigned char c = bytes[pos];
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
144 int c1_allowed = !vt->mode.utf8;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
145 size_t string_len;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
147 if(c == 0x00 || c == 0x7f) { // NUL, DEL
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
148 if(IS_STRING_STATE()) {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
149 string_fragment(vt, string_start, bytes + pos - string_start, FALSE);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 string_start = bytes + pos + 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 continue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 }
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
154 if(c == 0x18 || c == 0x1a) { // CAN, SUB
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
155 vt->parser.in_esc = FALSE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 ENTER_NORMAL_STATE();
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 continue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 }
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
159 else if(c == 0x1b) { // ESC
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
160 vt->parser.intermedlen = 0;
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
161 if(!IS_STRING_STATE())
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
162 vt->parser.state = NORMAL;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
163 vt->parser.in_esc = TRUE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 continue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 }
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
166 else if(c == 0x07 && // BEL, can stand for ST in OSC or DCS state
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
167 IS_STRING_STATE()) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
168 // fallthrough
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 }
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
170 else if(c < 0x20) { // other C0
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
171 if(vt->parser.state == SOS)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
172 continue; // All other C0s permitted in SOS
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
173
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
174 if(vterm_get_special_pty_type() == 2) {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
175 if(c == 0x08) // BS
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
176 // Set the trick for BS output after a sequence, to delay backspace
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
177 // activation
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
178 if(pos + 2 < len && bytes[pos + 1] == 0x20 && bytes[pos + 2] == 0x08)
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
179 vt->in_backspace = 2; // Trigger when count down to 1
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
180 }
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
181 if(IS_STRING_STATE())
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
182 string_fragment(vt, string_start, bytes + pos - string_start, FALSE);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 do_control(vt, c);
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
184 if(IS_STRING_STATE())
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 string_start = bytes + pos + 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 continue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 }
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
188 // else fallthrough
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
190 string_len = bytes + pos - string_start;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
192 if(vt->parser.in_esc) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
193 // Hoist an ESC letter into a C1 if we're not in a string mode
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
194 // Always accept ESC \ == ST even in string mode
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
195 if(!vt->parser.intermedlen &&
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
196 c >= 0x40 && c < 0x60 &&
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
197 ((!IS_STRING_STATE() || c == 0x5c))) {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
198 c += 0x40;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
199 c1_allowed = TRUE;
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
200 if(string_len)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
201 string_len -= 1;
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
202 vt->parser.in_esc = FALSE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 }
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
204 else {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
205 string_start = NULL;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
206 vt->parser.state = NORMAL;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
207 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
208 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
210 switch(vt->parser.state) {
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
211 case CSI_LEADER:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
212 /* Extract leader bytes 0x3c to 0x3f */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
213 if(c >= 0x3c && c <= 0x3f) {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
214 if(vt->parser.v.csi.leaderlen < CSI_LEADER_MAX-1)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
215 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen++] = c;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
216 break;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
217 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
218
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
219 /* else fallthrough */
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
220 vt->parser.v.csi.leader[vt->parser.v.csi.leaderlen] = 0;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
221
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
222 vt->parser.v.csi.argi = 0;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
223 vt->parser.v.csi.args[0] = CSI_ARG_MISSING;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
224 vt->parser.state = CSI_ARGS;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
225
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
226 /* fallthrough */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
227 case CSI_ARGS:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
228 /* Numerical value of argument */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
229 if(c >= '0' && c <= '9') {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
230 if(vt->parser.v.csi.args[vt->parser.v.csi.argi] == CSI_ARG_MISSING)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
231 vt->parser.v.csi.args[vt->parser.v.csi.argi] = 0;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
232 vt->parser.v.csi.args[vt->parser.v.csi.argi] *= 10;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
233 vt->parser.v.csi.args[vt->parser.v.csi.argi] += c - '0';
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
234 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 }
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
236 if(c == ':') {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
237 vt->parser.v.csi.args[vt->parser.v.csi.argi] |= CSI_ARG_FLAG_MORE;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
238 c = ';';
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
239 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
240 if(c == ';') {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
241 vt->parser.v.csi.argi++;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
242 vt->parser.v.csi.args[vt->parser.v.csi.argi] = CSI_ARG_MISSING;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
243 break;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
244 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
245
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
246 /* else fallthrough */
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
247 vt->parser.v.csi.argi++;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
248 vt->parser.intermedlen = 0;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
249 vt->parser.state = CSI_INTERMED;
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
250 // fallthrough
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
251 case CSI_INTERMED:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
252 if(is_intermed(c)) {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
253 if(vt->parser.intermedlen < INTERMED_MAX-1)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
254 vt->parser.intermed[vt->parser.intermedlen++] = c;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
255 break;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
256 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
257 else if(c == 0x1b) {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
258 /* ESC in CSI cancels */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
259 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
260 else if(c >= 0x40 && c <= 0x7e) {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
261 vt->parser.intermed[vt->parser.intermedlen] = 0;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
262 do_csi(vt, c);
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
263 }
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
264 /* else was invalid CSI */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
265
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
266 ENTER_NORMAL_STATE();
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
269 case OSC_COMMAND:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
270 /* Numerical value of command */
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
271 if(c >= '0' && c <= '9') {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
272 if(vt->parser.v.osc.command == -1)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
273 vt->parser.v.osc.command = 0;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
274 else
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
275 vt->parser.v.osc.command *= 10;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
276 vt->parser.v.osc.command += c - '0';
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
277 break;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
278 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
279 if(c == ';') {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
280 vt->parser.state = OSC;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
281 string_start = bytes + pos + 1;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
282 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 }
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
284
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
285 /* else fallthrough */
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
286 string_start = bytes + pos;
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
287 string_len = 0;
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
288 vt->parser.state = OSC;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
289 goto string_state;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
290
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
291 case DCS_COMMAND:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
292 if(vt->parser.v.dcs.commandlen < CSI_LEADER_MAX)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
293 vt->parser.v.dcs.command[vt->parser.v.dcs.commandlen++] = c;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
294
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
295 if(c >= 0x40 && c<= 0x7e) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
296 string_start = bytes + pos + 1;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
297 vt->parser.state = DCS;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
298 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
299 break;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
300
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
301 string_state:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
302 case OSC:
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
303 case DCS:
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
304 case APC:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
305 case PM:
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
306 case SOS:
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
307 if(c == 0x07 || (c1_allowed && c == 0x9c)) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
308 string_fragment(vt, string_start, string_len, TRUE);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
309 ENTER_NORMAL_STATE();
13604
caa9825b04cd patch 8.0.1674: libvterm can't handle an OSC string split
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
310 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 case NORMAL:
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
314 if(vt->parser.in_esc) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
315 if(is_intermed(c)) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
316 if(vt->parser.intermedlen < INTERMED_MAX-1)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
317 vt->parser.intermed[vt->parser.intermedlen++] = c;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
318 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
319 else if(c >= 0x30 && c < 0x7f) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
320 do_escape(vt, c);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
321 vt->parser.in_esc = 0;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
322 ENTER_NORMAL_STATE();
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
323 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
324 else {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
325 DEBUG_LOG1("TODO: Unhandled byte %02x in Escape\n", c);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
326 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
327 break;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
328 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
329 if(c1_allowed && c >= 0x80 && c < 0xa0) {
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 switch(c) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
331 case 0x90: // DCS
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
332 vt->parser.string_initial = TRUE;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
333 vt->parser.v.dcs.commandlen = 0;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
334 ENTER_STATE(DCS_COMMAND);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 break;
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
336 case 0x98: // SOS
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
337 vt->parser.string_initial = TRUE;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
338 ENTER_STATE(SOS);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
339 string_start = bytes + pos + 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
340 string_len = 0;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
341 break;
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
342 case 0x9b: // CSI
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
343 vt->parser.v.csi.leaderlen = 0;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
344 ENTER_STATE(CSI_LEADER);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 break;
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
346 case 0x9d: // OSC
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
347 vt->parser.v.osc.command = -1;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
348 vt->parser.string_initial = TRUE;
20498
55a373a243c0 patch 8.2.0803: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
349 string_start = bytes + pos + 1;
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
350 ENTER_STATE(OSC_COMMAND);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 break;
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
352 case 0x9e: // PM
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
353 vt->parser.string_initial = TRUE;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
354 ENTER_STATE(PM);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
355 string_start = bytes + pos + 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
356 string_len = 0;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
357 break;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
358 case 0x9f: // APC
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
359 vt->parser.string_initial = TRUE;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
360 ENTER_STATE(APC);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
361 string_start = bytes + pos + 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
362 string_len = 0;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
363 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 do_control(vt, c);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 else {
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
370 size_t eaten = 0;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
371 if(vt->parser.callbacks && vt->parser.callbacks->text)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
372 eaten = (*vt->parser.callbacks->text)(bytes + pos, len - pos, vt->parser.cbdata);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
374 if(!eaten) {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
375 DEBUG_LOG("libvterm: Text callback did not consume any input\n");
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20498
diff changeset
376 /* force it to make progress */
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
377 eaten = 1;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13606
diff changeset
380 pos += (eaten - 1); // we'll ++ it again in a moment
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
386 if(string_start) {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
387 size_t string_len = bytes + pos - string_start;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
388 if(vt->parser.in_esc)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
389 string_len -= 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
390 string_fragment(vt, string_start, string_len, FALSE);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
391 }
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
392
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 return len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 }
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
395
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
396 void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
397 {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
398 vt->parser.callbacks = callbacks;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
399 vt->parser.cbdata = user;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
400 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
401
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
402 void *vterm_parser_get_cbdata(VTerm *vt)
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
403 {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
404 return vt->parser.cbdata;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11761
diff changeset
405 }