vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 0cbdf9bf2a5d7d0efe73c3bec38708f73980ecbd parent 27192e0a2b5ff17ca34ad7cd8860584bc5f329b8 Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 13 Jan 2016 14:22:36 +0100 view: introduce view_selection_get It returns the range covered by the selection of the primary cursor. Diffstat:
| M | view.c | | | 4 | ++++ |
| M | view.h | | | 2 | ++ |
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/view.c b/view.c @@ -1301,6 +1301,10 @@ Selection *view_selections_next(Selection *s) { return s->next; } +Filerange view_selection_get(View *view) { + return view_selections_get(view->cursor->sel); +} + Filerange view_selections_get(Selection *s) { if (!s) return text_range_empty(); diff --git a/view.h b/view.h @@ -109,6 +109,8 @@ int view_colorcolumn_get(View*); CursorPos view_cursor_getpos(View*); /* get main cursor position in bytes from start of the file */ size_t view_cursor_get(View*); +/* get selection associated with primary cursor */ +Filerange view_selection_get(View*); /* moves window viewport in direction until pos is visible. should only be * used for short distances between current cursor position and destination */ void view_scroll_to(View*, size_t pos);