Mercurial > vim
comparison src/libvterm/bin/vterm-dump.c @ 17777:811a12a78164 v8.1.1885
patch 8.1.1885: comments in libvterm are inconsistent
commit https://github.com/vim/vim/commit/db1085a5630ffdaa2e9f342c06cc739ebdf1a99a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 18 20:41:38 2019 +0200
patch 8.1.1885: comments in libvterm are inconsistent
Problem: Comments in libvterm are inconsistent.
Solution: Use // comments. Als update the table of combining characters.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Aug 2019 20:45:04 +0200 |
parents | 2449b6ce1456 |
children |
comparison
equal
deleted
inserted
replaced
17776:5c9a1d9d02ad | 17777:811a12a78164 |
---|---|
19 static int parser_text(const char bytes[], size_t len, void *user) | 19 static int parser_text(const char bytes[], size_t len, void *user) |
20 { | 20 { |
21 unsigned char *b = (unsigned char *)bytes; | 21 unsigned char *b = (unsigned char *)bytes; |
22 | 22 |
23 int i; | 23 int i; |
24 for(i = 0; i < len; /* none */) { | 24 for(i = 0; i < len; ) { |
25 if(b[i] < 0x20) // C0 | 25 if(b[i] < 0x20) // C0 |
26 break; | 26 break; |
27 else if(b[i] < 0x80) // ASCII | 27 else if(b[i] < 0x80) // ASCII |
28 i++; | 28 i++; |
29 else if(b[i] < 0xa0) // C1 | 29 else if(b[i] < 0xa0) // C1 |
49 | 49 |
50 printf("%.*s", i, b); | 50 printf("%.*s", i, b); |
51 return i; | 51 return i; |
52 } | 52 } |
53 | 53 |
54 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ | 54 // 0 1 2 3 4 5 6 7 8 9 A B C D E F |
55 static const char *name_c0[] = { | 55 static const char *name_c0[] = { |
56 "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "LS0", "LS1", | 56 "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "LS0", "LS1", |
57 "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", | 57 "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", |
58 }; | 58 }; |
59 static const char *name_c1[] = { | 59 static const char *name_c1[] = { |
89 printf("%sESC %.*s%s", special_begin, (int)len, bytes, special_end); | 89 printf("%sESC %.*s%s", special_begin, (int)len, bytes, special_end); |
90 | 90 |
91 return len; | 91 return len; |
92 } | 92 } |
93 | 93 |
94 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ | 94 // 0 1 2 3 4 5 6 7 8 9 A B C D E F |
95 static const char *name_csi_plain[] = { | 95 static const char *name_csi_plain[] = { |
96 "ICH", "CUU", "CUD", "CUF", "CUB", "CNL", "CPL", "CHA", "CUP", "CHT", "ED", "EL", "IL", "DL", "EF", "EA", | 96 "ICH", "CUU", "CUD", "CUF", "CUB", "CNL", "CPL", "CHA", "CUP", "CHT", "ED", "EL", "IL", "DL", "EF", "EA", |
97 "DCH", "SSE", "CPR", "SU", "SD", "NP", "PP", "CTC", "ECH", "CVT", "CBT", "SRS", "PTX", "SDS", "SIMD",NULL, | 97 "DCH", "SSE", "CPR", "SU", "SD", "NP", "PP", "CTC", "ECH", "CVT", "CBT", "SRS", "PTX", "SDS", "SIMD",NULL, |
98 "HPA", "HPR", "REP", "DA", "VPA", "VPR", "HVP", "TBC", "SM", "MC", "HPB", "VPB", "RM", "SGR", "DSR", "DAQ", | 98 "HPA", "HPR", "REP", "DA", "VPA", "VPR", "HVP", "TBC", "SM", "MC", "HPB", "VPB", "RM", "SGR", "DSR", "DAQ", |
99 }; | 99 }; |
100 | 100 |
101 /*0 4 8 B */ | 101 //0 4 8 B |
102 static const int newline_csi_plain[] = { | 102 static const int newline_csi_plain[] = { |
103 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, | 103 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, |
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, | 104 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, |
105 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, | 105 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, |
106 }; | 106 }; |
109 { | 109 { |
110 const char *name = NULL; | 110 const char *name = NULL; |
111 if(!leader && !intermed && command < 0x70) | 111 if(!leader && !intermed && command < 0x70) |
112 name = name_csi_plain[command - 0x40]; | 112 name = name_csi_plain[command - 0x40]; |
113 else if(leader && streq(leader, "?") && !intermed) { | 113 else if(leader && streq(leader, "?") && !intermed) { |
114 /* DEC */ | 114 // DEC |
115 switch(command) { | 115 switch(command) { |
116 case 'h': name = "DECSM"; break; | 116 case 'h': name = "DECSM"; break; |
117 case 'l': name = "DECRM"; break; | 117 case 'l': name = "DECRM"; break; |
118 } | 118 } |
119 if(name) | 119 if(name) |
170 | 170 |
171 return 1; | 171 return 1; |
172 } | 172 } |
173 | 173 |
174 static VTermParserCallbacks parser_cbs = { | 174 static VTermParserCallbacks parser_cbs = { |
175 &parser_text, /* text */ | 175 &parser_text, // text |
176 &parser_control, /* control */ | 176 &parser_control, // control |
177 &parser_escape, /* escape */ | 177 &parser_escape, // escape |
178 &parser_csi, /* csi */ | 178 &parser_csi, // csi |
179 &parser_osc, /* osc */ | 179 &parser_osc, // osc |
180 &parser_dcs, /* dcs */ | 180 &parser_dcs, // dcs |
181 NULL /* resize */ | 181 NULL // resize |
182 }; | 182 }; |
183 | 183 |
184 int main(int argc, char *argv[]) | 184 int main(int argc, char *argv[]) |
185 { | 185 { |
186 int use_colour = isatty(1); | 186 int use_colour = isatty(1); |
212 if(use_colour) { | 212 if(use_colour) { |
213 special_begin = "\x1b[7m{"; | 213 special_begin = "\x1b[7m{"; |
214 special_end = "}\x1b[m"; | 214 special_end = "}\x1b[m"; |
215 } | 215 } |
216 | 216 |
217 /* Size matters not for the parser */ | 217 // Size matters not for the parser |
218 vt = vterm_new(25, 80); | 218 vt = vterm_new(25, 80); |
219 vterm_set_utf8(vt, 1); | 219 vterm_set_utf8(vt, 1); |
220 vterm_parser_set_callbacks(vt, &parser_cbs, NULL); | 220 vterm_parser_set_callbacks(vt, &parser_cbs, NULL); |
221 | 221 |
222 while((len = read(fd, buffer, sizeof(buffer))) > 0) { | 222 while((len = read(fd, buffer, sizeof(buffer))) > 0) { |