To: vim-dev@vim.org Subject: Patch 6.0.151 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.151 Problem: Redrawing the status line and ruler can be wrong when it contains multi-byte characters. Solution: Use character width and byte length correctly. (Yasuhiro Matsumoto) Files: src/screen.c *** ../vim60.150/src/screen.c Thu Jan 17 16:30:27 2002 --- src/screen.c Thu Jan 24 12:23:08 2002 *************** *** 4734,4740 **** { int clen = 0, i; - p[len] = NUL; /* Count total number of display cells. */ for (i = 0; p[i] != NUL; i += (*mb_ptr2len_check)(p + i)) clen += (*mb_ptr2cells)(p + i); --- 4734,4739 ---- *************** *** 4747,4754 **** { p = p + i - 1; *p = '<'; - len = len - i + 1; } } else --- 4746,4753 ---- { p = p + i - 1; *p = '<'; } + len = clen; } else *************** *** 7799,7805 **** */ i = (int)STRLEN(buffer); get_rel_pos(wp, buffer + i + 1); ! o = (int)STRLEN(buffer + i + 1); #ifdef FEAT_WINDOWS if (wp->w_status_height == 0) /* can't use last char of screen */ #endif --- 7798,7804 ---- */ i = (int)STRLEN(buffer); get_rel_pos(wp, buffer + i + 1); ! o = vim_strsize(buffer + i + 1); #ifdef FEAT_WINDOWS if (wp->w_status_height == 0) /* can't use last char of screen */ #endif *************** *** 7820,7825 **** --- 7819,7840 ---- get_rel_pos(wp, buffer + i); } /* Truncate at window boundary. */ + #ifdef FEAT_MBYTE + if (has_mbyte) + { + o = 0; + for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len_check)(buffer + i)) + { + o += (*mb_ptr2cells)(buffer + i); + if (this_ru_col + o > WITH_WIDTH(width)) + { + buffer[i] = NUL; + break; + } + } + } + else + #endif if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width)) buffer[WITH_WIDTH(width) - this_ru_col] = NUL; *** ../vim60.150/src/version.c Thu Jan 24 11:27:35 2002 --- src/version.c Thu Jan 24 13:45:14 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 151, /**/ -- Q: What is a patch 22? A: A patch you need to include to make it possible to include patches. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///