diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-07 14:33:49 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-08 10:44:22 +0200 |
| commit | a2abb7d9c8df32f65f907452f292784d569e8e88 (patch) | |
| tree | 20ca619bd560c6f53f6974d3e1efb41b5e967090 /ui-curses.c | |
| parent | b9b6b8fb15f1a8986aa5195fbca0d89155ad768e (diff) | |
| download | vis-a2abb7d9c8df32f65f907452f292784d569e8e88.tar.gz vis-a2abb7d9c8df32f65f907452f292784d569e8e88.tar.xz | |
vis: indicate primary cursor number in status bar
If there exist multiple cursors, [n/m] is added to the status bar.
Meaning the n-th cursor out of the existing m cursors is currently
the primary one.
Diffstat (limited to 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ui-curses.c b/ui-curses.c index f6d4a43..d335995 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -641,15 +641,21 @@ static void ui_window_draw_status(UiWin *w) { text_modified(vis_file_text(win->file)) ? "[+]" : "", vis_macro_recording(vis) ? "recording": ""); + char buf[4*32] = "", *msg = buf; + int cursor_count = view_cursors_count(win->view); + if (cursor_count > 1) { + Cursor *c = view_cursors_primary_get(win->view); + int cursor_number = view_cursors_number(c) + 1; + msg += sprintf(msg, "[%d/%d] ", cursor_number, cursor_count); + } + if (!(win->options & UI_OPTION_LARGE_FILE)) { CursorPos pos = view_cursor_getpos(win->view); - char buf[win->width + 1]; - int len = snprintf(buf, win->width, "%zd, %zd", pos.line, pos.col); - if (len > 0) { - buf[len] = '\0'; - mvwaddstr(win->winstatus, 0, win->width - len - 1, buf); - } + msg += sprintf(msg, "%zd, %zd", pos.line, pos.col); } + + if (buf[0]) + mvwaddstr(win->winstatus, 0, win->width - (msg - buf) - 1, buf); } static void ui_window_draw(UiWin *w) { |
