diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-07-17 12:47:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-07-17 12:47:16 +0200 |
commit | f91787cb9adc47cadea5d17b08d075a15a2e00f4 (patch) | |
tree | c88be44c3b47c44d14e815b03d742d71f2102b32 /src/normal.c | |
parent | 11505dcd2b4bf7ab892549f4ce29c0dbc53aac8b (diff) |
In Visual mode with 'showcmd' display the number of bytes and characters.
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/normal.c b/src/normal.c index 3321b3ff83..727ecd0590 100644 --- 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; } |