diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 22:11:39 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 22:11:39 +0200 |
| commit | f958ace51f5ac9d4528cfadfce57bcab34d87498 (patch) | |
| tree | 6e3466dedd8cc227b8faa4a54574216c664ade38 | |
| parent | 341b490b5981de164958eaf83fdf1ade9f85c764 (diff) | |
| download | vis-f958ace51f5ac9d4528cfadfce57bcab34d87498.tar.gz vis-f958ace51f5ac9d4528cfadfce57bcab34d87498.tar.xz | |
view: add view_cursors_line function
| -rw-r--r-- | view.c | 5 | ||||
| -rw-r--r-- | view.h | 2 |
2 files changed, 7 insertions, 0 deletions
@@ -1262,6 +1262,11 @@ size_t view_cursors_pos(Cursor *c) { return text_mark_get(c->view->text, c->mark); } +size_t view_cursors_line(Cursor *c) { + size_t pos = view_cursors_pos(c); + return text_lineno_by_pos(c->view->text, pos); +} + int view_cursors_cell_get(Cursor *c) { return c->line ? c->col : -1; } @@ -148,6 +148,8 @@ Cursor *view_cursors_primary_get(View*); void view_cursors_primary_set(Cursor*); /* get current position of cursor in bytes from the start of the file */ size_t view_cursors_pos(Cursor*); +/* get 1-based line number of cursor location */ +size_t view_cursors_line(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*); |
