From 4af9fe66851a42c20c550f2c59aa64d7a327c9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 30 Jun 2015 11:37:00 +0200 Subject: Perform character prev/next movements based on Text not View While it is slower, it allows to move to characters which are currently not visible. This will be handy when experimenting with multiple cursors. --- view.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index 85e5c41..d49c417 100644 --- a/view.c +++ b/view.c @@ -519,46 +519,6 @@ View *view_new(Text *text, ViewEvent *events) { void view_ui(View *view, UiWin* ui) { view->ui = ui; } -size_t view_char_prev(View *view) { - Cursor *cursor = &view->cursor; - Line *line = cursor->line; - - do { - if (cursor->col == 0) { - if (!line->prev) - return cursor->pos; - cursor->line = line = line->prev; - cursor->col = MIN(line->width, view->width - 1); - cursor->row--; - } else { - cursor->col--; - } - } while (line->cells[cursor->col].len == 0); - - cursor->pos -= line->cells[cursor->col].len; - return view_cursor_update(view); -} - -size_t view_char_next(View *view) { - Cursor *cursor = &view->cursor; - Line *line = cursor->line; - - do { - cursor->pos += line->cells[cursor->col].len; - if ((line->width == view->width && cursor->col == view->width - 1) || - cursor->col == line->width) { - if (!line->next) - return cursor->pos; - cursor->line = line = line->next; - cursor->row++; - cursor->col = 0; - } else { - cursor->col++; - } - } while (line->cells[cursor->col].len == 0); - - return view_cursor_update(view); -} static size_t view_cursor_set(View *view, Line *line, int col) { int row = 0; -- cgit v1.2.3