aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-03-10 20:53:47 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-03-10 22:36:54 +0100
commit5e632554d9bf7ea48783702ea59585639e1797bf (patch)
tree5691f504dd0c9974d1579469094a9c1fc2b24967 /view.c
parent5f8760a614e11dc2f665ed4a23309875a6af61df (diff)
downloadvis-5e632554d9bf7ea48783702ea59585639e1797bf.tar.gz
vis-5e632554d9bf7ea48783702ea59585639e1797bf.tar.xz
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.
Diffstat (limited to 'view.c')
-rw-r--r--view.c14
1 files changed, 12 insertions, 2 deletions
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);