vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 656aa60bded26e11813bb3acda9dc8c9cba04cc4 parent 2dff551501eaed48d1a3455ef8a8cb15989f5861 Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 15 Apr 2016 22:12:36 +0200 view: add view_cursors_col function Diffstat:
| M | view.c | | | 5 | +++++ |
| M | view.h | | | 2 | ++ |
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/view.c b/view.c @@ -1267,6 +1267,11 @@ size_t view_cursors_line(Cursor *c) { return text_lineno_by_pos(c->view->text, pos); } +size_t view_cursors_col(Cursor *c) { + size_t pos = view_cursors_pos(c); + return text_line_char_get(c->view->text, pos) + 1; +} + int view_cursors_cell_get(Cursor *c) { return c->line ? c->col : -1; } diff --git a/view.h b/view.h @@ -150,6 +150,8 @@ void view_cursors_primary_set(Cursor*); size_t view_cursors_pos(Cursor*); /* get 1-based line number of cursor location */ size_t view_cursors_line(Cursor*); +/* get 1-based column (number of graphemes on line) cursor postion */ +size_t view_cursors_col(Cursor*); /* get/set zero based index of cell on which cursor currently resides, * -1 if cursor is currently not visible */ int view_cursors_cell_get(Cursor*);