annotate src/libvterm/t/harness.c @ 28614:9ae2c32841fb v8.2.4831

patch 8.2.4831: crash when using maparg() and unmapping simplified keys Commit: https://github.com/vim/vim/commit/2c8a7ebdad9da017bfb6dc8a0f46acea77ec2e17 Author: zeertzjq <zeertzjq@outlook.com> Date: Tue Apr 26 21:36:21 2022 +0100 patch 8.2.4831: crash when using maparg() and unmapping simplified keys Problem: Crash when using maparg() and unmapping simplified keys. Solution: Do not keep a mapblock pointer. (closes https://github.com/vim/vim/issues/10294)
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Apr 2022 22:45:03 +0200
parents f93337ae0612
children 2d2758ffd959
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.h"
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
2 #include "../src/vterm_internal.h" // We pull in some internal bits too
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 #include <stdio.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 #include <string.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 #define streq(a,b) (!strcmp(a,b))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 #define strstartswith(a,b) (!strncmp(a,b,strlen(b)))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 static size_t inplace_hex2bytes(char *s)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 char *inpos = s, *outpos = s;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 while(*inpos) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 unsigned int ch;
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
16 if(sscanf(inpos, "%2x", &ch) < 1)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
17 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 *outpos = ch;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 outpos += 1; inpos += 2;
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
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 return outpos - s;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 static VTermModifier strpe_modifiers(char **strp)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 VTermModifier state = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 while((*strp)[0]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 switch(((*strp)++)[0]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 case 'S': state |= VTERM_MOD_SHIFT; break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 case 'C': state |= VTERM_MOD_CTRL; break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 case 'A': state |= VTERM_MOD_ALT; break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 default: return state;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 return state;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 static VTermKey strp_key(char *str)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 static struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 char *name;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 VTermKey key;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 } keys[] = {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 { "Up", VTERM_KEY_UP },
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 { "Tab", VTERM_KEY_TAB },
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 { "Enter", VTERM_KEY_ENTER },
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 { "KP0", VTERM_KEY_KP_0 },
20458
ffadba5f898c patch 8.2.0783: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19995
diff changeset
51 { "F1", VTERM_KEY_FUNCTION(1) },
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 { NULL, VTERM_KEY_NONE },
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 int i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 for(i = 0; keys[i].name; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 if(streq(str, keys[i].name))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 return keys[i].key;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 return VTERM_KEY_NONE;
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
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
64 static void print_color(const VTermColor *col)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
65 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
66 if (VTERM_COLOR_IS_RGB(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
67 printf("rgb(%d,%d,%d", col->red, col->green, col->blue);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
68 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
69 else if (VTERM_COLOR_IS_INDEXED(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
70 printf("idx(%d", col->index);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
71 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
72 else {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
73 printf("invalid(%d", col->type);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
74 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
75 if (VTERM_COLOR_IS_DEFAULT_FG(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
76 printf(",is_default_fg");
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
77 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
78 if (VTERM_COLOR_IS_DEFAULT_BG(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
79 printf(",is_default_bg");
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
80 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
81 printf(")");
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
82 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
83
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 static VTerm *vt;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 static VTermState *state;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 static VTermScreen *screen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 static VTermEncodingInstance encoding;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
19995
19dc9f64a906 patch 8.2.0553: error for unused argument
Bram Moolenaar <Bram@vim.org>
parents: 19989
diff changeset
90 static void term_output(const char *s, size_t len, void *user UNUSED)
19989
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
91 {
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
92 size_t i;
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
93
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
94 printf("output ");
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
95 for(i = 0; i < len; i++)
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
96 printf("%x%s", (unsigned char)s[i], i < len-1 ? "," : "\n");
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
97 }
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
98
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
99 static void printhex(const char *s, size_t len)
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
100 {
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
101 while(len--)
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
102 printf("%02x", (uint8_t)(s++)[0]);
19989
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
103 }
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
104
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
105 static int parser_text(const char bytes[], size_t len, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 {
19971
a042d2a3b13d patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
107 size_t i;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 printf("text ");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 for(i = 0; i < len; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 unsigned char b = bytes[i];
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 if(b < 0x20 || b == 0x7f || (b >= 0x80 && b < 0xa0))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 printf(i ? ",%x" : "%x", b);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 return i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
121 static int parser_control(unsigned char control, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 printf("control %02x\n", control);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
128 static int parser_escape(const char bytes[], size_t len, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 if(bytes[0] >= 0x20 && bytes[0] < 0x30) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 if(len < 2)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 return -1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 len = 2;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 else {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 len = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 printf("escape ");
19989
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
140 printhex(bytes, len);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 return len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
146 static int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 int i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 printf("csi %02x", command);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 if(leader && leader[0]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 printf(" L=");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 for(i = 0; leader[i]; i++)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 printf("%02x", leader[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 for(i = 0; i < argcount; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 char sep = i ? ',' : ' ';
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 if(args[i] == CSI_ARG_MISSING)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 printf("%c*", sep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 printf("%c%ld%s", sep, CSI_ARG(args[i]), CSI_ARG_HAS_MORE(args[i]) ? "+" : "");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 if(intermed && intermed[0]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 printf(" I=");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 for(i = 0; intermed[i]; i++)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 printf("%02x", intermed[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
177 static int parser_osc(int command, VTermStringFragment frag, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 {
19971
a042d2a3b13d patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
179
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 printf("osc ");
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
181
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
182 if(frag.initial) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
183 if(command == -1)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
184 printf("[");
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
185 else
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
186 printf("[%d;", command);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
187 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
188
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
189 printhex(frag.str, frag.len);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
190
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
191 if(frag.final)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
192 printf("]");
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
193
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
199 static int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 {
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
201 printf("dcs ");
19971
a042d2a3b13d patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
202
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
203 if(frag.initial) {
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
204 size_t i;
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
205 printf("[");
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
206 for(i = 0; i < commandlen; i++)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
207 printf("%02x", command[i]);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
208 }
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
209
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
210 printhex(frag.str, frag.len);
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
211
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
212 if(frag.final)
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
213 printf("]");
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
214
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
220 static int parser_apc(VTermStringFragment frag, void *user UNUSED)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
221 {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
222 printf("apc ");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
223
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
224 if(frag.initial)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
225 printf("[");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
226
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
227 printhex(frag.str, frag.len);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
228
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
229 if(frag.final)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
230 printf("]");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
231
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
232 printf("\n");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
233
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
234 return 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
235 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
236
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
237 static int parser_pm(VTermStringFragment frag, void *user UNUSED)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
238 {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
239 printf("pm ");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
240
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
241 if(frag.initial)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
242 printf("[");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
243
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
244 printhex(frag.str, frag.len);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
245
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
246 if(frag.final)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
247 printf("]");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
248
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
249 printf("\n");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
250
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
251 return 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
252 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
253
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
254 static int parser_sos(VTermStringFragment frag, void *user UNUSED)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
255 {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
256 printf("sos ");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
257
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
258 if(frag.initial)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
259 printf("[");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
260
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
261 printhex(frag.str, frag.len);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
262
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
263 if(frag.final)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
264 printf("]");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
265
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
266 printf("\n");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
267
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
268 return 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
269 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
270
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 static VTermParserCallbacks parser_cbs = {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
272 parser_text, // text
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
273 parser_control, // control
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
274 parser_escape, // escape
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
275 parser_csi, // csi
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
276 parser_osc, // osc
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
277 parser_dcs, // dcs
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
278 parser_apc, // apc
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
279 parser_pm, // pm
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
280 parser_sos, // sos
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
281 NULL // resize
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
284 static VTermStateFallbacks fallbacks = {
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
285 parser_control, // control
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
286 parser_csi, // csi
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
287 parser_osc, // osc
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
288 parser_dcs, // dcs
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
289 parser_apc, // dcs
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
290 parser_pm, // pm
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
291 parser_sos // sos
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
292 };
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
293
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
294 /* These callbacks are shared by State and Screen */
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 static int want_movecursor = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 static VTermPos state_pos;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
298 static int movecursor(VTermPos pos, VTermPos oldpos UNUSED, int visible UNUSED, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 state_pos = pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 if(want_movecursor)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 printf("movecursor %d,%d\n", pos.row, pos.col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 static int want_scrollrect = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
309 static int scrollrect(VTermRect rect, int downward, int rightward, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 if(!want_scrollrect)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 printf("scrollrect %d..%d,%d..%d => %+d,%+d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 rect.start_row, rect.end_row, rect.start_col, rect.end_col,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 downward, rightward);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 static int want_moverect = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
322 static int moverect(VTermRect dest, VTermRect src, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 if(!want_moverect)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 printf("moverect %d..%d,%d..%d -> %d..%d,%d..%d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 src.start_row, src.end_row, src.start_col, src.end_col,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 dest.start_row, dest.end_row, dest.start_col, dest.end_col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 static int want_settermprop = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
335 static int settermprop(VTermProp prop, VTermValue *val, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 VTermValueType type;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 if(!want_settermprop)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 type = vterm_get_prop_type(prop);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 switch(type) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 case VTERM_VALUETYPE_BOOL:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 printf("settermprop %d %s\n", prop, val->boolean ? "true" : "false");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 case VTERM_VALUETYPE_INT:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 printf("settermprop %d %d\n", prop, val->number);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 case VTERM_VALUETYPE_STRING:
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
350 printf("settermprop %d %s\"%.*s\"%s\n", prop,
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
351 val->string.initial ? "[" : "", val->string.len, val->string.str, val->string.final ? "]" : "");
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 case VTERM_VALUETYPE_COLOR:
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
354 printf("settermprop %d ", prop);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
355 print_color(&val->color);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
356 printf("\n");
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 return 1;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
358
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
359 case VTERM_N_VALUETYPES:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
360 return 0;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
366 // These callbacks are for State
11621
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 static int want_state_putglyph = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
369 static int state_putglyph(VTermGlyphInfo *info, VTermPos pos, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 int i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 if(!want_state_putglyph)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 printf("putglyph ");
20488
1d595fada804 patch 8.2.0798: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20482
diff changeset
376 for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 printf(i ? ",%x" : "%x", info->chars[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 printf(" %d %d,%d", info->width, pos.row, pos.col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 if(info->protected_cell)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 printf(" prot");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 if(info->dwl)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 printf(" dwl");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 if(info->dhl)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 printf(" dhl-%s", info->dhl == 1 ? "top" : info->dhl == 2 ? "bottom" : "?" );
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 static int want_state_erase = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
391 static int state_erase(VTermRect rect, int selective, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 if(!want_state_erase)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 printf("erase %d..%d,%d..%d%s\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 rect.start_row, rect.end_row, rect.start_col, rect.end_col,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 selective ? " selective" : "");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 static struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 int bold;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 int underline;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 int italic;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 int blink;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 int reverse;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
409 int conceal;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 int strike;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 int font;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 VTermColor foreground;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 VTermColor background;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 } state_pen;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
415 static int state_setpenattr(VTermAttr attr, VTermValue *val, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 switch(attr) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 case VTERM_ATTR_BOLD:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 state_pen.bold = val->boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 case VTERM_ATTR_UNDERLINE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 state_pen.underline = val->number;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 case VTERM_ATTR_ITALIC:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 state_pen.italic = val->boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 case VTERM_ATTR_BLINK:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 state_pen.blink = val->boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 case VTERM_ATTR_REVERSE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 state_pen.reverse = val->boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 break;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
433 case VTERM_ATTR_CONCEAL:
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
434 state_pen.conceal = val->boolean;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
435 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 case VTERM_ATTR_STRIKE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437 state_pen.strike = val->boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 case VTERM_ATTR_FONT:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 state_pen.font = val->number;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 case VTERM_ATTR_FOREGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 state_pen.foreground = val->color;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 case VTERM_ATTR_BACKGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 state_pen.background = val->color;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 break;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
448
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
449 case VTERM_N_ATTRS:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
450 return 0;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
456 static int state_setlineinfo(int row UNUSED, const VTermLineInfo *newinfo UNUSED, const VTermLineInfo *oldinfo UNUSED, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 VTermStateCallbacks state_cbs = {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
462 state_putglyph, // putglyph
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
463 movecursor, // movecursor
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
464 scrollrect, // scrollrect
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
465 moverect, // moverect
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
466 state_erase, // erase
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
467 NULL, // initpen
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
468 state_setpenattr, // setpenattr
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
469 settermprop, // settermprop
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
470 NULL, // bell
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
471 NULL, // resize
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
472 state_setlineinfo, // setlineinfo
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
475 static int selection_set(VTermSelectionMask mask, VTermStringFragment frag, void *user UNUSED)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
476 {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
477 printf("selection-set mask=%04X ", mask);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
478 if(frag.initial)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
479 printf("[");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
480 printhex(frag.str, frag.len);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
481 if(frag.final)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
482 printf("]");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
483 printf("\n");
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
484
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
485 return 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
486 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
487
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
488 static int selection_query(VTermSelectionMask mask, void *user UNUSED)
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
489 {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
490 printf("selection-query mask=%04X\n", mask);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
491
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
492 return 1;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
493 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
494
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
495 VTermSelectionCallbacks selection_cbs = {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
496 .set = selection_set,
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
497 .query = selection_query,
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
498 };
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
499
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 static int want_screen_damage = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 static int want_screen_damage_cells = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
502 static int screen_damage(VTermRect rect, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504 if(!want_screen_damage)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 printf("damage %d..%d,%d..%d",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 rect.start_row, rect.end_row, rect.start_col, rect.end_col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 if(want_screen_damage_cells) {
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
511 int equals = FALSE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 int row;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 int col;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 for(row = rect.start_row; row < rect.end_row; row++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 int eol = rect.end_col;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 while(eol > rect.start_col) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 VTermScreenCell cell;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520 pos.row = row;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 pos.col = eol-1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 vterm_screen_get_cell(screen, pos, &cell);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 if(cell.chars[0])
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 eol--;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 if(eol == rect.start_col)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 if(!equals)
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
533 printf(" ="), equals = TRUE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 printf(" %d<", row);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 for(col = rect.start_col; col < eol; col++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 VTermScreenCell cell;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 pos.row = row;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 pos.col = col;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 vterm_screen_get_cell(screen, pos, &cell);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 printf(col == rect.start_col ? "%02X" : " %02X", cell.chars[0]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 printf(">");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
549
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 static int want_screen_scrollback = 0;
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
554 static int screen_sb_pushline(int cols, const VTermScreenCell *cells, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 int eol;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 int c;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 if(!want_screen_scrollback)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 eol = cols;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 while(eol && !cells[eol-1].chars[0])
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 eol--;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
565
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 printf("sb_pushline %d =", cols);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 for(c = 0; c < eol; c++)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 printf(" %02X", cells[c].chars[0]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
574 static int screen_sb_popline(int cols, VTermScreenCell *cells, void *user UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 int col;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 if(!want_screen_scrollback)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
581 // All lines of scrollback contain "ABCDE"
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 for(col = 0; col < cols; col++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 if(col < 5)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 cells[col].chars[0] = 'A' + col;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 cells[col].chars[0] = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 cells[col].width = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591 printf("sb_popline %d\n", cols);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 VTermScreenCallbacks screen_cbs = {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
596 screen_damage, // damage
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
597 moverect, // moverect
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
598 movecursor, // movecursor
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
599 settermprop, // settermprop
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
600 NULL, // bell
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
601 NULL, // resize
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
602 screen_sb_pushline, // sb_pushline
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
603 screen_sb_popline // sb_popline
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605
19979
a80007999d01 patch 8.2.0545: unused arguments ignored in non-standard way
Bram Moolenaar <Bram@vim.org>
parents: 19971
diff changeset
606 int main(int argc UNUSED, char **argv UNUSED)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 char line[1024] = {0};
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 int flag;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 int err;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613 setvbuf(stdout, NULL, _IONBF, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 while(fgets(line, sizeof line, stdin)) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 char *nl;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 size_t outlen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 err = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 if((nl = strchr(line, '\n')))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 *nl = '\0';
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 if(streq(line, "INIT")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 if(!vt)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 vt = vterm_new(25, 80);
20460
c15dd3da4f47 patch 8.2.0784: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20458
diff changeset
626
c15dd3da4f47 patch 8.2.0784: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20458
diff changeset
627 // Somehow this makes tests fail
c15dd3da4f47 patch 8.2.0784: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20458
diff changeset
628 // vterm_output_set_callback(vt, term_output, NULL);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 else if(streq(line, "WANTPARSER")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 vterm_parser_set_callbacks(vt, &parser_cbs, NULL);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 else if(strstartswith(line, "WANTSTATE") && (line[9] == '\0' || line[9] == ' ')) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 int i = 9;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 int sense = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 if(!state) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 state = vterm_obtain_state(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 vterm_state_set_callbacks(state, &state_cbs, NULL);
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
641 vterm_state_set_selection_callbacks(state, &selection_cbs, NULL, NULL, 1024);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 vterm_state_set_bold_highbright(state, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 vterm_state_reset(state, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 while(line[i] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 i++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 for( ; line[i]; i++)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 switch(line[i]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 case '+':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 sense = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
652 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653 case '-':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654 sense = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 case 'g':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657 want_state_putglyph = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 case 's':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 want_scrollrect = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 case 'm':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 want_moverect = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 case 'e':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 want_state_erase = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 case 'p':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 want_settermprop = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 case 'f':
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
672 vterm_state_set_unrecognised_fallbacks(state, sense ? &fallbacks : NULL, NULL);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 fprintf(stderr, "Unrecognised WANTSTATE flag '%c'\n", line[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
677 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 else if(strstartswith(line, "WANTSCREEN") && (line[10] == '\0' || line[10] == ' ')) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 int i = 10;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 int sense = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 if(!screen)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 screen = vterm_obtain_screen(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684 vterm_screen_set_callbacks(screen, &screen_cbs, NULL);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 while(line[i] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 i++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 for( ; line[i]; i++)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 switch(line[i]) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 case '-':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 sense = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692 break;
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
693 case 'a':
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
694 vterm_screen_enable_altscreen(screen, 1);
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
695 break;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 case 'd':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 want_screen_damage = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 case 'D':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 want_screen_damage = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 want_screen_damage_cells = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
702 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 case 'm':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 want_moverect = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 case 'c':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 want_movecursor = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 case 'p':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 want_settermprop = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 case 'b':
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713 want_screen_scrollback = sense;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 fprintf(stderr, "Unrecognised WANTSCREEN flag '%c'\n", line[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 else if(sscanf(line, "UTF8 %d", &flag)) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 vterm_set_utf8(vt, flag);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 else if(streq(line, "RESET")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725 if(state) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 vterm_state_reset(state, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 vterm_state_get_cursorpos(state, &state_pos);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 if(screen) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 vterm_screen_reset(screen, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 else if(strstartswith(line, "RESIZE ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 int rows, cols;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 char *linep = line + 7;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 sscanf(linep, "%d, %d", &rows, &cols);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 vterm_set_size(vt, rows, cols);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 else if(strstartswith(line, "PUSH ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 char *bytes = line + 5;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 size_t len = inplace_hex2bytes(bytes);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 size_t written = vterm_input_write(vt, bytes, len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 if(written < len)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 fprintf(stderr, "! short write\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 else if(streq(line, "WANTENCODING")) {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
752 // This isn't really external API but it's hard to get this out any
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
753 // other way
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 encoding.enc = vterm_lookup_encoding(ENC_UTF8, 'u');
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 if(encoding.enc->init)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 (*encoding.enc->init)(encoding.enc, encoding.data);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 else if(strstartswith(line, "ENCIN ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 char *bytes = line + 6;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 size_t len = inplace_hex2bytes(bytes);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 uint32_t cp[1024];
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764 int cpi = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 size_t pos = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 (*encoding.enc->decode)(encoding.enc, encoding.data,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 cp, &cpi, len, bytes, &pos, len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 if(cpi > 0) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 int i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 printf("encout ");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 for(i = 0; i < cpi; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 printf(i ? ",%x" : "%x", cp[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 else if(strstartswith(line, "INCHAR ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 char *linep = line + 7;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 unsigned int c = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 VTermModifier mod;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 mod = strpe_modifiers(&linep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 sscanf(linep, " %x", &c);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 vterm_keyboard_unichar(vt, c, mod);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792 else if(strstartswith(line, "INKEY ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 VTermModifier mod;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 VTermKey key;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 char *linep = line + 6;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 mod = strpe_modifiers(&linep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 key = strp_key(linep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 vterm_keyboard_key(vt, key, mod);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 else if(strstartswith(line, "PASTE ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807 char *linep = line + 6;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 if(streq(linep, "START"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809 vterm_keyboard_start_paste(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 else if(streq(linep, "END"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811 vterm_keyboard_end_paste(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
816 else if(strstartswith(line, "FOCUS ")) {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
817 char *linep = line + 6;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
818 if(streq(linep, "IN"))
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
819 vterm_state_focus_in(state);
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
820 else if(streq(linep, "OUT"))
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
821 vterm_state_focus_out(state);
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
822 else
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
823 goto abort_line;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
824 }
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 11780
diff changeset
825
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 else if(strstartswith(line, "MOUSEMOVE ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 char *linep = line + 10;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 int row, col, len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 VTermModifier mod;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 sscanf(linep, "%d,%d%n", &row, &col, &len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 linep += len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 mod = strpe_modifiers(&linep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 vterm_mouse_move(vt, row, col, mod);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 else if(strstartswith(line, "MOUSEBTN ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841 char *linep = line + 9;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842 char press;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 int button, len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 VTermModifier mod;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 sscanf(linep, "%c %d%n", &press, &button, &len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 linep += len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 mod = strpe_modifiers(&linep);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 vterm_mouse_button(vt, button, (press == 'd' || press == 'D'), mod);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854
26270
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
855 else if(strstartswith(line, "SELECTION ")) {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
856 char *linep = line + 10;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
857 unsigned int mask;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
858 int len;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
859 VTermStringFragment frag = { 0 };
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
860 sscanf(linep, "%x%n", &mask, &len);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
861 linep += len;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
862 while(linep[0] == ' ')
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
863 linep++;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
864 if(linep[0] == '[') {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
865 frag.initial = TRUE;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
866 linep++;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
867 while(linep[0] == ' ')
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
868 linep++;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
869 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
870 frag.len = inplace_hex2bytes(linep);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
871 frag.str = linep;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
872 linep += frag.len * 2;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
873 while(linep[0] == ' ')
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
874 linep++;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
875 if(linep[0] == ']') {
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
876 frag.final = TRUE;
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
877 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
878 vterm_state_send_selection(state, mask, frag);
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
879 }
f93337ae0612 patch 8.2.3666: libvterm is outdated
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
880
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 else if(strstartswith(line, "DAMAGEMERGE ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 char *linep = line + 12;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 if(streq(linep, "CELL"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_CELL);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 else if(streq(linep, "ROW"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_ROW);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 else if(streq(linep, "SCREEN"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_SCREEN);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 else if(streq(linep, "SCROLL"))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 vterm_screen_set_damage_merge(screen, VTERM_DAMAGE_SCROLL);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 else if(strstartswith(line, "DAMAGEFLUSH")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 vterm_screen_flush_damage(screen);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 else if(line[0] == '?') {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900 if(streq(line, "?cursor")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 vterm_state_get_cursorpos(state, &pos);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 if(pos.row != state_pos.row)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 printf("! row mismatch: state=%d,%d event=%d,%d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 pos.row, pos.col, state_pos.row, state_pos.col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 else if(pos.col != state_pos.col)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 printf("! col mismatch: state=%d,%d event=%d,%d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 pos.row, pos.col, state_pos.row, state_pos.col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 printf("%d,%d\n", state_pos.row, state_pos.col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 else if(strstartswith(line, "?pen ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 VTermValue val;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 char *linep = line + 5;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918 #define BOOLSTR(v) ((v) ? "on" : "off")
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
919
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
920 if(streq(linep, "bold")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 vterm_state_get_penattr(state, VTERM_ATTR_BOLD, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 if(val.boolean != state_pen.bold)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
923 printf("! pen bold mismatch; state=%s, event=%s\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 BOOLSTR(val.boolean), BOOLSTR(state_pen.bold));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926 printf("%s\n", BOOLSTR(state_pen.bold));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928 else if(streq(linep, "underline")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 vterm_state_get_penattr(state, VTERM_ATTR_UNDERLINE, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930 if(val.boolean != state_pen.underline)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 printf("! pen underline mismatch; state=%d, event=%d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 val.boolean, state_pen.underline);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934 printf("%d\n", state_pen.underline);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936 else if(streq(linep, "italic")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937 vterm_state_get_penattr(state, VTERM_ATTR_ITALIC, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 if(val.boolean != state_pen.italic)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939 printf("! pen italic mismatch; state=%s, event=%s\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 BOOLSTR(val.boolean), BOOLSTR(state_pen.italic));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 printf("%s\n", BOOLSTR(state_pen.italic));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944 else if(streq(linep, "blink")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 vterm_state_get_penattr(state, VTERM_ATTR_BLINK, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 if(val.boolean != state_pen.blink)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 printf("! pen blink mismatch; state=%s, event=%s\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 BOOLSTR(val.boolean), BOOLSTR(state_pen.blink));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 printf("%s\n", BOOLSTR(state_pen.blink));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 else if(streq(linep, "reverse")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 vterm_state_get_penattr(state, VTERM_ATTR_REVERSE, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 if(val.boolean != state_pen.reverse)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 printf("! pen reverse mismatch; state=%s, event=%s\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 BOOLSTR(val.boolean), BOOLSTR(state_pen.reverse));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 printf("%s\n", BOOLSTR(state_pen.reverse));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 else if(streq(linep, "font")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 vterm_state_get_penattr(state, VTERM_ATTR_FONT, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
962 if(val.boolean != state_pen.font)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963 printf("! pen font mismatch; state=%d, event=%d\n",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 val.boolean, state_pen.font);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 printf("%d\n", state_pen.font);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 else if(streq(linep, "foreground")) {
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
969 print_color(&state_pen.foreground);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
970 printf("\n");
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 else if(streq(linep, "background")) {
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
973 print_color(&state_pen.background);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
974 printf("\n");
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
976 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
977 printf("?\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 }
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
979 else if(strstartswith(line, "?lineinfo ")) {
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
980 char *linep = line + 10;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
981 int row;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
982 const VTermLineInfo *info;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
983 while(linep[0] == ' ')
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
984 linep++;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
985 if(sscanf(linep, "%d", &row) < 1) {
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
986 printf("! lineinfo unrecognised input\n");
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
987 goto abort_line;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
988 }
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
989 info = vterm_state_get_lineinfo(state, row);
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
990 if(info->doublewidth)
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
991 printf("dwl ");
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
992 if(info->doubleheight)
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
993 printf("dhl ");
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
994 if(info->continuation)
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
995 printf("cont ");
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
996 printf("\n");
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20460
diff changeset
997 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 else if(strstartswith(line, "?screen_chars ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999 char *linep = line + 13;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000 VTermRect rect;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001 size_t len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1002 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004 if(sscanf(linep, "%d,%d,%d,%d", &rect.start_row, &rect.start_col, &rect.end_row, &rect.end_col) < 4) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005 printf("! screen_chars unrecognised input\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008 len = vterm_screen_get_chars(screen, NULL, 0, rect);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009 if(len == (size_t)-1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010 printf("! screen_chars error\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 else if(len == 0)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1013 else {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014 uint32_t *chars = malloc(sizeof(uint32_t) * len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 size_t i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 vterm_screen_get_chars(screen, chars, len, rect);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 for(i = 0; i < len; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 printf("0x%02x%s", chars[i], i < len-1 ? "," : "\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020 free(chars);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023 else if(strstartswith(line, "?screen_text ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 char *linep = line + 12;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025 VTermRect rect;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 size_t len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1027 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 if(sscanf(linep, "%d,%d,%d,%d", &rect.start_row, &rect.start_col, &rect.end_row, &rect.end_col) < 4) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 printf("! screen_text unrecognised input\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1033 len = vterm_screen_get_text(screen, NULL, 0, rect);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034 if(len == (size_t)-1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 printf("! screen_text error\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036 else if(len == 0)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 printf("\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1038 else {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 13531
diff changeset
1039 // Put an overwrite guard at both ends of the buffer
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040 unsigned char *buffer = malloc(len + 4);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1041 unsigned char *text = buffer + 2;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1042 text[-2] = 0x55; text[-1] = 0xAA;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043 text[len] = 0x55; text[len+1] = 0xAA;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045 vterm_screen_get_text(screen, (char *)text, len, rect);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 if(text[-2] != 0x55 || text[-1] != 0xAA)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 printf("! screen_get_text buffer overrun left [%02x,%02x]\n", text[-2], text[-1]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049 else if(text[len] != 0x55 || text[len+1] != 0xAA)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050 printf("! screen_get_text buffer overrun right [%02x,%02x]\n", text[len], text[len+1]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1051 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053 size_t i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 for(i = 0; i < len; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 printf("0x%02x%s", text[i], i < len-1 ? "," : "\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059 free(buffer);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1060 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 else if(strstartswith(line, "?screen_cell ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 char *linep = line + 12;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 int i;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066 VTermScreenCell cell;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 if(sscanf(linep, "%d,%d\n", &pos.row, &pos.col) < 2) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070 printf("! screen_cell unrecognised input\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073 if(!vterm_screen_get_cell(screen, pos, &cell))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075 printf("{");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell.chars[i]; i++) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077 printf("%s0x%x", i ? "," : "", cell.chars[i]);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1078 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 printf("} width=%d attrs={", cell.width);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 if(cell.attrs.bold) printf("B");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 if(cell.attrs.underline) printf("U%d", cell.attrs.underline);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082 if(cell.attrs.italic) printf("I");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1083 if(cell.attrs.blink) printf("K");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1084 if(cell.attrs.reverse) printf("R");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1085 if(cell.attrs.font) printf("F%d", cell.attrs.font);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1086 printf("} ");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1087 if(cell.attrs.dwl) printf("dwl ");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1088 if(cell.attrs.dhl) printf("dhl-%s ", cell.attrs.dhl == 2 ? "bottom" : "top");
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1089 printf("fg=");
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1090 vterm_screen_convert_color_to_rgb(screen, &cell.fg);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1091 print_color(&cell.fg);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1092 printf(" bg=");
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1093 vterm_screen_convert_color_to_rgb(screen, &cell.bg);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1094 print_color(&cell.bg);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1095 printf("\n");
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1097 else if(strstartswith(line, "?screen_eol ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1098 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 char *linep = line + 12;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1102 if(sscanf(linep, "%d,%d\n", &pos.row, &pos.col) < 2) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103 printf("! screen_eol unrecognised input\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106 printf("%d\n", vterm_screen_is_eol(screen, pos));
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 else if(strstartswith(line, "?screen_attrs_extent ")) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 VTermRect rect;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111 char *linep = line + 21;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 while(linep[0] == ' ')
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 linep++;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 if(sscanf(linep, "%d,%d\n", &pos.row, &pos.col) < 2) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1115 printf("! screen_attrs_extent unrecognised input\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 rect.start_col = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 rect.end_col = -1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120 if(!vterm_screen_get_attrs_extent(screen, &rect, pos, ~0)) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 printf("! screen_attrs_extent failed\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 goto abort_line;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 printf("%d,%d-%d,%d\n", rect.start_row, rect.start_col, rect.end_row, rect.end_col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 printf("?\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 memset(line, 0, sizeof line);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130 continue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 abort_line: err = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 outlen = vterm_output_get_buffer_current(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 if(outlen > 0) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1138 char outbuff[1024];
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 vterm_output_read(vt, outbuff, outlen);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140
19989
deadaa5c2c49 patch 8.2.0550: some changes in the libvterm upstream code
Bram Moolenaar <Bram@vim.org>
parents: 19979
diff changeset
1141 term_output(outbuff, outlen, NULL);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 printf(err ? "?\n" : "DONE\n");
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 vterm_free(vt);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 }