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

[vim-multibyte] substitution of the multi-byte character

Expand Messages
  • Yasuhiro Matsumoto
    I made patch because the substitution of the multi-byte character wasn t good. (For example when typing r or R ) It was changed to work as follows. ...
    Message 1 of 1 , Feb 24, 2000
    • 0 Attachment
      I made patch because the substitution of the multi-byte character wasn't good.
      (For example when typing 'r' or 'R')

      It was changed to work as follows.

      ----------------------------------------------------------
      Problem : Can't replace multi-byte character.
      Solution : Replacing one single-byte character to one single-byte character.
      Replacing one multi-byte character to one single-byte character.
      Replacing one single-byte character to one multi-byte character.
      Replacing one multi-byte character to one multi-byte character.
      Files : normal.c, misc1.c


      *** src.orig/normal.c Mon Jan 17 01:42:06 2000
      --- src/normal.c Thu Feb 24 16:35:54 2000
      ***************
      *** 4521,4529 ****
      if (is_dbcs)
      {
      if (trailbyte != NUL)
      ! ptr[curwin->w_cursor.col++] = trailbyte;
      else if (IsLeadByte(prechar))
      ! (void)del_chars((long)1, TRUE);
      }
      #endif
      }
      --- 4521,4537 ----
      if (is_dbcs)
      {
      if (trailbyte != NUL)
      ! {
      ! if (IsLeadByte(prechar))
      ! ptr[curwin->w_cursor.col] = trailbyte;
      ! else
      ! (void)ins_char(trailbyte);
      ! }
      else if (IsLeadByte(prechar))
      ! {
      ! (void)del_char(TRUE);
      ! ++curwin->w_cursor.col;
      ! }
      }
      #endif
      }
      *** src.orig/misc1.c Mon Jan 17 01:42:06 2000
      --- src/misc1.c Thu Feb 24 18:06:27 2000
      ***************
      *** 1354,1359 ****
      --- 1354,1363 ----
      extra = 1;
      else
      extra = 0;
      + #ifdef MULTI_BYTE
      + if (is_dbcs && State == REPLACE && IsLeadByte(c))
      + extra = 1;
      + #endif

      /*
      * A character has to be put on the replace stack if there is a
      ***************
      *** 1410,1416 ****
      --- 1414,1438 ----
      curwin->w_p_list = old_list;
      }

      + #ifdef MULTI_BYTE
      + if (State == REPLACE && is_dbcs)
      + {
      + // check multi-byte
      + int src_is_mbyte, dst_is_mbyte;
      + src_is_mbyte = IsLeadByte(c);
      + dst_is_mbyte = IsLeadByte(*(oldp+col));
      + if (src_is_mbyte && !dst_is_mbyte)
      + newp = alloc_check((unsigned)(oldlen + extra + 1));
      + else if (!src_is_mbyte && dst_is_mbyte)
      + newp = alloc_check((unsigned)(oldlen + extra - 1));
      + else
      + newp = alloc_check((unsigned)(oldlen + extra));
      + }
      + else
      + newp = alloc_check((unsigned)(oldlen + extra));
      + #else
      newp = alloc_check((unsigned)(oldlen + extra));
      + #endif
      if (newp == NULL)
      return;
      if (col > 0)
      ***************
      *** 1422,1438 ****
      mch_memmove(p + 1, oldp + i, (size_t)(oldlen - i));
      }
      else
      ! mch_memmove(p + extra, oldp + col, (size_t)(oldlen - col));
      !
      #ifdef MULTI_BYTE
      ! /*
      ! * We define that "[]" is a multi-byte character. For example, if
      ! * replace(R) is done over "a[]" with "[]". Finally, "[]]" is
      ! * constructed, but the following line replaces "[]]" with "[] ".
      ! */
      ! if (is_dbcs && State == REPLACE && IsLeadByte(*p) && p[1] != NUL)
      ! p[1] = ' ';
      #endif
      *p = c;
      ml_replace(lnum, newp, FALSE);

      --- 1444,1461 ----
      mch_memmove(p + 1, oldp + i, (size_t)(oldlen - i));
      }
      else
      ! {
      #ifdef MULTI_BYTE
      ! // if oldp have multi-byte, erase trail byte
      ! if (is_dbcs && State == REPLACE && !IsLeadByte(*p+extra) && IsLeadByte(*(oldp+col)))
      ! mch_memmove(p + extra, oldp + col + 1, (size_t)(oldlen - col)-1);
      ! else
      ! mch_memmove(p + extra, oldp + col, (size_t)(oldlen - col));
      ! #else
      ! mch_memmove(p + extra, oldp + col, (size_t)(oldlen - col));
      #endif
      + }
      +
      *p = c;
      ml_replace(lnum, newp, FALSE);
    Your message has been successfully submitted and would be delivered to recipients shortly.