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

Re: multi-byte patch for message line

Expand Messages
  • Taro Muraoka
    Hi, Yasuhiro Matsumoto and vim-multibyte. ... I have tested that patch again. It seems working good except 2 problems. First one of problems is command
    Message 1 of 4 , May 29, 2000
    View Source
    • 0 Attachment
      Hi, Yasuhiro Matsumoto and vim-multibyte.

      > > Hello.
      > >
      > > > I made a patch for 'message line'.
      > > > This make 'message line' showing multi-byte.
      > >
      > > I have tested this.
      >
      > Thank you.
      >
      > > My patch progam failed this HUNK. Are any other patches required? I have
      > > tried to patch to original 5.6.70 source.
      >
      > Sorry, It seem old patch.
      > Below is correctly.
      > ( I made from 5.6.072 )


      I have tested that patch again. It seems working good except 2
      problems. First one of problems is command "echo" print an
      extra-character per a multibyte character. The character is a trail
      byte of a multibyte character.

      Another one is sources on patch have no tabs. It makes too difficult to
      see sources.

      I revised these points and made new patch attached to this mail.
      ----
      Taro Muraoka <koron@...>



      Problem: Vim can not show multibyte characters on message line.
      Solution: Add some multi-byte check routines at showing messages.
      (Original: Yasuhiro Matsumoto)
      Files: src/eval.c src/ex_getln.c src/message.c src/misc2.c src/screen.c

      diff -cr src.orig/eval.c src/eval.c
      *** src.orig/eval.c Sat Apr 01 00:21:22 2000
      --- src/eval.c Mon May 29 16:36:18 2000
      ***************
      *** 4652,4657 ****
      --- 4652,4658 ----
      else if (echo)
      msg_puts_attr((char_u *)" ", echo_attr);
      for (p = get_var_string(&retvar); *p != NUL && !got_int; ++p)
      + {
      if (*p == '\n' || *p == '\r' || *p == TAB)
      {
      if (*p != TAB && needclr)
      ***************
      *** 4663,4669 ****
      --- 4664,4677 ----
      msg_putchar_attr(*p, echo_attr);
      }
      else
      + {
      (void)msg_outtrans_len_attr(p, 1, echo_attr);
      + #ifdef MULTI_BYTE
      + if (is_dbcs && *(p + 1) && IsLeadByte(*p))
      + ++p;
      + #endif
      + }
      + }
      }
      clear_var(&retvar);
      arg = skipwhite(arg);
      diff -cr src.orig/ex_getln.c src/ex_getln.c
      *** src.orig/ex_getln.c Tue Apr 04 06:29:14 2000
      --- src/ex_getln.c Mon May 29 16:36:18 2000
      ***************
      *** 1352,1357 ****
      --- 1352,1363 ----
      else
      #endif
      c = charsize(ccline.cmdbuff[i]);
      + #ifdef MULTI_BYTE
      + /* multibyte wrap */
      + if (is_dbcs && IsLeadByte(ccline.cmdbuff[i])
      + && ccline.cmdspos % Columns + c == Columns)
      + ccline.cmdspos++;
      + #endif
      /* If the cmdline doesn't fit, put cursor on last visible char. */
      if ((ccline.cmdspos += c) >= m)
      {
      ***************
      *** 1687,1692 ****
      --- 1693,1699 ----
      int retval;
      int i;
      int m;
      + int c;

      if (len < 0)
      len = STRLEN(str);
      ***************
      *** 1735,1753 ****
      m = Columns * Rows;
      else
      m = MAXCOL;
      ! while (len--)
      {
      #ifdef CRYPTV
      if (cmdline_crypt)
      ! i = 1;
      else
      #endif
      ! i = charsize(str[len]);
      /* Stop cursor at the end of the screen */
      ! if (ccline.cmdspos + i >= m)
      break;
      ++ccline.cmdpos;
      ! ccline.cmdspos += i;
      }
      }
      }
      --- 1742,1766 ----
      m = Columns * Rows;
      else
      m = MAXCOL;
      ! for (i = 0; i < len; ++i)
      {
      #ifdef CRYPTV
      if (cmdline_crypt)
      ! c = 1;
      else
      #endif
      ! c = charsize(str[i]);
      ! #ifdef MULTI_BYTE
      ! /* multibyte wrap */
      ! if (is_dbcs && IsLeadByte(str[i])
      ! && ccline.cmdspos%Columns + c == Columns)
      ! ccline.cmdspos++;
      ! #endif
      /* Stop cursor at the end of the screen */
      ! if (ccline.cmdspos + c >= m)
      break;
      ++ccline.cmdpos;
      ! ccline.cmdspos += c;
      }
      }
      }
      diff -cr src.orig/message.c src/message.c
      *** src.orig/message.c Tue Dec 07 01:58:36 1999
      --- src/message.c Mon May 29 16:36:18 2000
      ***************
      *** 857,862 ****
      --- 857,877 ----

      while (--len >= 0)
      {
      + #ifdef MULTI_BYTE
      + /* check multibyte */
      + if(is_dbcs && *(str + 1) && IsLeadByte(*str))
      + {
      + char_u buf[3];
      +
      + buf[0] = *str++;
      + buf[1] = *str++;
      + buf[2] = NUL;
      + msg_puts_attr(buf, attr);
      + retval += 2;
      + --len;
      + continue;
      + }
      + #endif
      msg_puts_attr(transchar(*str), attr);
      retval += charsize(*str);
      ++str;
      ***************
      *** 1229,1236 ****
      --- 1244,1257 ----
      * (some terminals scroll automatically, some don't. To avoid
      * problems we scroll ourselves)
      */
      + #ifdef MULTI_BYTE
      + if (msg_row >= Rows - 1 && (*s == '\n' || msg_col >= Columns - 1 ||
      + (*s == TAB && msg_col >= ((Columns - 1) & ~7)) ||
      + (is_dbcs && IsLeadByte(*s) && msg_col >= Columns - 2)))
      + #else
      if (msg_row >= Rows - 1 && (*s == '\n' || msg_col >= Columns - 1 ||
      (*s == TAB && msg_col >= ((Columns - 1) & ~7))))
      + #endif
      {
      /* When no more prompt an no more room, truncate here */
      if (msg_no_more && lines_left == 0)
      ***************
      *** 1373,1378 ****
      --- 1394,1424 ----
      msg_screen_putchar(' ', attr);
      while (msg_col & 7);
      }
      + #ifdef MULTI_BYTE
      + else if (is_dbcs && *(s + 1) && IsLeadByte(*s))
      + {
      + if (msg_col % Columns == Columns - 1)
      + {
      + msg_screen_putchar('>', hl_attr(HLF_AT));
      + continue;
      + }
      + else
      + {
      + char_u mbyte[3]; /* only for dbcs */
      +
      + mbyte[0] = *s;
      + mbyte[1] = *(s + 1);
      + mbyte[2] = NUL;
      + screen_puts(mbyte, msg_row, msg_col, attr);
      + if ((msg_col += 2) >= Columns)
      + {
      + msg_col = 0;
      + ++msg_row;
      + }
      + ++s;
      + }
      + }
      + #endif
      else
      msg_screen_putchar(*s, attr);
      ++s;
      diff -cr src.orig/misc2.c src/misc2.c
      *** src.orig/misc2.c Fri Mar 24 09:23:32 2000
      --- src/misc2.c Mon May 29 16:36:18 2000
      ***************
      *** 673,678 ****
      --- 673,686 ----
      length = 1; /* count the trailing '/' and NUL */
      for (p = string; *p; p++)
      {
      + #ifdef MULTI_BYTE
      + if(is_dbcs && *(p + 1) && IsLeadByte(*p))
      + {
      + length += 2;
      + ++p; /* skip multibyte */
      + continue;
      + }
      + #endif
      if (vim_strchr(esc_chars, *p) != NULL)
      ++length; /* count a backslash */
      ++length; /* count an ordinary char */
      ***************
      *** 683,688 ****
      --- 691,704 ----
      p2 = escaped_string;
      for (p = string; *p; p++)
      {
      + #ifdef MULTI_BYTE
      + if(is_dbcs && *(p + 1) && IsLeadByte(*p))
      + {
      + *p2++ = *p++; /* skip multibyte lead */
      + *p2++ = *p; /* skip multibyte trail */
      + continue;
      + }
      + #endif
      if (vim_strchr(esc_chars, *p) != NULL)
      *p2++ = '\\';
      *p2++ = *p;
      diff -cr src.orig/screen.c src/screen.c
      *** src.orig/screen.c Thu Apr 13 20:52:04 2000
      --- src/screen.c Mon May 29 16:36:18 2000
      ***************
      *** 3217,3222 ****
      --- 3217,3248 ----
      screenp = LinePointers[row] + col;
      while (*text && col < Columns)
      {
      + #ifdef MULTI_BYTE
      + char_u is_mbyte = FALSE;
      +
      + if (is_dbcs && *(text + 1) && IsLeadByte(*text))
      + {
      + /* check if multibyte need refresh */
      + if (*screenp != *text || *(screenp + 1) != *(text + 1))
      + is_mbyte = TRUE;
      + }
      + if (*screenp != *text || *(screenp + Columns) != attr ||
      + exmode_active || is_mbyte)
      + {
      + *screenp = *text;
      + *(screenp + Columns) = attr;
      + screen_char(screenp, row, col);
      + if (is_mbyte) /* refresh multibyte */
      + {
      + ++screenp;
      + ++col;
      + ++text;
      + *screenp = *text;
      + *(screenp + Columns) = attr;
      + screen_char(screenp, row, col);
      + }
      + }
      + #else
      if (*screenp != *text || *(screenp + Columns) != attr ||
      exmode_active)
      {
      ***************
      *** 3224,3229 ****
      --- 3250,3256 ----
      *(screenp + Columns) = attr;
      screen_char(screenp, row, col);
      }
      + #endif
      ++screenp;
      ++col;
      ++text;
    Your message has been successfully submitted and would be delivered to recipients shortly.