Loading ...
Sorry, an error occurred while loading the content.
 

Re: Non-GUI 6.2.225 on OS X.3: digraphs gone?

Expand Messages
  • Eckehard Berns
    Hi! I ve added multi byte awareness to gui_mac.c. Vim should behave a lot more like on other platforms now. The behavior in terminal mode and in the GUI should
    Message 1 of 35 , Feb 15, 2004
      Hi!

      I've added multi byte awareness to gui_mac.c. Vim should behave a lot
      more like on other platforms now. The behavior in terminal mode and in
      the GUI should be consistent. I think this should fix the encodings
      issues and the digraph problems.

      This patch is a diff against 6.2.253, so it won't cleanly apply against
      6.2.256 and newer. This patch also doesn't cleanly apply against sources
      that use the TransBack patch.

      You will have to configure using --with-features=big or huge to get
      multi byte support.

      With the patch Vim best results should be achieved with

      :set encoding=utf-8
      :set fileencodings=ucs-bom,utf-8,latin1

      Of cause you should be able to load MacRoman encoded files with ":e
      ++enc=macroman file.ext" (see ":help ++enc").

      *** ../vim62.253/src/digraph.c Sat Feb 7 13:37:50 2004
      --- ./src/digraph.c Wed Feb 11 23:06:10 2004
      ***************
      *** 390,396 ****
      };

      # else
      ! # ifdef MACOS

      /*
      * Macintosh digraphs
      --- 390,396 ----
      };

      # else
      ! # if defined(MACOS) && !defined(FEAT_MBYTE)

      /*
      * Macintosh digraphs
      ***************
      *** 813,818 ****
      --- 813,819 ----
      {'y', ':', 0xff},

      # ifdef FEAT_MBYTE
      + # define USE_UNICODE_DIGRAPH

      {'A', '-', 0x0100},
      {'a', '-', 0x0101},
      ***************
      *** 2110,2115 ****
      --- 2111,2142 ----
      }
      }
      #ifdef FEAT_MBYTE
      + # ifdef USE_UNICODE_DIGRAPH
      + if (retval != 0 && !enc_utf8 && !enc_unicode) {
      + char_u buf[6], *to;
      + vimconv_T vc;
      + int utflen;
      +
      + i = utf_char2bytes(retval, buf);
      + if (OK == convert_setup(&vc, "utf-8", p_enc)) {
      + utflen = i;
      + to = string_convert(&vc, buf, &i);
      + if (to != NULL) {
      + /* Checking for invalid values isn't very easy. Internal
      + * latin1 conversion will return char 0xbf in case it can't be
      + * converted */
      + if ((i > 1 && !has_mbyte) ||
      + (vc.vc_type == CONV_TO_LATIN1 && utflen != 1 &&
      + to[0] == 0xbf))
      + /* assume invalid value */
      + retval = 0;
      + else
      + retval = mb_ptr2char(to);
      + vim_free(to);
      + }
      + }
      + }
      + # endif
      /* Ignore multi-byte characters when not in multi-byte mode. */
      if (!has_mbyte && retval > 0xff)
      retval = 0;
      ***************
      *** 2219,2230 ****
      --- 2246,2268 ----
      dp = digraphdefault;
      for (i = 0; dp->char1 != NUL && !got_int; ++i)
      {
      + #if defined(USE_UNICODE_DIGRAPH) && defined(FEAT_MBYTE)
      + digr_T tmp;
      +
      + tmp.char1 = dp->char1;
      + tmp.char2 = dp->char2;
      + tmp.result = getexactdigraph(tmp.char1, tmp.char2, FALSE);
      + if (tmp.result != 0 && tmp.result != tmp.char2 &&
      + (has_mbyte || tmp.result <= 255))
      + printdigraph(&tmp);
      + #else
      if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
      #ifdef FEAT_MBYTE
      && (has_mbyte || dp->result <= 255)
      #endif
      )
      printdigraph(dp);
      + #endif
      ++dp;
      ui_breakcheck();
      }
      *** ../vim62.253/src/gui_mac.c Thu Feb 12 19:16:31 2004
      --- ./src/gui_mac.c Sun Feb 15 13:13:33 2004
      ***************
      *** 2025,2031 ****
      {
      /* TODO: add support for COMMAND KEY */
      long menu;
      ! unsigned char string[10];
      short num, i;
      short len = 0;
      KeySym key_sym;
      --- 2025,2031 ----
      {
      /* TODO: add support for COMMAND KEY */
      long menu;
      ! unsigned char string[20];
      short num, i;
      short len = 0;
      KeySym key_sym;
      ***************
      *** 2129,2134 ****
      --- 2129,2156 ----
      }
      else
      {
      + #ifdef FEAT_MBYTE
      + if (input_conv.vc_type != CONV_NONE) {
      + char_u from[2], *to;
      + int l;
      +
      + from[0] = key_char;
      + from[1] = NUL;
      + l = 1;
      + to = string_convert(&input_conv, from, &l);
      + if (to != NULL) {
      + for (i = 0; i < l && len < 19; i++) {
      + if (to[i] == CSI) {
      + string[len++] = KS_EXTRA;
      + string[len++] = KE_CSI;
      + } else
      + string[len++] = to[i];
      + }
      + vim_free(to);
      + } else
      + string[len++] = key_char;
      + } else
      + #endif
      string[ len++ ] = key_char;
      }

      ***************
      *** 2874,2879 ****
      --- 2896,2905 ----
      vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
      #endif

      + #ifdef FEAT_MBYTE
      + set_option_value((char_u *)"termencoding", 0L, (char_u *)"macroman", 0);
      + #endif
      +
      /* TODO: Load bitmap if using TOOLBAR */
      return OK;
      }
      ***************
      *** 3345,3356 ****
      int len;
      int flags;
      {

      #if defined(FEAT_GUI) && defined(MACOS_X)
      /*
      * On OS X, try using Quartz-style text antialiasing.
      */
      ! SInt32 sys_version = 0;

      Gestalt(gestaltSystemVersion, &sys_version);
      if (sys_version >= 0x1020)
      --- 3371,3400 ----
      int len;
      int flags;
      {
      + #ifdef FEAT_MBYTE
      + int free_s = 0;
      + #endif
      + #if defined(FEAT_GUI) && defined(MACOS_X)
      + SInt32 sys_version;
      + #endif
      +
      + #ifdef FEAT_MBYTE
      + if (output_conv.vc_type != CONV_NONE) {
      + char_u *to;
      +
      + to = string_convert(&output_conv, s, &len);
      + if (to != NULL) {
      + s = to;
      + free_s = 1;
      + }
      + }
      + #endif

      #if defined(FEAT_GUI) && defined(MACOS_X)
      /*
      * On OS X, try using Quartz-style text antialiasing.
      */
      ! sys_version = 0;

      Gestalt(gestaltSystemVersion, &sys_version);
      if (sys_version >= 0x1020)
      ***************
      *** 3425,3430 ****
      --- 3469,3478 ----
      LineTo (FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
      }
      }
      + #ifdef FEAT_MBYTE
      + if (free_s)
      + vim_free(s);
      + #endif
      }

      /*
      ***************
      *** 3886,3892 ****

      }

      ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);

      free(tempclip);
      HUnlock(textOfClip);
      --- 3934,3953 ----

      }

      ! #ifdef FEAT_MBYTE
      ! if (input_conv.vc_type != CONV_NONE) {
      ! char_u *to;
      ! int l = scrapSize;
      !
      ! to = string_convert(&input_conv, tempclip, &l);
      ! if (to != NULL) {
      ! clip_yank_selection(type, to, l, cbd);
      ! vim_free(to);
      ! } else
      ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);
      ! } else
      ! #endif
      ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);

      free(tempclip);
      HUnlock(textOfClip);
      ***************
      *** 3941,3946 ****
      --- 4002,4022 ----
      cbd->owned = FALSE;

      type = clip_convert_selection(&str, (long_u *) &scrapSize, cbd);
      +
      + #ifdef FEAT_MBYTE
      + if (str != NULL && output_conv.vc_type != CONV_NONE) {
      + char_u *to;
      + int l;
      +
      + l = scrapSize;
      + to = string_convert(&output_conv, str, &l);
      + if (to != NULL) {
      + vim_free(str);
      + str = to;
      + scrapSize = l;
      + }
      + }
      + #endif

      if (type >= 0)
      {
      *** ../vim62.253/src/mbyte.c Mon Feb 9 19:49:27 2004
      --- ./src/mbyte.c Sat Feb 14 22:41:57 2004
      ***************
      *** 216,222 ****
      {"big5", ENC_DBCS, DBCS_CHT},
      #define IDX_CP1251 35
      {"cp1251", ENC_8BIT, 1251},
      ! #define IDX_COUNT 36
      };

      /*
      --- 216,228 ----
      {"big5", ENC_DBCS, DBCS_CHT},
      #define IDX_CP1251 35
      {"cp1251", ENC_8BIT, 1251},
      ! #if defined(MACOS_X)
      ! # define IDX_MACROMAN 36
      ! {"macroman", ENC_8BIT + ENC_MACROMAN, 0},
      ! # define IDX_COUNT 37
      ! #else
      ! # define IDX_COUNT 36
      ! #endif
      };

      /*
      ***************
      *** 290,295 ****
      --- 296,304 ----
      {"cp950", IDX_BIG5},
      {"950", IDX_BIG5},
      #endif
      + #ifdef MACOS_X
      + {"mac", IDX_MACROMAN},
      + #endif
      {NULL, 0}
      };

      ***************
      *** 374,379 ****
      --- 383,391 ----
      int idx;
      int n;
      int enc_dbcs_new = 0;
      + #ifdef MACOS_X
      + int enc_macroman = 0;
      + #endif

      if (p_enc == NULL)
      {
      ***************
      *** 454,459 ****
      --- 466,480 ----
      /* 2byte, handle below */
      enc_dbcs_new = enc_canon_table[idx].codepage;
      }
      + #ifdef MACOS_X
      + else if (i & ENC_MACROMAN)
      + {
      + /* 8-bit, but internal conversion from and to Mac Roman */
      + enc_macroman = 1;
      + enc_unicode = 0;
      + enc_utf8 = FALSE;
      + }
      + #endif
      else
      {
      /* Must be 8-bit. */
      ***************
      *** 5129,5134 ****
      --- 5150,5174 ----
      vcp->vc_cpto = (to_prop & ENC_UNICODE) ? 0 : encname2codepage(to);
      }
      #endif
      + #ifdef MACOS_X
      + else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1))
      + {
      + vcp->vc_type = CONV_MAC_LATIN1;
      + }
      + else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_UNICODE))
      + {
      + vcp->vc_type = CONV_MAC_UTF8;
      + vcp->vc_factor = 2; /* up to twice as long */
      + }
      + else if ((from_prop & ENC_LATIN1) && (to_prop & ENC_MACROMAN))
      + {
      + vcp->vc_type = CONV_LATIN1_MAC;
      + }
      + else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_MACROMAN))
      + {
      + vcp->vc_type = CONV_UTF8_MAC;
      + }
      + #endif
      # ifdef USE_ICONV
      else
      {
      ***************
      *** 5174,5179 ****
      --- 5214,5286 ----
      return dlen;
      }

      + #if defined(MACOS_X)
      + /*
      + * A Mac version of string_convert for special cases
      + */
      + static char_u *
      + mac_string_convert(ptr, len, lenp, from, to)
      + char_u *ptr;
      + int len;
      + int *lenp;
      + CFStringEncoding from;
      + CFStringEncoding to;
      + {
      + char_u *retval, *d;
      + CFStringRef cfstr;
      + int buflen, in, out, l, i;
      +
      + cfstr = CFStringCreateWithBytes(NULL, ptr, len, from, 0);
      + if (cfstr == NULL)
      + return NULL;
      + if (to == kCFStringEncodingUTF8)
      + buflen = len * 6 + 1;
      + else
      + buflen = len + 1;
      + retval = alloc(buflen);
      + if (retval == NULL) {
      + CFRelease(cfstr);
      + return NULL;
      + }
      + if (!CFStringGetCString(cfstr, retval, buflen, to))
      + {
      + CFRelease(cfstr);
      + /* conversion failed for the whole string, but maybe it will work
      + * for each character */
      + for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;) {
      + if (from == kCFStringEncodingUTF8)
      + l = utf_ptr2len_check(ptr + in);
      + else
      + l = 1;
      + cfstr = CFStringCreateWithBytes(NULL, ptr + in, l, from, 0);
      + if (cfstr == NULL) {
      + *d++ = '?';
      + out++;
      + } else {
      + if (!CFStringGetCString(cfstr, d, buflen - out, to)) {
      + *d++ = '?';
      + out++;
      + } else {
      + i = strlen(d);
      + d += i;
      + out += i;
      + }
      + CFRelease(cfstr);
      + }
      + in += l;
      + }
      + *d = NUL;
      + if (lenp != NULL)
      + *lenp = out;
      + return retval;
      + }
      + CFRelease(cfstr);
      + if (lenp != NULL)
      + *lenp = strlen(retval);
      + return retval;
      + }
      + #endif
      +
      /*
      * Convert text "ptr[*lenp]" according to "vcp".
      * Returns the result in allocated memory and sets "*lenp".
      ***************
      *** 5253,5258 ****
      --- 5360,5391 ----
      if (lenp != NULL)
      *lenp = (int)(d - retval);
      break;
      +
      + # ifdef MACOS_X
      + case CONV_MAC_LATIN1:
      + retval = mac_string_convert(ptr, len, lenp,
      + kCFStringEncodingMacRoman,
      + kCFStringEncodingISOLatin1);
      + break;
      +
      + case CONV_LATIN1_MAC:
      + retval = mac_string_convert(ptr, len, lenp,
      + kCFStringEncodingISOLatin1,
      + kCFStringEncodingMacRoman);
      + break;
      +
      + case CONV_MAC_UTF8:
      + retval = mac_string_convert(ptr, len, lenp,
      + kCFStringEncodingMacRoman,
      + kCFStringEncodingUTF8);
      + break;
      +
      + case CONV_UTF8_MAC:
      + retval = mac_string_convert(ptr, len, lenp,
      + kCFStringEncodingUTF8,
      + kCFStringEncodingMacRoman);
      + break;
      + # endif

      # ifdef USE_ICONV
      case CONV_ICONV: /* conversion with output_conv.vc_fd */
      *** ../vim62.253/src/structs.h Sat Feb 7 13:37:50 2004
      --- ./src/structs.h Thu Feb 12 20:13:27 2004
      ***************
      *** 828,833 ****
      --- 828,839 ----
      #ifdef WIN3264
      # define CONV_CODEPAGE 4 /* codepage -> codepage */
      #endif
      + #ifdef MACOS_X
      + # define CONV_MAC_LATIN1 5
      + # define CONV_LATIN1_MAC 6
      + # define CONV_MAC_UTF8 7
      + # define CONV_UTF8_MAC 8
      + #endif

      /*
      * Structure used for mappings and abbreviations.
      *** ../vim62.253/src/vim.h Thu Feb 12 19:16:31 2004
      --- ./src/vim.h Thu Feb 12 19:46:28 2004
      ***************
      *** 1653,1658 ****
      --- 1653,1661 ----
      # define ENC_2WORD 0x100 /* Unicode: UTF-16 */

      # define ENC_LATIN1 0x200 /* Latin1 */
      + # ifdef MACOS_X
      + # define ENC_MACROMAN 0x400 /* Mac Roman */
      + # endif
      #endif

      #ifdef FEAT_MBYTE

      --
      Eckehard Berns
    • Eckehard Berns
      Hi! I ve added multi byte awareness to gui_mac.c. Vim should behave a lot more like on other platforms now. The behavior in terminal mode and in the GUI should
      Message 35 of 35 , Feb 15, 2004
        Hi!

        I've added multi byte awareness to gui_mac.c. Vim should behave a lot
        more like on other platforms now. The behavior in terminal mode and in
        the GUI should be consistent. I think this should fix the encodings
        issues and the digraph problems.

        This patch is a diff against 6.2.253, so it won't cleanly apply against
        6.2.256 and newer. This patch also doesn't cleanly apply against sources
        that use the TransBack patch.

        You will have to configure using --with-features=big or huge to get
        multi byte support.

        With the patch Vim best results should be achieved with

        :set encoding=utf-8
        :set fileencodings=ucs-bom,utf-8,latin1

        Of cause you should be able to load MacRoman encoded files with ":e
        ++enc=macroman file.ext" (see ":help ++enc").

        *** ../vim62.253/src/digraph.c Sat Feb 7 13:37:50 2004
        --- ./src/digraph.c Wed Feb 11 23:06:10 2004
        ***************
        *** 390,396 ****
        };

        # else
        ! # ifdef MACOS

        /*
        * Macintosh digraphs
        --- 390,396 ----
        };

        # else
        ! # if defined(MACOS) && !defined(FEAT_MBYTE)

        /*
        * Macintosh digraphs
        ***************
        *** 813,818 ****
        --- 813,819 ----
        {'y', ':', 0xff},

        # ifdef FEAT_MBYTE
        + # define USE_UNICODE_DIGRAPH

        {'A', '-', 0x0100},
        {'a', '-', 0x0101},
        ***************
        *** 2110,2115 ****
        --- 2111,2142 ----
        }
        }
        #ifdef FEAT_MBYTE
        + # ifdef USE_UNICODE_DIGRAPH
        + if (retval != 0 && !enc_utf8 && !enc_unicode) {
        + char_u buf[6], *to;
        + vimconv_T vc;
        + int utflen;
        +
        + i = utf_char2bytes(retval, buf);
        + if (OK == convert_setup(&vc, "utf-8", p_enc)) {
        + utflen = i;
        + to = string_convert(&vc, buf, &i);
        + if (to != NULL) {
        + /* Checking for invalid values isn't very easy. Internal
        + * latin1 conversion will return char 0xbf in case it can't be
        + * converted */
        + if ((i > 1 && !has_mbyte) ||
        + (vc.vc_type == CONV_TO_LATIN1 && utflen != 1 &&
        + to[0] == 0xbf))
        + /* assume invalid value */
        + retval = 0;
        + else
        + retval = mb_ptr2char(to);
        + vim_free(to);
        + }
        + }
        + }
        + # endif
        /* Ignore multi-byte characters when not in multi-byte mode. */
        if (!has_mbyte && retval > 0xff)
        retval = 0;
        ***************
        *** 2219,2230 ****
        --- 2246,2268 ----
        dp = digraphdefault;
        for (i = 0; dp->char1 != NUL && !got_int; ++i)
        {
        + #if defined(USE_UNICODE_DIGRAPH) && defined(FEAT_MBYTE)
        + digr_T tmp;
        +
        + tmp.char1 = dp->char1;
        + tmp.char2 = dp->char2;
        + tmp.result = getexactdigraph(tmp.char1, tmp.char2, FALSE);
        + if (tmp.result != 0 && tmp.result != tmp.char2 &&
        + (has_mbyte || tmp.result <= 255))
        + printdigraph(&tmp);
        + #else
        if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
        #ifdef FEAT_MBYTE
        && (has_mbyte || dp->result <= 255)
        #endif
        )
        printdigraph(dp);
        + #endif
        ++dp;
        ui_breakcheck();
        }
        *** ../vim62.253/src/gui_mac.c Thu Feb 12 19:16:31 2004
        --- ./src/gui_mac.c Sun Feb 15 13:13:33 2004
        ***************
        *** 2025,2031 ****
        {
        /* TODO: add support for COMMAND KEY */
        long menu;
        ! unsigned char string[10];
        short num, i;
        short len = 0;
        KeySym key_sym;
        --- 2025,2031 ----
        {
        /* TODO: add support for COMMAND KEY */
        long menu;
        ! unsigned char string[20];
        short num, i;
        short len = 0;
        KeySym key_sym;
        ***************
        *** 2129,2134 ****
        --- 2129,2156 ----
        }
        else
        {
        + #ifdef FEAT_MBYTE
        + if (input_conv.vc_type != CONV_NONE) {
        + char_u from[2], *to;
        + int l;
        +
        + from[0] = key_char;
        + from[1] = NUL;
        + l = 1;
        + to = string_convert(&input_conv, from, &l);
        + if (to != NULL) {
        + for (i = 0; i < l && len < 19; i++) {
        + if (to[i] == CSI) {
        + string[len++] = KS_EXTRA;
        + string[len++] = KE_CSI;
        + } else
        + string[len++] = to[i];
        + }
        + vim_free(to);
        + } else
        + string[len++] = key_char;
        + } else
        + #endif
        string[ len++ ] = key_char;
        }

        ***************
        *** 2874,2879 ****
        --- 2896,2905 ----
        vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
        #endif

        + #ifdef FEAT_MBYTE
        + set_option_value((char_u *)"termencoding", 0L, (char_u *)"macroman", 0);
        + #endif
        +
        /* TODO: Load bitmap if using TOOLBAR */
        return OK;
        }
        ***************
        *** 3345,3356 ****
        int len;
        int flags;
        {

        #if defined(FEAT_GUI) && defined(MACOS_X)
        /*
        * On OS X, try using Quartz-style text antialiasing.
        */
        ! SInt32 sys_version = 0;

        Gestalt(gestaltSystemVersion, &sys_version);
        if (sys_version >= 0x1020)
        --- 3371,3400 ----
        int len;
        int flags;
        {
        + #ifdef FEAT_MBYTE
        + int free_s = 0;
        + #endif
        + #if defined(FEAT_GUI) && defined(MACOS_X)
        + SInt32 sys_version;
        + #endif
        +
        + #ifdef FEAT_MBYTE
        + if (output_conv.vc_type != CONV_NONE) {
        + char_u *to;
        +
        + to = string_convert(&output_conv, s, &len);
        + if (to != NULL) {
        + s = to;
        + free_s = 1;
        + }
        + }
        + #endif

        #if defined(FEAT_GUI) && defined(MACOS_X)
        /*
        * On OS X, try using Quartz-style text antialiasing.
        */
        ! sys_version = 0;

        Gestalt(gestaltSystemVersion, &sys_version);
        if (sys_version >= 0x1020)
        ***************
        *** 3425,3430 ****
        --- 3469,3478 ----
        LineTo (FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
        }
        }
        + #ifdef FEAT_MBYTE
        + if (free_s)
        + vim_free(s);
        + #endif
        }

        /*
        ***************
        *** 3886,3892 ****

        }

        ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);

        free(tempclip);
        HUnlock(textOfClip);
        --- 3934,3953 ----

        }

        ! #ifdef FEAT_MBYTE
        ! if (input_conv.vc_type != CONV_NONE) {
        ! char_u *to;
        ! int l = scrapSize;
        !
        ! to = string_convert(&input_conv, tempclip, &l);
        ! if (to != NULL) {
        ! clip_yank_selection(type, to, l, cbd);
        ! vim_free(to);
        ! } else
        ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);
        ! } else
        ! #endif
        ! clip_yank_selection(type, (char_u *) tempclip, scrapSize, cbd);

        free(tempclip);
        HUnlock(textOfClip);
        ***************
        *** 3941,3946 ****
        --- 4002,4022 ----
        cbd->owned = FALSE;

        type = clip_convert_selection(&str, (long_u *) &scrapSize, cbd);
        +
        + #ifdef FEAT_MBYTE
        + if (str != NULL && output_conv.vc_type != CONV_NONE) {
        + char_u *to;
        + int l;
        +
        + l = scrapSize;
        + to = string_convert(&output_conv, str, &l);
        + if (to != NULL) {
        + vim_free(str);
        + str = to;
        + scrapSize = l;
        + }
        + }
        + #endif

        if (type >= 0)
        {
        *** ../vim62.253/src/mbyte.c Mon Feb 9 19:49:27 2004
        --- ./src/mbyte.c Sat Feb 14 22:41:57 2004
        ***************
        *** 216,222 ****
        {"big5", ENC_DBCS, DBCS_CHT},
        #define IDX_CP1251 35
        {"cp1251", ENC_8BIT, 1251},
        ! #define IDX_COUNT 36
        };

        /*
        --- 216,228 ----
        {"big5", ENC_DBCS, DBCS_CHT},
        #define IDX_CP1251 35
        {"cp1251", ENC_8BIT, 1251},
        ! #if defined(MACOS_X)
        ! # define IDX_MACROMAN 36
        ! {"macroman", ENC_8BIT + ENC_MACROMAN, 0},
        ! # define IDX_COUNT 37
        ! #else
        ! # define IDX_COUNT 36
        ! #endif
        };

        /*
        ***************
        *** 290,295 ****
        --- 296,304 ----
        {"cp950", IDX_BIG5},
        {"950", IDX_BIG5},
        #endif
        + #ifdef MACOS_X
        + {"mac", IDX_MACROMAN},
        + #endif
        {NULL, 0}
        };

        ***************
        *** 374,379 ****
        --- 383,391 ----
        int idx;
        int n;
        int enc_dbcs_new = 0;
        + #ifdef MACOS_X
        + int enc_macroman = 0;
        + #endif

        if (p_enc == NULL)
        {
        ***************
        *** 454,459 ****
        --- 466,480 ----
        /* 2byte, handle below */
        enc_dbcs_new = enc_canon_table[idx].codepage;
        }
        + #ifdef MACOS_X
        + else if (i & ENC_MACROMAN)
        + {
        + /* 8-bit, but internal conversion from and to Mac Roman */
        + enc_macroman = 1;
        + enc_unicode = 0;
        + enc_utf8 = FALSE;
        + }
        + #endif
        else
        {
        /* Must be 8-bit. */
        ***************
        *** 5129,5134 ****
        --- 5150,5174 ----
        vcp->vc_cpto = (to_prop & ENC_UNICODE) ? 0 : encname2codepage(to);
        }
        #endif
        + #ifdef MACOS_X
        + else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1))
        + {
        + vcp->vc_type = CONV_MAC_LATIN1;
        + }
        + else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_UNICODE))
        + {
        + vcp->vc_type = CONV_MAC_UTF8;
        + vcp->vc_factor = 2; /* up to twice as long */
        + }
        + else if ((from_prop & ENC_LATIN1) && (to_prop & ENC_MACROMAN))
        + {
        + vcp->vc_type = CONV_LATIN1_MAC;
        + }
        + else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_MACROMAN))
        + {
        + vcp->vc_type = CONV_UTF8_MAC;
        + }
        + #endif
        # ifdef USE_ICONV
        else
        {
        ***************
        *** 5174,5179 ****
        --- 5214,5286 ----
        return dlen;
        }

        + #if defined(MACOS_X)
        + /*
        + * A Mac version of string_convert for special cases
        + */
        + static char_u *
        + mac_string_convert(ptr, len, lenp, from, to)
        + char_u *ptr;
        + int len;
        + int *lenp;
        + CFStringEncoding from;
        + CFStringEncoding to;
        + {
        + char_u *retval, *d;
        + CFStringRef cfstr;
        + int buflen, in, out, l, i;
        +
        + cfstr = CFStringCreateWithBytes(NULL, ptr, len, from, 0);
        + if (cfstr == NULL)
        + return NULL;
        + if (to == kCFStringEncodingUTF8)
        + buflen = len * 6 + 1;
        + else
        + buflen = len + 1;
        + retval = alloc(buflen);
        + if (retval == NULL) {
        + CFRelease(cfstr);
        + return NULL;
        + }
        + if (!CFStringGetCString(cfstr, retval, buflen, to))
        + {
        + CFRelease(cfstr);
        + /* conversion failed for the whole string, but maybe it will work
        + * for each character */
        + for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;) {
        + if (from == kCFStringEncodingUTF8)
        + l = utf_ptr2len_check(ptr + in);
        + else
        + l = 1;
        + cfstr = CFStringCreateWithBytes(NULL, ptr + in, l, from, 0);
        + if (cfstr == NULL) {
        + *d++ = '?';
        + out++;
        + } else {
        + if (!CFStringGetCString(cfstr, d, buflen - out, to)) {
        + *d++ = '?';
        + out++;
        + } else {
        + i = strlen(d);
        + d += i;
        + out += i;
        + }
        + CFRelease(cfstr);
        + }
        + in += l;
        + }
        + *d = NUL;
        + if (lenp != NULL)
        + *lenp = out;
        + return retval;
        + }
        + CFRelease(cfstr);
        + if (lenp != NULL)
        + *lenp = strlen(retval);
        + return retval;
        + }
        + #endif
        +
        /*
        * Convert text "ptr[*lenp]" according to "vcp".
        * Returns the result in allocated memory and sets "*lenp".
        ***************
        *** 5253,5258 ****
        --- 5360,5391 ----
        if (lenp != NULL)
        *lenp = (int)(d - retval);
        break;
        +
        + # ifdef MACOS_X
        + case CONV_MAC_LATIN1:
        + retval = mac_string_convert(ptr, len, lenp,
        + kCFStringEncodingMacRoman,
        + kCFStringEncodingISOLatin1);
        + break;
        +
        + case CONV_LATIN1_MAC:
        + retval = mac_string_convert(ptr, len, lenp,
        + kCFStringEncodingISOLatin1,
        + kCFStringEncodingMacRoman);
        + break;
        +
        + case CONV_MAC_UTF8:
        + retval = mac_string_convert(ptr, len, lenp,
        + kCFStringEncodingMacRoman,
        + kCFStringEncodingUTF8);
        + break;
        +
        + case CONV_UTF8_MAC:
        + retval = mac_string_convert(ptr, len, lenp,
        + kCFStringEncodingUTF8,
        + kCFStringEncodingMacRoman);
        + break;
        + # endif

        # ifdef USE_ICONV
        case CONV_ICONV: /* conversion with output_conv.vc_fd */
        *** ../vim62.253/src/structs.h Sat Feb 7 13:37:50 2004
        --- ./src/structs.h Thu Feb 12 20:13:27 2004
        ***************
        *** 828,833 ****
        --- 828,839 ----
        #ifdef WIN3264
        # define CONV_CODEPAGE 4 /* codepage -> codepage */
        #endif
        + #ifdef MACOS_X
        + # define CONV_MAC_LATIN1 5
        + # define CONV_LATIN1_MAC 6
        + # define CONV_MAC_UTF8 7
        + # define CONV_UTF8_MAC 8
        + #endif

        /*
        * Structure used for mappings and abbreviations.
        *** ../vim62.253/src/vim.h Thu Feb 12 19:16:31 2004
        --- ./src/vim.h Thu Feb 12 19:46:28 2004
        ***************
        *** 1653,1658 ****
        --- 1653,1661 ----
        # define ENC_2WORD 0x100 /* Unicode: UTF-16 */

        # define ENC_LATIN1 0x200 /* Latin1 */
        + # ifdef MACOS_X
        + # define ENC_MACROMAN 0x400 /* Mac Roman */
        + # endif
        #endif

        #ifdef FEAT_MBYTE

        --
        Eckehard Berns
      Your message has been successfully submitted and would be delivered to recipients shortly.