Mercurial > vim
diff src/normal.c @ 2324:0a258a67051d vim73
In Visual mode with 'showcmd' display the number of bytes and characters.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 17 Jul 2010 12:47:16 +0200 |
parents | 2209060c340d |
children | 6e563e1c8033 |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -3756,9 +3756,40 @@ clear_showcmd() else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) sprintf((char *)showcmd_buf, "%ld", lines); else - sprintf((char *)showcmd_buf, "%ld", (long)(cursor_bot - ? curwin->w_cursor.col - VIsual.col - : VIsual.col - curwin->w_cursor.col) + (*p_sel != 'e')); + { + char_u *s, *e; + int l; + int bytes = 0; + int chars = 0; + + if (cursor_bot) + { + s = ml_get_pos(&VIsual); + e = ml_get_cursor(); + } + else + { + s = ml_get_cursor(); + e = ml_get_pos(&VIsual); + } + while ((*p_sel != 'e') ? s <= e : s < e) + { + l = (*mb_ptr2len)(s); + if (l == 0) + { + ++bytes; + ++chars; + break; /* end of line */ + } + bytes += l; + ++chars; + s += l; + } + if (bytes == chars) + sprintf((char *)showcmd_buf, "%d", chars); + else + sprintf((char *)showcmd_buf, "%d-%d", chars, bytes); + } showcmd_buf[SHOWCMD_COLS] = NUL; /* truncate */ showcmd_visual = TRUE; }