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, 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},
1943 {'"', '\'', 0xe007},
1980 # endif /* FEAT_MBYTE */
1982 /* Vim 5.x compatible digraphs that don't conflict with the above */
1983 {'~', '!', 161}, /* ¡ */
1984 {'c', '|', 162}, /* ¢ */
1985 {'$', '$', 163}, /* £ */
1986 {'o', 'x', 164}, /* ¤ - currency symbol in ISO 8859-1 */
1987 {'Y', '-', 165}, /* ¥ */
1988 {'|', '|', 166}, /* ¦ */
1989 {'c', 'O', 169}, /* © */
1990 {'-', ',', 172}, /* ¬ */
1991 {'-', '=', 175}, /* ¯ */
1992 {'~', 'o', 176}, /* ° */
1993 {'2', '2', 178}, /* ² */
1994 {'3', '3', 179}, /* ³ */
1995 {'p', 'p', 182}, /* ¶ */
1996 {'~', '.', 183}, /* · */
1997 {'1', '1', 185}, /* ¹ */
1998 {'~', '?', 191}, /* ¿ */
1999 {'A', '`', 192}, /* À */
2000 {'A', '^', 194}, /* Â */
2001 {'A', '~', 195}, /* Ã */
2002 {'A', '"', 196}, /* Ä */
2003 {'A', '@', 197}, /* Å */
2004 {'E', '`', 200}, /* È */
2005 {'E', '^', 202}, /* Ê */
2006 {'E', '"', 203}, /* Ë */
2007 {'I', '`', 204}, /* Ì */
2008 {'I', '^', 206}, /* Î */
2009 {'I', '"', 207}, /* Ï */
2010 {'N', '~', 209}, /* Ñ */
2011 {'O', '`', 210}, /* Ò */
2012 {'O', '^', 212}, /* Ô */
2013 {'O', '~', 213}, /* Õ */
2014 {'/', '\\', 215}, /* × - multiplication symbol in ISO 8859-1 */
2015 {'U', '`', 217}, /* Ù */
2016 {'U', '^', 219}, /* Û */
2017 {'I', 'p', 222}, /* Þ */
2018 {'a', '`', 224}, /* à */
2019 {'a', '^', 226}, /* â */
2020 {'a', '~', 227}, /* ã */
2021 {'a', '"', 228}, /* ä */
2022 {'a', '@', 229}, /* å */
2023 {'e', '`', 232}, /* è */
2024 {'e', '^', 234}, /* ê */
2025 {'e', '"', 235}, /* ë */
2026 {'i', '`', 236}, /* ì */
2027 {'i', '^', 238}, /* î */
2028 {'n', '~', 241}, /* ñ */
2029 {'o', '`', 242}, /* ò */
2030 {'o', '^', 244}, /* ô */
2031 {'o', '~', 245}, /* õ */
2032 {'u', '`', 249}, /* ù */
2033 {'u', '^', 251}, /* û */
2034 {'y', '"', 255}, /* x XX */
2039 # endif /* OLD_DIGRAPHS */
2041 # endif /* Macintosh */
2042 # endif /* EBCDIC */
2043 # endif /* !HPUX_DIGRAPHS */
2044 # endif /* !__MINT__ */
2045 #endif /* !MSDOS && !OS2 */
2048 * handle digraphs after typing a character
2054 static int backspaced
; /* character before K_BS */
2055 static int lastchar
; /* last typed character */
2057 if (c
== -1) /* init values */
2063 if (backspaced
>= 0)
2064 c
= getdigraph(backspaced
, c
, FALSE
);
2066 if ((c
== K_BS
|| c
== Ctrl_H
) && lastchar
>= 0)
2067 backspaced
= lastchar
;
2074 * Get a digraph. Used after typing CTRL-K on the command line or in normal
2076 * Returns composed character, or NUL when ESC was used.
2079 get_digraph(cmdline
)
2080 int cmdline
; /* TRUE when called from the cmdline */
2089 if (c
!= ESC
) /* ESC cancels CTRL-K */
2091 if (IS_SPECIAL(c
)) /* insert special key code */
2095 if (char2cells(c
) == 1
2096 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
2097 && cmdline_star
== 0
2100 putcmdline(c
, TRUE
);
2102 #ifdef FEAT_CMDL_INFO
2111 if (cc
!= ESC
) /* ESC cancels CTRL-K */
2112 return getdigraph(c
, cc
, TRUE
);
2118 * Lookup the pair "char1", "char2" in the digraph tables.
2119 * If no match, return "char2".
2120 * If "meta" is TRUE and "char1" is a space, return "char2" | 0x80.
2123 getexactdigraph(char1
, char2
, meta
)
2132 if (IS_SPECIAL(char1
) || IS_SPECIAL(char2
))
2136 * Search user digraphs first.
2138 dp
= (digr_T
*)user_digraphs
.ga_data
;
2139 for (i
= 0; i
< user_digraphs
.ga_len
; ++i
)
2141 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2143 retval
= dp
->result
;
2150 * Search default digraphs.
2154 dp
= digraphdefault
;
2155 for (i
= 0; dp
->char1
!= 0; ++i
)
2157 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2159 retval
= dp
->result
;
2166 # ifdef USE_UNICODE_DIGRAPHS
2167 if (retval
!= 0 && !enc_utf8
)
2173 * Convert the Unicode digraph to 'encoding'.
2175 i
= utf_char2bytes(retval
, buf
);
2177 vc
.vc_type
= CONV_NONE
;
2178 if (convert_setup(&vc
, (char_u
*)"utf-8", p_enc
) == OK
)
2181 to
= string_convert(&vc
, buf
, &i
);
2184 retval
= (*mb_ptr2char
)(to
);
2187 (void)convert_setup(&vc
, NULL
, NULL
);
2192 /* Ignore multi-byte characters when not in multi-byte mode. */
2193 if (!has_mbyte
&& retval
> 0xff)
2197 if (retval
== 0) /* digraph deleted or not found */
2199 if (char1
== ' ' && meta
) /* <space> <char> --> meta-char */
2200 return (char2
| 0x80);
2208 * Allow for both char1-char2 and char2-char1
2211 getdigraph(char1
, char2
, meta
)
2218 if (((retval
= getexactdigraph(char1
, char2
, meta
)) == char2
)
2220 && ((retval
= getexactdigraph(char2
, char1
, meta
)) == char1
))
2226 * Add the digraphs in the argument to the digraph table.
2227 * format: {c1}{c2} char {c1}{c2} char ...
2233 int char1
, char2
, n
;
2239 str
= skipwhite(str
);
2249 if (char1
== ESC
|| char2
== ESC
)
2251 EMSG(_("E104: Escape not allowed in digraph"));
2254 str
= skipwhite(str
);
2255 if (!VIM_ISDIGIT(*str
))
2257 EMSG(_(e_number_exp
));
2260 n
= getdigits(&str
);
2262 /* If the digraph already exists, replace the result. */
2263 dp
= (digr_T
*)user_digraphs
.ga_data
;
2264 for (i
= 0; i
< user_digraphs
.ga_len
; ++i
)
2266 if ((int)dp
->char1
== char1
&& (int)dp
->char2
== char2
)
2274 /* Add a new digraph to the table. */
2275 if (i
== user_digraphs
.ga_len
)
2277 if (ga_grow(&user_digraphs
, 1) == OK
)
2279 dp
= (digr_T
*)user_digraphs
.ga_data
+ user_digraphs
.ga_len
;
2283 ++user_digraphs
.ga_len
;
2297 dp
= digraphdefault
;
2298 for (i
= 0; dp
->char1
!= NUL
&& !got_int
; ++i
)
2300 #if defined(USE_UNICODE_DIGRAPHS) && defined(FEAT_MBYTE)
2303 /* May need to convert the result to 'encoding'. */
2304 tmp
.char1
= dp
->char1
;
2305 tmp
.char2
= dp
->char2
;
2306 tmp
.result
= getexactdigraph(tmp
.char1
, tmp
.char2
, FALSE
);
2307 if (tmp
.result
!= 0 && tmp
.result
!= tmp
.char2
2308 && (has_mbyte
|| tmp
.result
<= 255))
2312 if (getexactdigraph(dp
->char1
, dp
->char2
, FALSE
) == dp
->result
2314 && (has_mbyte
|| dp
->result
<= 255)
2323 dp
= (digr_T
*)user_digraphs
.ga_data
;
2324 for (i
= 0; i
< user_digraphs
.ga_len
&& !got_int
; ++i
)
2330 must_redraw
= CLEAR
; /* clear screen, because some digraphs may be
2331 wrong, in which case we messed up ScreenLines */
2343 if ((dy_flags
& DY_UHEX
)
2352 if (dp
->result
!= 0)
2354 if (msg_col
> Columns
- list_width
)
2357 while (msg_col
% list_width
!= 0)
2367 /* add a space to draw a composing char on */
2368 if (enc_utf8
&& utf_iscomposing(dp
->result
))
2370 p
+= (*mb_char2bytes
)(dp
->result
, p
);
2375 if (char2cells(dp
->result
) == 1)
2377 sprintf((char *)p
, " %3d", dp
->result
);
2382 #endif /* FEAT_DIGRAPHS */
2384 #if defined(FEAT_KEYMAP) || defined(PROTO)
2386 /* structure used for b_kmap_ga.ga_data */
2393 #define KMAP_MAXLEN 20 /* maximum length of "from" or "to" */
2395 static void keymap_unload
__ARGS((void));
2398 * Set up key mapping tables for the 'keymap' option
2403 curbuf
->b_kmap_state
&= ~KEYMAP_INIT
;
2405 if (*curbuf
->b_p_keymap
== NUL
)
2407 /* Stop any active keymap and clear the table. Also remove
2408 * b:keymap_name, as no keymap is active now. */
2410 do_cmdline_cmd((char_u
*)"unlet! b:keymap_name");
2416 /* Source the keymap file. It will contain a ":loadkeymap" command
2417 * which will call ex_loadkeymap() below. */
2418 buf
= alloc((unsigned)(STRLEN(curbuf
->b_p_keymap
)
2427 /* try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' */
2428 sprintf((char *)buf
, "keymap/%s_%s.vim", curbuf
->b_p_keymap
, p_enc
);
2429 if (source_runtime(buf
, FALSE
) == FAIL
)
2432 /* try finding "keymap/'keymap'.vim" in 'runtimepath' */
2433 sprintf((char *)buf
, "keymap/%s.vim", curbuf
->b_p_keymap
);
2434 if (source_runtime(buf
, FALSE
) == FAIL
)
2437 return (char_u
*)N_("E544: Keymap file not found");
2447 * ":loadkeymap" command: load the following lines as the keymap.
2457 #define KMAP_LLEN 200 /* max length of "to" and "from" together */
2458 char_u buf
[KMAP_LLEN
+ 11];
2460 char_u
*save_cpo
= p_cpo
;
2462 if (!getline_equal(eap
->getline
, eap
->cookie
, getsourceline
))
2464 EMSG(_("E105: Using :loadkeymap not in a sourced file"));
2469 * Stop any active keymap and clear the table.
2473 curbuf
->b_kmap_state
= 0;
2474 ga_init2(&curbuf
->b_kmap_ga
, (int)sizeof(kmap_T
), 20);
2476 /* Set 'cpoptions' to "C" to avoid line continuation. */
2477 p_cpo
= (char_u
*)"C";
2480 * Get each line of the sourced file, break at the end.
2484 line
= eap
->getline(0, eap
->cookie
, 0);
2488 p
= skipwhite(line
);
2489 if (*p
!= '"' && *p
!= NUL
&& ga_grow(&curbuf
->b_kmap_ga
, 1) == OK
)
2491 kp
= (kmap_T
*)curbuf
->b_kmap_ga
.ga_data
+ curbuf
->b_kmap_ga
.ga_len
;
2493 kp
->from
= vim_strnsave(p
, (int)(s
- p
));
2496 kp
->to
= vim_strnsave(p
, (int)(s
- p
));
2498 if (kp
->from
== NULL
|| kp
->to
== NULL
2499 || STRLEN(kp
->from
) + STRLEN(kp
->to
) >= KMAP_LLEN
2500 || *kp
->from
== NUL
|| *kp
->to
== NUL
)
2502 if (kp
->to
!= NULL
&& *kp
->to
== NUL
)
2503 EMSG(_("E791: Empty keymap entry"));
2508 ++curbuf
->b_kmap_ga
.ga_len
;
2514 * setup ":lnoremap" to map the keys
2516 for (i
= 0; i
< curbuf
->b_kmap_ga
.ga_len
; ++i
)
2518 vim_snprintf((char *)buf
, sizeof(buf
), "<buffer> %s %s",
2519 ((kmap_T
*)curbuf
->b_kmap_ga
.ga_data
)[i
].from
,
2520 ((kmap_T
*)curbuf
->b_kmap_ga
.ga_data
)[i
].to
);
2521 (void)do_map(2, buf
, LANGMAP
, FALSE
);
2526 curbuf
->b_kmap_state
|= KEYMAP_LOADED
;
2528 status_redraw_curbuf();
2533 * Stop using 'keymap'.
2538 char_u buf
[KMAP_MAXLEN
+ 10];
2540 char_u
*save_cpo
= p_cpo
;
2542 if (!(curbuf
->b_kmap_state
& KEYMAP_LOADED
))
2545 /* Set 'cpoptions' to "C" to avoid line continuation. */
2546 p_cpo
= (char_u
*)"C";
2548 /* clear the ":lmap"s */
2549 for (i
= 0; i
< curbuf
->b_kmap_ga
.ga_len
; ++i
)
2551 vim_snprintf((char *)buf
, sizeof(buf
), "<buffer> %s",
2552 ((kmap_T
*)curbuf
->b_kmap_ga
.ga_data
)[i
].from
);
2553 (void)do_map(1, buf
, LANGMAP
, FALSE
);
2558 ga_clear(&curbuf
->b_kmap_ga
);
2559 curbuf
->b_kmap_state
&= ~KEYMAP_LOADED
;
2561 status_redraw_curbuf();
2565 #endif /* FEAT_KEYMAP */