From f958ace51f5ac9d4528cfadfce57bcab34d87498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 15 Apr 2016 22:11:39 +0200 Subject: view: add view_cursors_line function --- view.c | 5 +++++ view.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/view.c b/view.c index f2a0c90..d79e42b 100644 --- a/view.c +++ b/view.c @@ -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; } diff --git a/view.h b/view.h index fadaaba..2d78924 100644 --- a/view.h +++ b/view.h @@ -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*); -- cgit v1.2.3