To: vim-dev@vim.org Subject: Patch 6.3a.014 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3a.014 Problem: Using multi-byte text and highlighting in a statusline causes gaps to appear. (Helmut Stiegler) Solution: Advance the column by text width instead of number of bytes. Add the vim_strnsize() function. Files: src/charset.c, src/proto/charset.pro, src/screen.c *** ../vim-6.3a.013/src/charset.c Fri May 7 10:59:38 2004 --- src/charset.c Wed May 12 16:54:57 2004 *************** *** 711,738 **** } /* ! * Return the number of characters string 's' will take on the screen, * counting TABs as two characters: "^I". */ int vim_strsize(s) char_u *s; { ! int len = 0; ! while (*s != NUL) { #ifdef FEAT_MBYTE if (has_mbyte) { ! len += ptr2cells(s); ! s += (*mb_ptr2len_check)(s); } else #endif ! len += byte2cells(*s++); } ! return len; } /* --- 711,753 ---- } /* ! * Return the number of characters string "s" will take on the screen, * counting TABs as two characters: "^I". */ int vim_strsize(s) char_u *s; { ! return vim_strnsize(s, (int)MAXCOL); ! } ! /* ! * Return the number of characters string "s[len]" will take on the screen, ! * counting TABs as two characters: "^I". ! */ ! int ! vim_strnsize(s, len) ! char_u *s; ! int len; ! { ! int size = 0; ! ! while (*s != NUL && --len >= 0) { #ifdef FEAT_MBYTE if (has_mbyte) { ! int l = (*mb_ptr2len_check)(s); ! ! size += ptr2cells(s); ! s += l; ! len -= l - 1; } else #endif ! size += byte2cells(*s++); } ! return size; } /* *** ../vim-6.3a.013/src/proto/charset.pro Fri May 7 10:59:36 2004 --- src/proto/charset.pro Wed May 12 17:26:46 2004 *************** *** 12,17 **** --- 12,18 ---- int char2cells __ARGS((int c)); int ptr2cells __ARGS((char_u *p)); int vim_strsize __ARGS((char_u *s)); + int vim_strnsize __ARGS((char_u *s, int len)); int chartabsize __ARGS((char_u *p, colnr_T col)); int linetabsize __ARGS((char_u *s)); int win_linetabsize __ARGS((win_T *wp, char_u *p, colnr_T len)); *** ../vim-6.3a.013/src/screen.c Fri May 7 10:59:38 2004 --- src/screen.c Wed May 12 16:36:12 2004 *************** *** 5341,5347 **** { len = (int)(hl[n].start - p); screen_puts_len(p, len, row, col, curattr); ! col += len; p = hl[n].start; if (hl[n].userhl == 0) --- 5341,5347 ---- { len = (int)(hl[n].start - p); screen_puts_len(p, len, row, col, curattr); ! col += vim_strnsize(p, len); p = hl[n].start; if (hl[n].userhl == 0) *** ../vim-6.3a.013/src/version.c Wed May 12 17:24:27 2004 --- src/version.c Wed May 12 17:25:45 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 14, /**/ -- hundred-and-one symptoms of being an internet addict: 10E. You start counting in hex. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///