1 /* vi:set ts=8 sts=4 sw=4:
3 * VIM - Vi IMproved by Bram Moolenaar
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
11 * digraph.c: code for digraphs
16 #if defined(FEAT_DIGRAPHS) || defined(PROTO)
21 typedef char_u result_T
;
24 typedef struct digraph
31 static int getexactdigraph
__ARGS((int, int, int));
32 static void printdigraph
__ARGS((digr_T
*));
34 /* digraphs added by the user */
35 static garray_T user_digraphs
= {0, 0, (int)sizeof(digr_T
), 10, NULL
};
38 * Note: Characters marked with XX are not included literally, because some
39 * compilers cannot handle them (Amiga SAS/C is the most picky one).
41 static digr_T digraphdefault
[] =
42 #if defined(MSDOS) || defined(OS2)
46 {{'C', ',', 128}, /* ~@ XX */
47 {'u', '"', 129}, /* � */
48 {'e', '\'', 130}, /* ‚ */
49 {'a', '^', 131}, /* ƒ */
50 {'a', '"', 132}, /* „ */
51 {'a', '`', 133}, /* … */
52 {'a', '@', 134}, /* † */
53 {'c', ',', 135}, /* ~G XX */
54 {'e', '^', 136}, /* ~H XX */
55 {'e', '"', 137}, /* ‰ */
56 {'e', '`', 138}, /* Š */
57 {'i', '"', 139}, /* ‹ */
58 {'i', '^', 140}, /* Œ */
59 {'i', '`', 141}, /* � */
60 {'A', '"', 142}, /* ~N XX */
61 {'A', '@', 143}, /* � */
62 {'E', '\'', 144}, /* � */
63 {'a', 'e', 145}, /* ‘ */
64 {'A', 'E', 146}, /* ’ */
65 {'o', '^', 147}, /* “ */
66 {'o', '"', 148}, /* ” */
67 {'o', '`', 149}, /* • */
68 {'u', '^', 150}, /* – */
69 {'u', '`', 151}, /* — */
70 {'y', '"', 152}, /* ˜ */
71 {'O', '"', 153}, /* ™ */
72 {'U', '"', 154}, /* š */
73 {'c', '|', 155}, /* › */
74 {'$', '$', 156}, /* œ */
75 {'Y', '-', 157}, /* ~] XX */
76 {'P', 't', 158}, /* ž */
77 {'f', 'f', 159}, /* Ÿ */
78 {'a', '\'', 160}, /* */
79 {'i', '\'', 161}, /* ¡ */
80 {'o', '\'', 162}, /* ¢ */
81 {'u', '\'', 163}, /* x XX */
82 {'n', '~', 164}, /* ¤ */
83 {'N', '~', 165}, /* ¥ */
84 {'a', 'a', 166}, /* ¦ */
85 {'o', 'o', 167}, /* § */
86 {'~', '?', 168}, /* ¨ */
87 {'-', 'a', 169}, /* © */
88 {'a', '-', 170}, /* ª */
89 {'1', '2', 171}, /* « */
90 {'1', '4', 172}, /* ¬ */
91 {'~', '!', 173}, /* */
92 {'<', '<', 174}, /* ® */
93 {'>', '>', 175}, /* ¯ */
95 {'s', 's', 225}, /* á */
96 {'j', 'u', 230}, /* æ */
97 {'o', '/', 237}, /* í */
98 {'+', '-', 241}, /* ñ */
99 {'>', '=', 242}, /* ò */
100 {'<', '=', 243}, /* ó */
101 {':', '-', 246}, /* ö */
102 {'~', '~', 247}, /* ÷ */
103 {'~', 'o', 248}, /* ø */
104 {'2', '2', 253}, /* ý */
108 #else /* !MSDOS && !OS2 */
114 {{'C', ',', 128}, /* ~@ XX */
115 {'u', '"', 129}, /* � */
116 {'e', '\'', 130}, /* ‚ */
117 {'a', '^', 131}, /* ƒ */
118 {'a', '"', 132}, /* „ */
119 {'a', '`', 133}, /* … */
120 {'a', '@', 134}, /* † */
121 {'c', ',', 135}, /* ~G XX */
122 {'e', '^', 136}, /* ~H XX */
123 {'e', '"', 137}, /* ‰ */
124 {'e', '`', 138}, /* Š */
125 {'i', '"', 139}, /* ‹ */
126 {'i', '^', 140}, /* Œ */
127 {'i', '`', 141}, /* � */
128 {'A', '"', 142}, /* Ž */
129 {'A', '@', 143}, /* � */
130 {'E', '\'', 144}, /* � */
131 {'a', 'e', 145}, /* ‘ */
132 {'A', 'E', 146}, /* ’ */
133 {'o', '^', 147}, /* “ */
134 {'o', '"', 148}, /* ” */
135 {'o', '`', 149}, /* • */
136 {'u', '^', 150}, /* – */
137 {'u', '`', 151}, /* — */
138 {'y', '"', 152}, /* ˜ */
139 {'O', '"', 153}, /* ™ */
140 {'U', '"', 154}, /* š */
141 {'c', '|', 155}, /* › */
142 {'$', '$', 156}, /* œ */
143 {'Y', '-', 157}, /* ~] XX */
144 {'s', 's', 158}, /* ž */
145 {'f', 'f', 159}, /* Ÿ */
146 {'a', '\'', 160}, /* */
147 {'i', '\'', 161}, /* ¡ */
148 {'o', '\'', 162}, /* ¢ */
149 {'u', '\'', 163}, /* £ */
150 {'n', '~', 164}, /* ¤ */
151 {'N', '~', 165}, /* ¥ */
152 {'a', 'a', 166}, /* ¦ */
153 {'o', 'o', 167}, /* § */
154 {'~', '?', 168}, /* ¨ */
155 {'-', 'a', 169}, /* © */
156 {'a', '-', 170}, /* ª */
157 {'1', '2', 171}, /* « */
158 {'1', '4', 172}, /* ¬ */
159 {'~', '!', 173}, /* */
160 {'<', '<', 174}, /* ® */
161 {'>', '>', 175}, /* ¯ */
162 {'j', 'u', 230}, /* æ */
163 {'o', '/', 237}, /* í */
164 {'+', '-', 241}, /* ñ */
165 {'>', '=', 242}, /* ò */
166 {'<', '=', 243}, /* ó */
167 {':', '-', 246}, /* ö */
168 {'~', '~', 247}, /* ÷ */
169 {'~', 'o', 248}, /* ø */
170 {'2', '2', 253}, /* ý */
174 # else /* !__MINT__ */
175 # ifdef HPUX_DIGRAPHS
178 * different HPUX digraphs
180 {{'A', '`', 161}, /* ¡ */
181 {'A', '^', 162}, /* ¢ */
182 {'E', '`', 163}, /* £ */
183 {'E', '^', 164}, /* ¤ */
184 {'E', '"', 165}, /* ¥ */
185 {'I', '^', 166}, /* ¦ */
186 {'I', '"', 167}, /* § */
187 {'\'', '\'', 168}, /* ¨ */
188 {'`', '`', 169}, /* © */
189 {'^', '^', 170}, /* ª */
190 {'"', '"', 171}, /* « */
191 {'~', '~', 172}, /* ¬ */
192 {'U', '`', 173}, /* */
193 {'U', '^', 174}, /* ® */
194 {'L', '=', 175}, /* ¯ */
195 {'~', '_', 176}, /* ° */
196 {'Y', '\'', 177}, /* ± */
197 {'y', '\'', 178}, /* ² */
198 {'~', 'o', 179}, /* ³ */
199 {'C', ',', 180}, /* ´ */
200 {'c', ',', 181}, /* µ */
201 {'N', '~', 182}, /* ¶ */
202 {'n', '~', 183}, /* · */
203 {'~', '!', 184}, /* ¸ */
204 {'~', '?', 185}, /* ¹ */
205 {'o', 'x', 186}, /* º */
206 {'L', '-', 187}, /* » */
207 {'Y', '=', 188}, /* ¼ */
208 {'p', 'p', 189}, /* ½ */
209 {'f', 'l', 190}, /* ¾ */
210 {'c', '|', 191}, /* ¿ */
211 {'a', '^', 192}, /* À */
212 {'e', '^', 193}, /* Á */
213 {'o', '^', 194}, /* Â */
214 {'u', '^', 195}, /* Ã */
215 {'a', '\'', 196}, /* Ä */
216 {'e', '\'', 197}, /* Å */
217 {'o', '\'', 198}, /* Æ */
218 {'u', '\'', 199}, /* Ç */
219 {'a', '`', 200}, /* È */
220 {'e', '`', 201}, /* É */
221 {'o', '`', 202}, /* Ê */
222 {'u', '`', 203}, /* Ë */
223 {'a', '"', 204}, /* Ì */
224 {'e', '"', 205}, /* Í */
225 {'o', '"', 206}, /* Î */
226 {'u', '"', 207}, /* Ï */
227 {'A', 'o', 208}, /* Ð */
228 {'i', '^', 209}, /* Ñ */
229 {'O', '/', 210}, /* Ò */
230 {'A', 'E', 211}, /* Ó */
231 {'a', 'o', 212}, /* Ô */
232 {'i', '\'', 213}, /* Õ */
233 {'o', '/', 214}, /* Ö */
234 {'a', 'e', 215}, /* × */
235 {'A', '"', 216}, /* Ø */
236 {'i', '`', 217}, /* Ù */
237 {'O', '"', 218}, /* Ú */
238 {'U', '"', 219}, /* Û */
239 {'E', '\'', 220}, /* Ü */
240 {'i', '"', 221}, /* Ý */
241 {'s', 's', 222}, /* Þ */
242 {'O', '^', 223}, /* ß */
243 {'A', '\'', 224}, /* à */
244 {'A', '~', 225}, /* á */
245 {'a', '~', 226}, /* â */
246 {'D', '-', 227}, /* ã */
247 {'d', '-', 228}, /* ä */
248 {'I', '\'', 229}, /* å */
249 {'I', '`', 230}, /* æ */
250 {'O', '\'', 231}, /* ç */
251 {'O', '`', 232}, /* è */
252 {'O', '~', 233}, /* é */
253 {'o', '~', 234}, /* ê */
254 {'S', '~', 235}, /* ë */
255 {'s', '~', 236}, /* ì */
256 {'U', '\'', 237}, /* í */
257 {'Y', '"', 238}, /* î */
258 {'y', '"', 239}, /* ï */
259 {'p', '-', 240}, /* ð */
260 {'p', '~', 241}, /* ñ */
261 {'~', '.', 242}, /* ò */
262 {'j', 'u', 243}, /* ó */
263 {'P', 'p', 244}, /* ô */
264 {'3', '4', 245}, /* õ */
265 {'-', '-', 246}, /* ö */
266 {'1', '4', 247}, /* ÷ */
267 {'1', '2', 248}, /* ø */
268 {'a', '_', 249}, /* ù */
269 {'o', '_', 250}, /* ú */
270 {'<', '<', 251}, /* û */
271 {'x', 'x', 252}, /* ü */
272 {'>', '>', 253}, /* ý */
273 {'+', '-', 254}, /* þ */
274 {'n', 'u', 255}, /* x XX */
278 # else /* !HPUX_DIGRAPHS */
283 * EBCDIC - ISO digraphs
284 * TODO: EBCDIC Table is Code-Page 1047
286 {{'a', '^', 66}, /* â */
287 {'a', '"', 67}, /* ä */
288 {'a', '`', 68}, /* à */
289 {'a', '\'', 69}, /* á */
290 {'a', '~', 70}, /* ã */
291 {'a', '@', 71}, /* å */
292 {'a', 'a', 71}, /* å */
293 {'c', ',', 72}, /* ç */
294 {'n', '~', 73}, /* ñ */
295 {'c', '|', 74}, /* ¢ */
296 {'e', '\'', 81}, /* é */
297 {'e', '^', 82}, /* ê */
298 {'e', '"', 83}, /* ë */
299 {'e', '`', 84}, /* è */
300 {'i', '\'', 85}, /* í */
301 {'i', '^', 86}, /* î */
302 {'i', '"', 87}, /* ï */
303 {'i', '`', 88}, /* ì */
304 {'s', 's', 89}, /* ß */
305 {'A', '^', 98}, /* Â */
306 {'A', '"', 99}, /* Ä */
307 {'A', '`', 100}, /* À */
308 {'A', '\'', 101}, /* Á */
309 {'A', '~', 102}, /* Ã */
310 {'A', '@', 103}, /* Å */
311 {'A', 'A', 103}, /* Å */
312 {'C', ',', 104}, /* Ç */
313 {'N', '~', 105}, /* Ñ */
314 {'|', '|', 106}, /* ¦ */
315 {'o', '/', 112}, /* ø */
316 {'E', '\'', 113}, /* É */
317 {'E', '^', 114}, /* Ê */
318 {'E', '"', 115}, /* Ë */
319 {'E', '`', 116}, /* È */
320 {'I', '\'', 117}, /* Í */
321 {'I', '^', 118}, /* Î */
322 {'I', '"', 119}, /* Ï */
323 {'I', '`', 120}, /* Ì */
324 {'O', '/', 128}, /* 0/ XX */
325 {'<', '<', 138}, /* « */
326 {'>', '>', 139}, /* » */
327 {'d', '-', 140}, /* ð */
328 {'y', '\'', 141}, /* ý */
329 {'i', 'p', 142}, /* þ */
330 {'+', '-', 143}, /* ± */
331 {'~', 'o', 144}, /* ° */
332 {'a', '-', 154}, /* ª */
333 {'o', '-', 155}, /* º */
334 {'a', 'e', 156}, /* æ */
335 {',', ',', 157}, /* , XX */
336 {'A', 'E', 158}, /* Æ */
337 {'o', 'x', 159}, /* ¤ - currency symbol in ISO 8859-1 */
338 {'e', '=', 159}, /* ¤ - euro symbol in ISO 8859-15 */
339 {'E', 'u', 159}, /* ¤ - euro symbol in ISO 8859-15 */
340 {'j', 'u', 160}, /* µ */
341 {'y', '"', 167}, /* x XX */
342 {'~', '!', 170}, /* ¡ */
343 {'~', '?', 171}, /* ¿ */
344 {'D', '-', 172}, /* Ð */
345 {'I', 'p', 174}, /* Þ */
346 {'r', 'O', 175}, /* ® */
347 {'-', ',', 176}, /* ¬ */
348 {'$', '$', 177}, /* £ */
349 {'Y', '-', 178}, /* ¥ */
350 {'~', '.', 179}, /* · */
351 {'c', 'O', 180}, /* © */
352 {'p', 'a', 181}, /* § */
353 {'p', 'p', 182}, /* ¶ */
354 {'1', '4', 183}, /* ¼ */
355 {'1', '2', 184}, /* ½ */
356 {'3', '4', 185}, /* ¾ */
357 {'Y', '\'', 186}, /* Ý */
358 {'"', '"', 187}, /* ¨ */
359 {'-', '=', 188}, /* ¯ */
360 {'\'', '\'', 190}, /* ´ */
361 {'O', 'E', 191}, /* × - OE in ISO 8859-15 */
362 {'/', '\\', 191}, /* × - multiplication symbol in ISO 8859-1 */
363 {'-', '-', 202}, /* */
364 {'o', '^', 203}, /* ô */
365 {'o', '"', 204}, /* ö */
366 {'o', '`', 205}, /* ò */
367 {'o', '\'', 206}, /* ó */
368 {'o', '~', 207}, /* õ */
369 {'1', '1', 218}, /* ¹ */
370 {'u', '^', 219}, /* û */
371 {'u', '"', 220}, /* ü */
372 {'u', '`', 221}, /* ù */
373 {'u', '\'', 222}, /* ú */
374 {':', '-', 225}, /* ÷ - division symbol in ISO 8859-1 */
375 {'o', 'e', 225}, /* ÷ - oe in ISO 8859-15 */
376 {'2', '2', 234}, /* ² */
377 {'O', '^', 235}, /* Ô */
378 {'O', '"', 236}, /* Ö */
379 {'O', '`', 237}, /* Ò */
380 {'O', '\'', 238}, /* Ó */
381 {'O', '~', 239}, /* Õ */
382 {'3', '3', 250}, /* ³ */
383 {'U', '^', 251}, /* Û */
384 {'U', '"', 252}, /* Ü */
385 {'U', '`', 253}, /* Ù */
386 {'U', '\'', 254}, /* Ú */
391 # if defined(MACOS) && !defined(FEAT_MBYTE)
396 {{'a', 't', 64}, /* @ */
397 {'A', '"', 128}, /* ~@ XX */
398 {'A', 'o', 129}, /* Å */
399 {'C', ',', 130}, /* Ç */
400 {'E', '\'', 131}, /* É */
401 {'N', '~', 132}, /* Ñ */
402 {'O', '"', 133}, /* Ö */
403 {'U', '"', 134}, /* Ü */
404 {'a', '\'', 135}, /* ~G XX */
405 {'a', '`', 136}, /* ~H XX */
406 {'a', '^', 137}, /* â */
407 {'a', '"', 138}, /* ä */
408 {'a', '~', 139}, /* ã */
409 {'a', 'o', 140}, /* å */
410 {'c', ',', 141}, /* ç */
411 {'e', '\'', 142}, /* é */
412 {'e', '`', 143}, /* è */
413 {'e', '^', 144}, /* ê */
414 {'e', '"', 145}, /* ë */
415 {'i', '\'', 146}, /* í */
416 {'i', '`', 147}, /* ì */
417 {'i', '^', 148}, /* î */
418 {'i', '"', 149}, /* ï */
419 {'n', '~', 150}, /* ñ */
420 {'o', '\'', 151}, /* ó */
421 {'o', '`', 152}, /* ò */
422 {'o', '^', 153}, /* ô */
423 {'o', '"', 154}, /* ö */
424 {'o', '~', 155}, /* o */
425 {'u', '\'', 156}, /* ú */
426 {'u', '`', 157}, /* ~] XX */
427 {'u', '^', 158}, /* û */
428 {'u', '"', 159}, /* ü */
429 {'+', '_', 160}, /* Ý */
430 {'~', 'o', 161}, /* ° */
431 {'c', '|', 162}, /* ¢ */
432 {'$', '$', 163}, /* £ */
433 {'p', 'a', 164}, /* § */
434 {'.', '.', 165}, /* * */
435 {'P', 'P', 166}, /* ¶ */
436 {'s', 's', 167}, /* ß */
437 {'r', 'O', 168}, /* ® */
438 {'c', 'O', 169}, /* © */
439 {'T', 'M', 170}, /* � */
440 {'=', '/', 173}, /* ‚ */
441 {'A', 'E', 174}, /* Æ */
442 {'O', '/', 175}, /* Ø */
443 {'0', '0', 176}, /* ƒ */
444 {'+', '-', 177}, /* ± */
445 {'<', '=', 178}, /* ¾ */
446 {'>', '=', 179}, /* „ */
447 {'Y', '-', 180}, /* ¥ */
448 {'j', 'u', 181}, /* µ */
449 {'m', 'u', 181}, /* µ */
450 {'d', 'd', 182}, /* � */
451 {'S', 'S', 183}, /* … */
452 {'S', 'I', 183}, /* … */
453 {'P', 'I', 184}, /* ½ */
454 {'p', 'i', 185}, /* ¼ */
455 {'I', 'I', 186}, /* † */
456 {'a', '-', 187}, /* » */
457 {'o', '-', 188}, /* º */
458 {'O', 'M', 189}, /* ½ */
459 {'a', 'e', 190}, /* æ */
460 {'o', '/', 191}, /* ø */
461 {'~', '?', 192}, /* ¿ */
462 {'~', '!', 193}, /* ¡ */
463 {'-', ',', 194}, /* ¬ */
464 {'v', '-', 195}, /* ~H XX */
465 {'f', '-', 196}, /* Ÿ */
466 {'~', '~', 197}, /* ‰ */
467 {'D', 'E', 198}, /* � */
468 {'<', '<', 199}, /* « */
469 {'>', '>', 200}, /* » */
470 {'.', ':', 201}, /* Š */
471 {'A', '`', 203}, /* À */
472 {'A', '~', 204}, /* Ã */
473 {'O', '~', 205}, /* Õ */
474 {'O', 'E', 206}, /* ‘ */
475 {'o', 'e', 207}, /* ¦ */
476 {'-', '.', 208}, /* - */
477 {'-', '-', 209}, /* - */
478 {'`', '`', 210}, /* " */
479 {'\'', '\'', 211}, /* " */
480 {'`', ' ', 212}, /* ' */
481 {'\'', ' ', 213}, /* ' */
482 {'-', ':', 214}, /* ÷ */
483 {'D', 'I', 215}, /* × */
484 {'y', ':', 216}, /* ÿ */
485 {'Y', ':', 217}, /* � */
486 {'/', '/', 218}, /* Ž */
487 {'E', '=', 219}, /* ¤ Euro System >=8.5 */
488 {'o', 'x', 219}, /* ¤ Currency System <=8.1*/
489 {'<', ' ', 220}, /* Ð */
490 {'>', ' ', 221}, /* ð */
491 {'f', 'i', 222}, /* Þ */
492 {'f', 'l', 223}, /* þ */
493 {'+', '+', 224}, /* ý */
494 {'~', '.', 225}, /* · */
495 {',', ' ', 226}, /* ’ */
496 {',', ',', 227}, /* “ */
497 {'%', '.', 228}, /* ” */
498 {'%', '0', 228}, /* ” */
499 {'A', '^', 229}, /* Â */
500 {'E', '^', 230}, /* Ê */
501 {'A', '\'', 231}, /* Á */
502 {'E', '"', 232}, /* Ë */
503 {'E', '`', 233}, /* È */
504 {'I', '\'', 234}, /* Í */
505 {'I', '^', 235}, /* Î */
506 {'I', '"', 236}, /* Ï */
507 {'I', '`', 237}, /* Ì */
508 {'O', '\'', 238}, /* Ó */
509 {'O', '^', 239}, /* Ô */
510 {'A', 'P', 240}, /* • */
511 {'O', '`', 241}, /* Ò */
512 {'U', '\'', 242}, /* Ú */
513 {'U', '^', 243}, /* Û */
514 {'U', '`', 244}, /* Ù */
515 {'i', '.', 245}, /* ž */
524 * digraphs compatible with Vim 5.x
526 {{'~', '!', 161}, /* ¡ */
527 {'c', '|', 162}, /* ¢ */
528 {'$', '$', 163}, /* £ */
529 {'o', 'x', 164}, /* ¤ - currency symbol in ISO 8859-1 */
530 {'e', '=', 164}, /* ¤ - euro symbol in ISO 8859-15 */
531 {'Y', '-', 165}, /* ¥ */
532 {'|', '|', 166}, /* ¦ */
533 {'p', 'a', 167}, /* § */
534 {'"', '"', 168}, /* ¨ */
535 {'c', 'O', 169}, /* © */
536 {'a', '-', 170}, /* ª */
537 {'<', '<', 171}, /* « */
538 {'-', ',', 172}, /* ¬ */
539 {'-', '-', 173}, /* */
540 {'r', 'O', 174}, /* ® */
541 {'-', '=', 175}, /* ¯ */
542 {'~', 'o', 176}, /* ° */
543 {'+', '-', 177}, /* ± */
544 {'2', '2', 178}, /* ² */
545 {'3', '3', 179}, /* ³ */
546 {'\'', '\'', 180}, /* ´ */
547 {'j', 'u', 181}, /* µ */
548 {'p', 'p', 182}, /* ¶ */
549 {'~', '.', 183}, /* · */
550 {',', ',', 184}, /* ¸ */
551 {'1', '1', 185}, /* ¹ */
552 {'o', '-', 186}, /* º */
553 {'>', '>', 187}, /* » */
554 {'1', '4', 188}, /* ¼ */
555 {'1', '2', 189}, /* ½ */
556 {'3', '4', 190}, /* ¾ */
557 {'~', '?', 191}, /* ¿ */
558 {'A', '`', 192}, /* À */
559 {'A', '\'', 193}, /* Á */
560 {'A', '^', 194}, /* Â */
561 {'A', '~', 195}, /* Ã */
562 {'A', '"', 196}, /* Ä */
563 {'A', '@', 197}, /* Å */
564 {'A', 'A', 197}, /* Å */
565 {'A', 'E', 198}, /* Æ */
566 {'C', ',', 199}, /* Ç */
567 {'E', '`', 200}, /* È */
568 {'E', '\'', 201}, /* É */
569 {'E', '^', 202}, /* Ê */
570 {'E', '"', 203}, /* Ë */
571 {'I', '`', 204}, /* Ì */
572 {'I', '\'', 205}, /* Í */
573 {'I', '^', 206}, /* Î */
574 {'I', '"', 207}, /* Ï */
575 {'D', '-', 208}, /* Ð */
576 {'N', '~', 209}, /* Ñ */
577 {'O', '`', 210}, /* Ò */
578 {'O', '\'', 211}, /* Ó */
579 {'O', '^', 212}, /* Ô */
580 {'O', '~', 213}, /* Õ */
581 {'O', '"', 214}, /* Ö */
582 {'/', '\\', 215}, /* × - multiplication symbol in ISO 8859-1 */
583 {'O', 'E', 215}, /* × - OE in ISO 8859-15 */
584 {'O', '/', 216}, /* Ø */
585 {'U', '`', 217}, /* Ù */
586 {'U', '\'', 218}, /* Ú */
587 {'U', '^', 219}, /* Û */
588 {'U', '"', 220}, /* Ü */
589 {'Y', '\'', 221}, /* Ý */
590 {'I', 'p', 222}, /* Þ */
591 {'s', 's', 223}, /* ß */
592 {'a', '`', 224}, /* à */
593 {'a', '\'', 225}, /* á */
594 {'a', '^', 226}, /* â */
595 {'a', '~', 227}, /* ã */
596 {'a', '"', 228}, /* ä */
597 {'a', '@', 229}, /* å */
598 {'a', 'a', 229}, /* å */
599 {'a', 'e', 230}, /* æ */
600 {'c', ',', 231}, /* ç */
601 {'e', '`', 232}, /* è */
602 {'e', '\'', 233}, /* é */
603 {'e', '^', 234}, /* ê */
604 {'e', '"', 235}, /* ë */
605 {'i', '`', 236}, /* ì */
606 {'i', '\'', 237}, /* í */
607 {'i', '^', 238}, /* î */
608 {'i', '"', 239}, /* ï */
609 {'d', '-', 240}, /* ð */
610 {'n', '~', 241}, /* ñ */
611 {'o', '`', 242}, /* ò */
612 {'o', '\'', 243}, /* ó */
613 {'o', '^', 244}, /* ô */
614 {'o', '~', 245}, /* õ */
615 {'o', '"', 246}, /* ö */
616 {':', '-', 247}, /* ÷ - division symbol in ISO 8859-1 */
617 {'o', 'e', 247}, /* ÷ - oe in ISO 8859-15 */
618 {'o', '/', 248}, /* ø */
619 {'u', '`', 249}, /* ù */
620 {'u', '\'', 250}, /* ú */
621 {'u', '^', 251}, /* û */
622 {'u', '"', 252}, /* ü */
623 {'y', '\'', 253}, /* ý */
624 {'i', 'p', 254}, /* þ */
625 {'y', '"', 255}, /* x XX */
628 # else /* OLD_DIGRAPHS */
631 * digraphs for Unicode from RFC1345
632 * (also work for ISO-8859-1 aka latin1)
635 {'N', 'U', 0x0a}, /* LF for NUL */
811 # define USE_UNICODE_DIGRAPHS
1055 {'\'', 'G', 0x03d8},
1065 {'\'', '%', 0x03f4},
1139 {'=', '\'', 0x044a},
1141 {'%', '\'', 0x044c},
1201 {'H', '\'', 0x0621},
1242 {'\'', '+', 0x064f},
1280 {'K', '\'', 0x1e30},
1281 {'k', '\'', 0x1e31},
1286 {'M', '\'', 0x1e3e},
1287 {'m', '\'', 0x1e3f},
1294 {'P', '\'', 0x1e54},
1295 {'p', '\'', 0x1e55},
1312 {'W', '\'', 0x1e82},
1313 {'w', '\'', 0x1e83},
1350 {';', '\'', 0x1f00},
1351 {',', '\'', 0x1f01},
1371 {'\'', '6', 0x2018},
1372 {'\'', '9', 0x2019},
1374 {'9', '\'', 0x201b},
1383 {'1', '\'', 0x2032},
1384 {'2', '\'', 0x2033},
1385 {'3', '\'', 0x2034},
1393 {'\'', '-', 0x203e},
1426 {'=', 'e', 0x20ac}, /* euro */
1427 {'E', 'u', 0x20ac}, /* euro */
1693 {'<', '\'', 0x300c},
1694 {'>', '\'', 0x300d},
1701 {'(', '\'', 0x3014},
1702 {')', '\'', 0x3015},
1936 /* code points 0xe000 - 0xefff excluded, they have no assigned
1937 * characters, only used in proposals. */
1943 # endif /* FEAT_MBYTE */
1945 /* Vim 5.x compatible digraphs that don't conflict with the above */
1946 {'~', '!', 161}, /* ¡ */
1947 {'c', '|', 162}, /* ¢ */
1948 {'$', '$', 163}, /* £ */
1949 {'o', 'x', 164}, /* ¤ - currency symbol in ISO 8859-1 */
1950 {'Y', '-', 165}, /* ¥ */
1951 {'|', '|', 166}, /* ¦ */
1952 {'c', 'O', 169}, /* © */
1953 {'-', ',', 172}, /* ¬ */
1954 {'-', '=', 175}, /* ¯ */
1955 {'~', 'o', 176}, /* ° */
1956 {'2', '2', 178}, /* ² */
1957 {'3', '3', 179}, /* ³ */
1958 {'p', 'p', 182}, /* ¶ */
1959 {'~', '.', 183}, /* · */
1960 {'1', '1', 185}, /* ¹ */
1961 {'~', '?', 191}, /* ¿ */
1962 {'A', '`', 192}, /* À */
1963 {'A', '^', 194}, /* Â */
1964 {'A', '~', 195}, /* Ã */
1965 {'A', '"', 196}, /* Ä */
1966 {'A', '@', 197}, /* Å */
1967 {'E', '`', 200}, /* È */
1968 {'E', '^', 202}, /* Ê */
1969 {'E', '"', 203}, /* Ë */
1970 {'I', '`', 204}, /* Ì */
1971 {'I', '^', 206}, /* Î */
1972 {'I', '"', 207}, /* Ï */
1973 {'N', '~', 209}, /* Ñ */
1974 {'O', '`', 210}, /* Ò */
1975 {'O', '^', 212}, /* Ô */
1976 {'O', '~', 213}, /* Õ */
1977 {'/', '\\', 215}, /* × - multiplication symbol in ISO 8859-1 */
1978 {'U', '`', 217}, /* Ù */
1979 {'U', '^', 219}, /* Û */
1980 {'I', 'p', 222}, /* Þ */
1981 {'a', '`', 224}, /* à */
1982 {'a', '^', 226}, /* â */
1983 {'a', '~', 227}, /* ã */
1984 {'a', '"', 228}, /* ä */
1985 {'a', '@', 229}, /* å */
1986 {'e', '`', 232}, /* è */
1987 {'e', '^', 234}, /* ê */
1988 {'e', '"', 235}, /* ë */
1989 {'i', '`', 236}, /* ì */
1990 {'i', '^', 238}, /* î */
1991 {'n', '~', 241}, /* ñ */
1992 {'o', '`', 242}, /* ò */
1993 {'o', '^', 244}, /* ô */
1994 {'o', '~', 245}, /* õ */
1995 {'u', '`', 249}, /* ù */
1996 {'u', '^', 251}, /* û */
1997 {'y', '"', 255}, /* x XX */
2002 # endif /* OLD_DIGRAPHS */
2004 # endif /* Macintosh */
2005 # endif /* EBCDIC */
2006 # endif /* !HPUX_DIGRAPHS */
2007 # endif /* !__MINT__ */
2008 #endif /* !MSDOS && !OS2 */
2011 * handle digraphs after typing a character
2017 static int backspaced
; /* character before K_BS */
2018 static int lastchar
; /* last typed character */
2020 if (c
== -1) /* init values */
2026 if (backspaced
>= 0)
2027 c
= getdigraph(backspaced
, c
, FALSE
);
2029 if ((c
== K_BS
|| c
== Ctrl_H
) && lastchar
>= 0)
2030 backspaced
= lastchar
;
2037 * Get a digraph. Used after typing CTRL-K on the command line or in normal
2039 * Returns composed character, or NUL when ESC was used.
2042 get_digraph(cmdline
)
2043 int cmdline
; /* TRUE when called from the cmdline */
2052 if (c
!= ESC
) /* ESC cancels CTRL-K */
2054 if (IS_SPECIAL(c
)) /* insert special key code */
2058 if (char2cells(c
) == 1
2059 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
2060 && cmdline_star
== 0
2063 putcmdline(c
, TRUE
);
2065 #ifdef FEAT_CMDL_INFO
2074 if (cc
!= ESC
) /* ESC cancels CTRL-K */
2075 return getdigraph(c
, cc
, TRUE
);
2081 * Lookup the pair "char1", "char2" in the digraph tables.
2082 * If no match, return "char2".
2083 * If "meta" is TRUE and "char1" is a space, return "char2" | 0x80.
2086 getexactdigraph(char1
, char2
, meta
)
2095 if (IS_SPECIAL(char1
) || IS_SPECIAL(char2
))
2099 * Search user digraphs first.
2101 dp
= (digr_T
*)user_digraphs
.ga_data
;
2102 for (i
= 0; i
< user_digraphs
.ga_len
; ++i
)
2104 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2106 retval
= dp
->result
;
2113 * Search default digraphs.
2117 dp
= digraphdefault
;
2118 for (i
= 0; dp
->char1
!= 0; ++i
)
2120 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2122 retval
= dp
->result
;
2129 # ifdef USE_UNICODE_DIGRAPHS
2130 if (retval
!= 0 && !enc_utf8
)
2136 * Convert the Unicode digraph to 'encoding'.
2138 i
= utf_char2bytes(retval
, buf
);
2140 vc
.vc_type
= CONV_NONE
;
2141 if (convert_setup(&vc
, (char_u
*)"utf-8", p_enc
) == OK
)
2144 to
= string_convert(&vc
, buf
, &i
);
2147 retval
= (*mb_ptr2char
)(to
);
2150 (void)convert_setup(&vc
, NULL
, NULL
);
2155 /* Ignore multi-byte characters when not in multi-byte mode. */
2156 if (!has_mbyte
&& retval
> 0xff)
2160 if (retval
== 0) /* digraph deleted or not found */
2162 if (char1
== ' ' && meta
) /* <space> <char> --> meta-char */
2163 return (char2
| 0x80);
2171 * Allow for both char1-char2 and char2-char1
2174 getdigraph(char1
, char2
, meta
)
2181 if (((retval
= getexactdigraph(char1
, char2
, meta
)) == char2
)
2183 && ((retval
= getexactdigraph(char2
, char1
, meta
)) == char1
))
2189 * Add the digraphs in the argument to the digraph table.
2190 * format: {c1}{c2} char {c1}{c2} char ...
2196 int char1
, char2
, n
;
2202 str
= skipwhite(str
);
2212 if (char1
== ESC
|| char2
== ESC
)
2214 EMSG(_("E104: Escape not allowed in digraph"));
2217 str
= skipwhite(str
);
2218 if (!VIM_ISDIGIT(*str
))
2220 EMSG(_(e_number_exp
));
2223 n
= getdigits(&str
);
2225 /* If the digraph already exists, replace the result. */
2226 dp
= (digr_T
*)user_digraphs
.ga_data
;
2227 for (i
= 0; i
< user_digraphs
.ga_len
; ++i
)
2229 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2237 /* Add a new digraph to the table. */
2238 if (i
== user_digraphs
.ga_len
)
2240 if (ga_grow(&user_digraphs
, 1) == OK
)
2242 dp
= (digr_T
*)user_digraphs
.ga_data
+ user_digraphs
.ga_len
;
2246 ++user_digraphs
.ga_len
;
2260 dp
= digraphdefault
;
2261 for (i
= 0; dp
->char1
!= NUL
&& !got_int
; ++i
)
2263 #if defined(USE_UNICODE_DIGRAPHS) && defined(FEAT_MBYTE)
2266 /* May need to convert the result to 'encoding'. */
2267 tmp
.char1
= dp
->char1
;
2268 tmp
.char2
= dp
->char2
;
2269 tmp
.result
= getexactdigraph(tmp
.char1
, tmp
.char2
, FALSE
);
2270 if (tmp
.result
!= 0 && tmp
.result
!= tmp
.char2
2271 && (has_mbyte
|| tmp
.result
<= 255))
2275 if (getexactdigraph(dp
->char1
, dp
->char2
, FALSE
) == dp
->result
2277 && (has_mbyte
|| dp
->result
<= 255)
2286 dp
= (digr_T
*)user_digraphs
.ga_data
;
2287 for (i
= 0; i
< user_digraphs
.ga_len
&& !got_int
; ++i
)
2293 must_redraw
= CLEAR
; /* clear screen, because some digraphs may be
2294 wrong, in which case we messed up ScreenLines */
2306 if ((dy_flags
& DY_UHEX
)
2315 if (dp
->result
!= 0)
2317 if (msg_col
> Columns
- list_width
)
2320 while (msg_col
% list_width
!= 0)
2330 /* add a space to draw a composing char on */
2331 if (enc_utf8
&& utf_iscomposing(dp
->result
))
2333 p
+= (*mb_char2bytes
)(dp
->result
, p
);
2337 *p
++ = (char_u
)dp
->result
;
2338 if (char2cells(dp
->result
) == 1)
2340 vim_snprintf((char *)p
, sizeof(buf
) - (p
- buf
), " %3d", dp
->result
);
2345 #endif /* FEAT_DIGRAPHS */
2347 #if defined(FEAT_KEYMAP) || defined(PROTO)
2349 /* structure used for b_kmap_ga.ga_data */
2356 #define KMAP_MAXLEN 20 /* maximum length of "from" or "to" */
2358 static void keymap_unload
__ARGS((void));
2361 * Set up key mapping tables for the 'keymap' option.
2362 * Returns NULL if OK, an error message for failure. This only needs to be
2363 * used when setting the option, not later when the value has already been
2369 curbuf
->b_kmap_state
&= ~KEYMAP_INIT
;
2371 if (*curbuf
->b_p_keymap
== NUL
)
2373 /* Stop any active keymap and clear the table. Also remove
2374 * b:keymap_name, as no keymap is active now. */
2376 do_cmdline_cmd((char_u
*)"unlet! b:keymap_name");
2383 /* Source the keymap file. It will contain a ":loadkeymap" command
2384 * which will call ex_loadkeymap() below. */
2385 buflen
= STRLEN(curbuf
->b_p_keymap
)
2390 buf
= alloc((unsigned)buflen
);
2395 /* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */
2396 vim_snprintf((char *)buf
, buflen
, "keymap/%s_%s.vim",
2397 curbuf
->b_p_keymap
, p_enc
);
2398 if (source_runtime(buf
, FALSE
) == FAIL
)
2401 /* try finding "keymap/'keymap'.vim" in 'runtimepath' */
2402 vim_snprintf((char *)buf
, buflen
, "keymap/%s.vim",
2403 curbuf
->b_p_keymap
);
2404 if (source_runtime(buf
, FALSE
) == FAIL
)
2407 return (char_u
*)N_("E544: Keymap file not found");
2417 * ":loadkeymap" command: load the following lines as the keymap.
2427 #define KMAP_LLEN 200 /* max length of "to" and "from" together */
2428 char_u buf
[KMAP_LLEN
+ 11];
2430 char_u
*save_cpo
= p_cpo
;
2432 if (!getline_equal(eap
->getline
, eap
->cookie
, getsourceline
))
2434 EMSG(_("E105: Using :loadkeymap not in a sourced file"));
2439 * Stop any active keymap and clear the table.
2443 curbuf
->b_kmap_state
= 0;
2444 ga_init2(&curbuf
->b_kmap_ga
, (int)sizeof(kmap_T
), 20);
2446 /* Set 'cpoptions' to "C" to avoid line continuation. */
2447 p_cpo
= (char_u
*)"C";
2450 * Get each line of the sourced file, break at the end.
2454 line
= eap
->getline(0, eap
->cookie
, 0);
2458 p
= skipwhite(line
);
2459 if (*p
!= '"' && *p
!= NUL
&& ga_grow(&curbuf
->b_kmap_ga
, 1) == OK
)
2461 kp
= (kmap_T
*)curbuf
->b_kmap_ga
.ga_data
+ curbuf
->b_kmap_ga
.ga_len
;
2463 kp
->from
= vim_strnsave(p
, (int)(s
- p
));
2466 kp
->to
= vim_strnsave(p
, (int)(s
- p
));
2468 if (kp
->from
== NULL
|| kp
->to
== NULL
2469 || STRLEN(kp
->from
) + STRLEN(kp
->to
) >= KMAP_LLEN
2470 || *kp
->from
== NUL
|| *kp
->to
== NUL
)
2472 if (kp
->to
!= NULL
&& *kp
->to
== NUL
)
2473 EMSG(_("E791: Empty keymap entry"));
2478 ++curbuf
->b_kmap_ga
.ga_len
;
2484 * setup ":lnoremap" to map the keys
2486 for (i
= 0; i
< curbuf
->b_kmap_ga
.ga_len
; ++i
)
2488 vim_snprintf((char *)buf
, sizeof(buf
), "<buffer> %s %s",
2489 ((kmap_T
*)curbuf
->b_kmap_ga
.ga_data
)[i
].from
,
2490 ((kmap_T
*)curbuf
->b_kmap_ga
.ga_data
)[i
].to
);
2491 (void)do_map(2, buf
, LANGMAP
, FALSE
);
2496 curbuf
->b_kmap_state
|= KEYMAP_LOADED
;
2498 status_redraw_curbuf();
2503 * Stop using 'keymap'.
2508 char_u buf
[KMAP_MAXLEN
+ 10];
2510 char_u
*save_cpo
= p_cpo
;
2513 if (!(curbuf
->b_kmap_state
& KEYMAP_LOADED
))
2516 /* Set 'cpoptions' to "C" to avoid line continuation. */
2517 p_cpo
= (char_u
*)"C";
2519 /* clear the ":lmap"s */
2520 kp
= (kmap_T
*)curbuf
->b_kmap_ga
.ga_data
;
2521 for (i
= 0; i
< curbuf
->b_kmap_ga
.ga_len
; ++i
)
2523 vim_snprintf((char *)buf
, sizeof(buf
), "<buffer> %s", kp
[i
].from
);
2524 (void)do_map(1, buf
, LANGMAP
, FALSE
);
2525 vim_free(kp
[i
].from
);
2531 ga_clear(&curbuf
->b_kmap_ga
);
2532 curbuf
->b_kmap_state
&= ~KEYMAP_LOADED
;
2534 status_redraw_curbuf();
2538 #endif /* FEAT_KEYMAP */