From 5e632554d9bf7ea48783702ea59585639e1797bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 10 Mar 2016 20:53:47 +0100 Subject: view: clean up API functions related to primary cursor handling The currently visible display port is always adjusted in a way that the primary cursor is visible. --- view.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index 877b705..fb3a4a7 100644 --- a/view.c +++ b/view.c @@ -1116,10 +1116,20 @@ Cursor *view_cursors(View *view) { return view->cursors; } -Cursor *view_cursor(View *view) { +Cursor *view_cursors_primary_get(View *view) { return view->cursor; } +void view_cursors_primary_set(Cursor *c) { + if (!c) + return; + View *view = c->view; + view->cursor = c; + Filerange sel = view_cursors_selection_get(c); + view_cursors_to(c, view_cursors_pos(c)); + view_cursors_selection_set(c, &sel); +} + Cursor *view_cursors_prev(Cursor *c) { return c->prev; } @@ -1158,7 +1168,7 @@ void view_cursors_scroll_to(Cursor *c, size_t pos) { void view_cursors_to(Cursor *c, size_t pos) { View *view = c->view; - if (c->view->cursors == c) { + if (c->view->cursor == c) { c->mark = text_mark_set(view->text, pos); size_t max = text_size(view->text); -- cgit v1.2.3