aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-15 22:13:10 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-15 22:13:10 +0200
commitb9007ca88b5a57a1660c85c895a117ef15c04fb4 (patch)
treebb85d0aaf8608c86e965022ade8b2877e89253bc
parent0987fdd792984291041797032984872102961eb0 (diff)
downloadvis-b9007ca88b5a57a1660c85c895a117ef15c04fb4.tar.gz
vis-b9007ca88b5a57a1660c85c895a117ef15c04fb4.tar.xz
view: add view_cursors_place(cursor, line, col) function
-rw-r--r--view.c7
-rw-r--r--view.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/view.c b/view.c
index 9cc568c..875185e 100644
--- a/view.c
+++ b/view.c
@@ -1324,6 +1324,13 @@ void view_cursors_to(Cursor *c, size_t pos) {
cursor_to(c, pos);
}
+void view_cursors_place(Cursor *c, size_t line, size_t col) {
+ Text *txt = c->view->text;
+ size_t pos = text_pos_by_lineno(txt, line);
+ pos = text_line_char_set(txt, pos, col);
+ view_cursors_to(c, pos);
+}
+
void view_cursors_selection_start(Cursor *c) {
if (c->sel)
return;
diff --git a/view.h b/view.h
index 77fea1a..14f01d3 100644
--- a/view.h
+++ b/view.h
@@ -159,6 +159,7 @@ int view_cursors_cell_set(Cursor*, int cell);
/* place cursor at `pos' which should be in the interval [0, text-size] */
void view_cursors_to(Cursor*, size_t pos);
void view_cursors_scroll_to(Cursor*, size_t pos);
+void view_cursors_place(Cursor*, size_t line, size_t col);
/* get register associated with this register */
Register *view_cursors_register(Cursor*);
/* start selected area at current cursor position. further cursor movements