From 8965cd21386683cae680ba7de4b6a6ee6687e17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 27 Mar 2016 16:14:48 +0200 Subject: view: change cursor creation API to take an initial position --- view.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index b33263e..0d625f9 100644 --- a/view.c +++ b/view.c @@ -737,7 +737,7 @@ View *view_new(Text *text, lua_State *lua) { View *view = calloc(1, sizeof(View)); if (!view) return NULL; - if (!view_cursors_new(view)) { + if (!view_cursors_new(view, EPOS)) { view_free(view); return NULL; } @@ -1051,17 +1051,18 @@ size_t view_screenline_goto(View *view, int n) { return pos; } -Cursor *view_cursors_new(View *view) { +Cursor *view_cursors_new(View *view, size_t pos) { Cursor *c = calloc(1, sizeof(*c)); if (!c) return NULL; - c->view = view; c->next = view->cursors; if (view->cursors) view->cursors->prev = c; view->cursors = c; view->cursor = c; + if (pos != EPOS) + view_cursors_to(c, pos); return c; } -- cgit v1.2.3