home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / amiga / vim46src.lha / vim-4.6 / src / digraph.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-06  |  13.7 KB  |  562 lines

  1. /* vi:set ts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved        by Bram Moolenaar
  4.  *
  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.  */
  8.  
  9. /*
  10.  * digraph.c: code for digraphs
  11.  */
  12.  
  13. #include "vim.h"
  14. #include "globals.h"
  15. #include "proto.h"
  16. #include "option.h"
  17.  
  18. #ifdef DIGRAPHS
  19.  
  20. static int getexactdigraph __ARGS((int, int, int));
  21. static void printdigraph __ARGS((char_u *));
  22.  
  23. static char_u    (*digraphnew)[3];            /* pointer to added digraphs */
  24. static int        digraphcount = 0;            /* number of added digraphs */
  25.  
  26. /*
  27.  * Some HPUX machines use a different character set by default.  I don't know
  28.  * which ones and how to check for it, but since my workstation has it, I use
  29.  * the different character set when _INCLUDE_HPUX_SOURCE is defined (until
  30.  * somebody tells me what the correct use is!).  If you want to enable or
  31.  * disable this, change a line in the Makefile.
  32.  */
  33. #if !defined(NO_HPUX_DIGRAPHS) && !defined(HPUX_DIGRAPHS) && defined(_INCLUDE_HPUX_SOURCE)
  34. # define HPUX_DIGRAPHS
  35. #endif
  36.  
  37. #if defined(MSDOS) || defined(WIN32) || defined(OS2)
  38. char_u    digraphdefault[][3] =         /* standard MSDOS digraphs */
  39.        {{'C', ',', 128},    /* ~@ (SAS C can't handle the real char) */
  40.         {'u', '"', 129},    /* ü */
  41.         {'e', '\'', 130},    /* é */
  42.         {'a', '^', 131},    /* â */
  43.         {'a', '"', 132},    /* ä */
  44.         {'a', '`', 133},    /* à */
  45.         {'a', '@', 134},    /* å */
  46.         {'c', ',', 135},    /* ~G (SAS C can't handle the real char) */
  47.         {'e', '^', 136},    /* ~H (SAS C can't handle the real char) */
  48.         {'e', '"', 137},    /* ë */
  49.         {'e', '`', 138},    /* è */
  50.         {'i', '"', 139},    /* ï */
  51.         {'i', '^', 140},    /* î */
  52.         {'i', '`', 141},    /* ì */
  53.         {'A', '"', 142},    /* Ä */
  54.         {'A', '@', 143},    /* Å */
  55.         {'E', '\'', 144},    /* É */
  56.         {'a', 'e', 145},    /* æ */
  57.         {'A', 'E', 146},    /* Æ */
  58.         {'o', '^', 147},    /* ô */
  59.         {'o', '"', 148},    /* ö */
  60.         {'o', '`', 149},    /* ò */
  61.         {'u', '^', 150},    /* û */
  62.         {'u', '`', 151},    /* ù */
  63.         {'y', '"', 152},    /* ÿ */
  64.         {'O', '"', 153},    /* Ö */
  65.         {'U', '"', 154},    /* Ü */
  66.         {'c', '|', 155},    /* ¢ */
  67.         {'$', '$', 156},    /* £ */
  68.         {'Y', '-', 157},    /* ~] (SAS C can't handle the real char) */
  69.         {'P', 't', 158},    /* ₧ */
  70.         {'f', 'f', 159},    /* ƒ */
  71.         {'a', '\'', 160},    /* á */
  72.         {'i', '\'', 161},    /* í */
  73.         {'o', '\'', 162},    /* ó */
  74.         {'u', '\'', 163},    /* xx (SAS C can't handle the real char) */
  75.         {'n', '~', 164},    /* ñ */
  76.         {'N', '~', 165},    /* Ñ */
  77.         {'a', 'a', 166},    /* ª */
  78.         {'o', 'o', 167},    /* º */
  79.         {'~', '?', 168},    /* ¿ */
  80.         {'-', 'a', 169},    /* ⌐ */
  81.         {'a', '-', 170},    /* ¬ */
  82.         {'1', '2', 171},    /* ½ */
  83.         {'1', '4', 172},    /* ¼ */
  84.         {'~', '!', 173},    /* ¡ */
  85.         {'<', '<', 174},    /* « */
  86.         {'>', '>', 175},    /* » */
  87.  
  88.         {'s', 's', 225},    /* ß */
  89.         {'j', 'u', 230},    /* µ */
  90.         {'o', '/', 237},    /* φ */
  91.         {'+', '-', 241},    /* ± */
  92.         {'>', '=', 242},    /* ≥ */
  93.         {'<', '=', 243},    /* ≤ */
  94.         {':', '-', 246},    /* ÷ */
  95.         {'~', '~', 247},    /* ≈ */
  96.         {'~', 'o', 248},    /* ° */
  97.         {'2', '2', 253},    /* ² */
  98.         {NUL, NUL, NUL}
  99.         };
  100.  
  101. #else    /* !MSDOS && !WIN32 */
  102. # ifdef __MINT__
  103. char_u    digraphdefault[][3] =         /* standard ATARI digraphs */
  104.        {{'C', ',', 128},    /* ~@ */
  105.         {'u', '"', 129},    /* ü */
  106.         {'e', '\'', 130},    /* é */
  107.         {'a', '^', 131},    /* â */
  108.         {'a', '"', 132},    /* ä */
  109.         {'a', '`', 133},    /* à */
  110.         {'a', '@', 134},    /* å */
  111.         {'c', ',', 135},    /* ~G */
  112.         {'e', '^', 136},    /* ~H */
  113.         {'e', '"', 137},    /* ë */
  114.         {'e', '`', 138},    /* è */
  115.         {'i', '"', 139},    /* ï */
  116.         {'i', '^', 140},    /* î */
  117.         {'i', '`', 141},    /* ì */
  118.         {'A', '"', 142},    /* Ä */
  119.         {'A', '@', 143},    /* Å */
  120.         {'E', '\'', 144},    /* É */
  121.         {'a', 'e', 145},    /* æ */
  122.         {'A', 'E', 146},    /* Æ */
  123.         {'o', '^', 147},    /* ô */
  124.         {'o', '"', 148},    /* ö */
  125.         {'o', '`', 149},    /* ò */
  126.         {'u', '^', 150},    /* û */
  127.         {'u', '`', 151},    /* ù */
  128.         {'y', '"', 152},    /* ÿ */
  129.         {'O', '"', 153},    /* Ö */
  130.         {'U', '"', 154},    /* Ü */
  131.            {'c', '|', 155},    /* ¢ */
  132.            {'$', '$', 156},    /* £ */
  133.            {'Y', '-', 157},    /* ~] */
  134.            {'s', 's', 158},    /* ₧ */
  135.         {'f', 'f', 159},    /* ƒ */
  136.         {'a', '\'', 160},    /* á */
  137.         {'i', '\'', 161},    /* í */
  138.         {'o', '\'', 162},    /* ó */
  139.         {'u', '\'', 163},    /* ú */
  140.         {'n', '~', 164},    /* ñ */
  141.         {'N', '~', 165},    /* Ñ */
  142.         {'a', 'a', 166},    /* ª */
  143.         {'o', 'o', 167},    /* º */
  144.         {'~', '?', 168},    /* ¿ */
  145.         {'-', 'a', 169},    /* ⌐ */
  146.         {'a', '-', 170},    /* ¬ */
  147.         {'1', '2', 171},    /* ½ */
  148.         {'1', '4', 172},    /* ¼ */
  149.         {'~', '!', 173},    /* ¡ */
  150.         {'<', '<', 174},    /* « */
  151.         {'>', '>', 175},    /* » */
  152.         {'j', 'u', 230},    /* µ */
  153.         {'o', '/', 237},    /* φ */
  154.         {'+', '-', 241},    /* ± */
  155.         {'>', '=', 242},    /* ≥ */
  156.         {'<', '=', 243},    /* ≤ */
  157.         {':', '-', 246},    /* ÷ */
  158.         {'~', '~', 247},    /* ≈ */
  159.         {'~', 'o', 248},    /* ° */
  160.         {'2', '2', 253},    /* ² */
  161.         {NUL, NUL, NUL}
  162.         };
  163.  
  164. # else    /* !__MINT__ */
  165. #  ifdef HPUX_DIGRAPHS
  166.  
  167. char_u    digraphdefault[][3] =         /* default HPUX digraphs */
  168.        {{'A', '`', 161},    /* í */
  169.         {'A', '^', 162},    /* ó */
  170.         {'E', '`', 163},    /* ú */
  171.         {'E', '^', 164},    /* ñ */
  172.         {'E', '"', 165},    /* Ñ */
  173.         {'I', '^', 166},    /* ª */
  174.         {'I', '"', 167},    /* º */
  175.         {'\'', '\'', 168},    /* ¿ */
  176.         {'`', '`', 169},    /* ⌐ */
  177.         {'^', '^', 170},    /* ¬ */
  178.         {'"', '"', 171},    /* ½ */
  179.         {'~', '~', 172},    /* ¼ */
  180.         {'U', '`', 173},    /* ¡ */
  181.         {'U', '^', 174},    /* « */
  182.         {'L', '=', 175},    /* » */
  183.         {'~', '_', 176},    /* ░ */
  184.         {'Y', '\'', 177},    /* ▒ */
  185.         {'y', '\'', 178},    /* ▓ */
  186.         {'~', 'o', 179},    /* │ */
  187.         {'C', ',', 180},    /* ┤ */
  188.         {'c', ',', 181},    /* ╡ */
  189.         {'N', '~', 182},    /* ╢ */
  190.         {'n', '~', 183},    /* ╖ */
  191.         {'~', '!', 184},    /* ╕ */
  192.         {'~', '?', 185},    /* ╣ */
  193.         {'o', 'x', 186},    /* ║ */
  194.         {'L', '-', 187},    /* ╗ */
  195.         {'Y', '=', 188},    /* ╝ */
  196.         {'p', 'p', 189},    /* ╜ */
  197.         {'f', 'l', 190},    /* ╛ */
  198.         {'c', '|', 191},    /* ┐ */
  199.         {'a', '^', 192},    /* └ */
  200.         {'e', '^', 193},    /* ┴ */
  201.         {'o', '^', 194},    /* ┬ */
  202.         {'u', '^', 195},    /* ├ */
  203.         {'a', '\'', 196},    /* ─ */
  204.         {'e', '\'', 197},    /* ┼ */
  205.         {'o', '\'', 198},    /* ╞ */
  206.         {'u', '\'', 199},    /* ╟ */
  207.         {'a', '`', 200},    /* ╚ */
  208.         {'e', '`', 201},    /* ╔ */
  209.         {'o', '`', 202},    /* ╩ */
  210.         {'u', '`', 203},    /* ╦ */
  211.         {'a', '"', 204},    /* ╠ */
  212.         {'e', '"', 205},    /* ═ */
  213.         {'o', '"', 206},    /* ╬ */
  214.         {'u', '"', 207},    /* ╧ */
  215.         {'A', 'o', 208},    /* ╨ */
  216.         {'i', '^', 209},    /* ╤ */
  217.         {'O', '/', 210},    /* ╥ */
  218.         {'A', 'E', 211},    /* ╙ */
  219.         {'a', 'o', 212},    /* ╘ */
  220.         {'i', '\'', 213},    /* ╒ */
  221.         {'o', '/', 214},    /* ╓ */
  222.         {'a', 'e', 215},    /* ╫ */
  223.         {'A', '"', 216},    /* ╪ */
  224.         {'i', '`', 217},    /* ┘ */
  225.         {'O', '"', 218},    /* ┌ */
  226.         {'U', '"', 219},    /* █ */
  227.         {'E', '\'', 220},    /* ▄ */
  228.         {'i', '"', 221},    /* ▌ */
  229.         {'s', 's', 222},    /* ▐ */
  230.         {'O', '^', 223},    /* ▀ */
  231.         {'A', '\'', 224},    /* α */
  232.         {'A', '~', 225},    /* ß */
  233.         {'a', '~', 226},    /* Γ */
  234.         {'D', '-', 227},    /* π */
  235.         {'d', '-', 228},    /* Σ */
  236.         {'I', '\'', 229},    /* σ */
  237.         {'I', '`', 230},    /* µ */
  238.         {'O', '\'', 231},    /* τ */
  239.         {'O', '`', 232},    /* Φ */
  240.         {'O', '~', 233},    /* Θ */
  241.         {'o', '~', 234},    /* Ω */
  242.         {'S', '~', 235},    /* δ */
  243.         {'s', '~', 236},    /* ∞ */
  244.         {'U', '\'', 237},    /* φ */
  245.         {'Y', '"', 238},    /* ε */
  246.         {'y', '"', 239},    /* ∩ */
  247.         {'p', '-', 240},    /* ≡ */
  248.         {'p', '~', 241},    /* ± */
  249.         {'~', '.', 242},    /* ≥ */
  250.         {'j', 'u', 243},    /* ≤ */
  251.         {'P', 'p', 244},    /* ⌠ */
  252.         {'3', '4', 245},    /* ⌡ */
  253.         {'-', '-', 246},    /* ÷ */
  254.         {'1', '4', 247},    /* ≈ */
  255.         {'1', '2', 248},    /* ° */
  256.         {'a', '_', 249},    /* ∙ */
  257.         {'o', '_', 250},    /* · */
  258.         {'<', '<', 251},    /* √ */
  259.         {'x', 'x', 252},    /* ⁿ */
  260.         {'>', '>', 253},    /* ² */
  261.         {'+', '-', 254},    /* ■ */
  262.         {'n', 'u', 255},    /* (char excluded, is EOF on some systems */
  263.         {NUL, NUL, NUL}
  264.         };
  265.  
  266. #  else    /* HPUX_DIGRAPHS */
  267.  
  268. char_u    digraphdefault[][3] =         /* standard ISO digraphs */
  269.        {{'~', '!', 161},    /* í */
  270.         {'c', '|', 162},    /* ó */
  271.         {'$', '$', 163},    /* ú */
  272.         {'o', 'x', 164},    /* ñ */
  273.         {'Y', '-', 165},    /* Ñ */
  274.         {'|', '|', 166},    /* ª */
  275.         {'p', 'a', 167},    /* º */
  276.         {'"', '"', 168},    /* ¿ */
  277.         {'c', 'O', 169},    /* ⌐ */
  278.         {'a', '-', 170},    /* ¬ */
  279.         {'<', '<', 171},    /* ½ */
  280.         {'-', ',', 172},    /* ¼ */
  281.         {'-', '-', 173},    /* ¡ */
  282.         {'r', 'O', 174},    /* « */
  283.         {'-', '=', 175},    /* » */
  284.         {'~', 'o', 176},    /* ░ */
  285.         {'+', '-', 177},    /* ▒ */
  286.         {'2', '2', 178},    /* ▓ */
  287.         {'3', '3', 179},    /* │ */
  288.         {'\'', '\'', 180},    /* ┤ */
  289.         {'j', 'u', 181},    /* ╡ */
  290.         {'p', 'p', 182},    /* ╢ */
  291.         {'~', '.', 183},    /* ╖ */
  292.         {',', ',', 184},    /* ╕ */
  293.         {'1', '1', 185},    /* ╣ */
  294.         {'o', '-', 186},    /* ║ */
  295.         {'>', '>', 187},    /* ╗ */
  296.         {'1', '4', 188},    /* ╝ */
  297.         {'1', '2', 189},    /* ╜ */
  298.         {'3', '4', 190},    /* ╛ */
  299.         {'~', '?', 191},    /* ┐ */
  300.         {'A', '`', 192},    /* └ */
  301.         {'A', '\'', 193},    /* ┴ */
  302.         {'A', '^', 194},    /* ┬ */
  303.         {'A', '~', 195},    /* ├ */
  304.         {'A', '"', 196},    /* ─ */
  305.         {'A', '@', 197},    /* ┼ */
  306.         {'A', 'E', 198},    /* ╞ */
  307.         {'C', ',', 199},    /* ╟ */
  308.         {'E', '`', 200},    /* ╚ */
  309.         {'E', '\'', 201},    /* ╔ */
  310.         {'E', '^', 202},    /* ╩ */
  311.         {'E', '"', 203},    /* ╦ */
  312.         {'I', '`', 204},    /* ╠ */
  313.         {'I', '\'', 205},    /* ═ */
  314.         {'I', '^', 206},    /* ╬ */
  315.         {'I', '"', 207},    /* ╧ */
  316.         {'D', '-', 208},    /* ╨ */
  317.         {'N', '~', 209},    /* ╤ */
  318.         {'O', '`', 210},    /* ╥ */
  319.         {'O', '\'', 211},    /* ╙ */
  320.         {'O', '^', 212},    /* ╘ */
  321.         {'O', '~', 213},    /* ╒ */
  322.         {'O', '"', 214},    /* ╓ */
  323.         {'/', '\\', 215},    /* ╫ */
  324.         {'O', '/', 216},    /* ╪ */
  325.         {'U', '`', 217},    /* ┘ */
  326.         {'U', '\'', 218},    /* ┌ */
  327.         {'U', '^', 219},    /* █ */
  328.         {'U', '"', 220},    /* ▄ */
  329.         {'Y', '\'', 221},    /* ▌ */
  330.         {'I', 'p', 222},    /* ▐ */
  331.         {'s', 's', 223},    /* ▀ */
  332.         {'a', '`', 224},    /* α */
  333.         {'a', '\'', 225},    /* ß */
  334.         {'a', '^', 226},    /* Γ */
  335.         {'a', '~', 227},    /* π */
  336.         {'a', '"', 228},    /* Σ */
  337.         {'a', '@', 229},    /* σ */
  338.         {'a', 'e', 230},    /* µ */
  339.         {'c', ',', 231},    /* τ */
  340.         {'e', '`', 232},    /* Φ */
  341.         {'e', '\'', 233},    /* Θ */
  342.         {'e', '^', 234},    /* Ω */
  343.         {'e', '"', 235},    /* δ */
  344.         {'i', '`', 236},    /* ∞ */
  345.         {'i', '\'', 237},    /* φ */
  346.         {'i', '^', 238},    /* ε */
  347.         {'i', '"', 239},    /* ∩ */
  348.         {'d', '-', 240},    /* ≡ */
  349.         {'n', '~', 241},    /* ± */
  350.         {'o', '`', 242},    /* ≥ */
  351.         {'o', '\'', 243},    /* ≤ */
  352.         {'o', '^', 244},    /* ⌠ */
  353.         {'o', '~', 245},    /* ⌡ */
  354.         {'o', '"', 246},    /* ÷ */
  355.         {':', '-', 247},    /* ≈ */
  356.         {'o', '/', 248},    /* ° */
  357.         {'u', '`', 249},    /* ∙ */
  358.         {'u', '\'', 250},    /* · */
  359.         {'u', '^', 251},    /* √ */
  360.         {'u', '"', 252},    /* ⁿ */
  361.         {'y', '\'', 253},    /* ² */
  362.         {'i', 'p', 254},    /* ■ */
  363.         {'y', '"', 255},    /* (char excluded, is EOF on some systems */
  364.         {NUL, NUL, NUL}
  365.         };
  366.  
  367. #  endif    /* HPUX_DIGRAPHS */
  368. # endif    /* !__MINT__ */
  369. #endif    /* !MSDOS && !WIN32 */
  370.  
  371. /*
  372.  * handle digraphs after typing a character
  373.  */
  374.     int
  375. do_digraph(c)
  376.     int        c;
  377. {
  378.     static int    backspaced;        /* character before K_BS */
  379.     static int    lastchar;        /* last typed character */
  380.  
  381.     if (c == -1)                /* init values */
  382.     {
  383.         backspaced = -1;
  384.     }
  385.     else if (p_dg)
  386.     {
  387.         if (backspaced >= 0)
  388.             c = getdigraph(backspaced, c, FALSE);
  389.         backspaced = -1;
  390.         if ((c == K_BS || c == Ctrl('H')) && lastchar >= 0)
  391.             backspaced = lastchar;
  392.     }
  393.     lastchar = c;
  394.     return c;
  395. }
  396.  
  397. /*
  398.  * lookup the pair char1, char2 in the digraph tables
  399.  * if no match, return char2
  400.  */
  401.     static int
  402. getexactdigraph(char1, char2, meta)
  403.     int    char1;
  404.     int    char2;
  405.     int    meta;
  406. {
  407.     int        i;
  408.     int        retval;
  409.  
  410.     if (IS_SPECIAL(char1) || IS_SPECIAL(char2))
  411.         return char2;
  412.     retval = 0;
  413.     for (i = 0; ; ++i)            /* search added digraphs first */
  414.     {
  415.         if (i == digraphcount)    /* end of added table, search defaults */
  416.         {
  417.             for (i = 0; digraphdefault[i][0] != 0; ++i)
  418.                 if (digraphdefault[i][0] == char1 && digraphdefault[i][1] == char2)
  419.                 {
  420.                     retval = digraphdefault[i][2];
  421.                     break;
  422.                 }
  423.             break;
  424.         }
  425.         if (digraphnew[i][0] == char1 && digraphnew[i][1] == char2)
  426.         {
  427.             retval = digraphnew[i][2];
  428.             break;
  429.         }
  430.     }
  431.  
  432.     if (retval == 0)            /* digraph deleted or not found */
  433.     {
  434.         if (char1 == ' ' && meta)        /* <space> <char> --> meta-char */
  435.             return (char2 | 0x80);
  436.         return char2;
  437.     }
  438.     return retval;
  439. }
  440.  
  441. /*
  442.  * Get digraph.
  443.  * Allow for both char1-char2 and char2-char1
  444.  */
  445.     int
  446. getdigraph(char1, char2, meta)
  447.     int    char1;
  448.     int    char2;
  449.     int    meta;
  450. {
  451.     int        retval;
  452.  
  453.     if (((retval = getexactdigraph(char1, char2, meta)) == char2) &&
  454.                                                            (char1 != char2) &&
  455.                     ((retval = getexactdigraph(char2, char1, meta)) == char1))
  456.         return char2;
  457.     return retval;
  458. }
  459.  
  460. /*
  461.  * put the digraphs in the argument string in the digraph table
  462.  * format: {c1}{c2} char {c1}{c2} char ...
  463.  */
  464.     void
  465. putdigraph(str)
  466.     char_u *str;
  467. {
  468.     int        char1, char2, n;
  469.     char_u    (*newtab)[3];
  470.     int        i;
  471.  
  472.     while (*str)
  473.     {
  474.         str = skipwhite(str);
  475.         if ((char1 = *str++) == 0 || (char2 = *str++) == 0)
  476.             return;
  477.         if (char1 == ESC || char2 == ESC)
  478.         {
  479.             EMSG("Escape not allowed in digraph");
  480.             return;
  481.         }
  482.         str = skipwhite(str);
  483.         if (!isdigit(*str))
  484.         {
  485.             emsg(e_number);
  486.             return;
  487.         }
  488.         n = getdigits(&str);
  489.         if (digraphnew)        /* search the table for existing entry */
  490.         {
  491.             for (i = 0; i < digraphcount; ++i)
  492.                 if (digraphnew[i][0] == char1 && digraphnew[i][1] == char2)
  493.                 {
  494.                     digraphnew[i][2] = n;
  495.                     break;
  496.                 }
  497.             if (i < digraphcount)
  498.                 continue;
  499.         }
  500.         newtab = (char_u (*)[3])alloc(digraphcount * 3 + 3);
  501.         if (newtab)
  502.         {
  503.             vim_memmove(newtab, digraphnew, (size_t)(digraphcount * 3));
  504.             vim_free(digraphnew);
  505.             digraphnew = newtab;
  506.             digraphnew[digraphcount][0] = char1;
  507.             digraphnew[digraphcount][1] = char2;
  508.             digraphnew[digraphcount][2] = n;
  509.             ++digraphcount;
  510.         }
  511.     }
  512. }
  513.  
  514.     void
  515. listdigraphs()
  516. {
  517.     int        i;
  518.  
  519.     msg_outchar('\n');
  520.     printdigraph(NULL);
  521.     for (i = 0; digraphdefault[i][0] && !got_int; ++i)
  522.     {
  523.         if (getexactdigraph(digraphdefault[i][0], digraphdefault[i][1],
  524.                                                FALSE) == digraphdefault[i][2])
  525.             printdigraph(digraphdefault[i]);
  526.         mch_breakcheck();
  527.     }
  528.     for (i = 0; i < digraphcount && !got_int; ++i)
  529.     {
  530.         printdigraph(digraphnew[i]);
  531.         mch_breakcheck();
  532.     }
  533.     must_redraw = CLEAR;    /* clear screen, because some digraphs may be wrong,
  534.                              * in which case we messed up NextScreen */
  535. }
  536.  
  537.     static void
  538. printdigraph(p)
  539.     char_u *p;
  540. {
  541.     char_u        buf[9];
  542.     static int    len;
  543.  
  544.     if (p == NULL)
  545.         len = 0;
  546.     else if (p[2] != 0)
  547.     {
  548.         if (len > Columns - 11)
  549.         {
  550.             msg_outchar('\n');
  551.             len = 0;
  552.         }
  553.         if (len)
  554.             MSG_OUTSTR("   ");
  555.         sprintf((char *)buf, "%c%c %c %3d", p[0], p[1], p[2], p[2]);
  556.         msg_outstr(buf);
  557.         len += 11;
  558.     }
  559. }
  560.  
  561. #endif /* DIGRAPHS */
  562.