diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-06-12 18:43:03 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-06-15 15:51:43 +0200 |
| commit | 0001a83bb7f7b30840df2f2ec321e2c2d9507053 (patch) | |
| tree | 3011b4b21654ad4195c45d773b9a5e432e573a09 | |
| parent | fcb47fc938ac36e14565e60b9138c59ea9c67658 (diff) | |
| download | vis-0001a83bb7f7b30840df2f2ec321e2c2d9507053.tar.gz vis-0001a83bb7f7b30840df2f2ec321e2c2d9507053.tar.xz | |
view: rename view_cursors
| -rw-r--r-- | main.c | 26 | ||||
| -rw-r--r-- | sam.c | 12 | ||||
| -rw-r--r-- | view.c | 2 | ||||
| -rw-r--r-- | view.h | 2 | ||||
| -rw-r--r-- | vis-lua.c | 4 | ||||
| -rw-r--r-- | vis-modes.c | 6 | ||||
| -rw-r--r-- | vis.c | 14 |
7 files changed, 33 insertions, 33 deletions
@@ -1251,10 +1251,10 @@ static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) { cursor = view_selections_primary_get(view); break; case INT_MIN: - cursor = view_cursors(view); + cursor = view_selections(view); break; case INT_MAX: - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) cursor = c; break; default: @@ -1285,12 +1285,12 @@ static const char *cursors_align(Vis *vis, const char *keys, const Arg *arg) { View *view = vis_view(vis); Text *txt = vis_text(vis); int mincol = INT_MAX; - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) { int col = view_cursors_cell_get(c); if (col >= 0 && col < mincol) mincol = col; } - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) { if (view_cursors_cell_set(c, mincol) == -1) { size_t pos = view_cursors_pos(c); size_t col = text_line_width_set(txt, pos, mincol); @@ -1355,7 +1355,7 @@ static const char *cursors_clear(Vis *vis, const char *keys, const Arg *arg) { static const char *cursors_select(Vis *vis, const char *keys, const Arg *arg) { Text *txt = vis_text(vis); View *view = vis_view(vis); - for (Cursor *cursor = view_cursors(view); cursor; cursor = view_selections_next(cursor)) { + for (Cursor *cursor = view_selections(view); cursor; cursor = view_selections_next(cursor)) { Filerange word = text_object_word(txt, view_cursors_pos(cursor)); if (text_range_valid(&word)) view_selections_set(cursor, &word); @@ -1385,7 +1385,7 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar } } - sel = view_selections_get(view_cursors(view)); + sel = view_selections_get(view_selections(view)); word = text_object_word_find_prev(txt, sel.start, buf); if (!text_range_valid(&word)) goto out; @@ -1447,7 +1447,7 @@ static const char *cursors_remove_column_except(Vis *vis, const char *keys, cons return keys; } - Cursor *cur = view_cursors(view); + Cursor *cur = view_selections(view); Cursor *col = view_cursors_column(view, column); for (Cursor *next; cur; cur = next) { next = view_selections_next(cur); @@ -1471,11 +1471,11 @@ static const char *cursors_navigate(Vis *vis, const char *keys, const Arg *arg) if (arg->i > 0) { c = view_selections_next(c); if (!c) - c = view_cursors(view); + c = view_selections(view); } else { c = view_selections_prev(c); if (!c) { - c = view_cursors(view); + c = view_selections(view); for (Cursor *n = c; n; n = view_selections_next(n)) c = n; } @@ -1505,7 +1505,7 @@ static const char *selections_rotate(Vis *vis, const char *keys, const Arg *arg) return keys; size_t line = 0; - for (Cursor *c = view_cursors(view), *next; c; c = next) { + for (Cursor *c = view_selections(view), *next; c; c = next) { next = view_selections_next(c); size_t line_next = 0; @@ -1556,7 +1556,7 @@ static const char *selections_rotate(Vis *vis, const char *keys, const Arg *arg) static const char *selections_trim(Vis *vis, const char *keys, const Arg *arg) { Text *txt = vis_text(vis); View *view = vis_view(vis); - for (Cursor *c = view_cursors(view), *next; c; c = next) { + for (Cursor *c = view_selections(view), *next; c; c = next) { next = view_selections_next(c); Filerange sel = view_selections_get(c); if (!text_range_valid(&sel)) @@ -1660,7 +1660,7 @@ static const char *textobj(Vis *vis, const char *keys, const Arg *arg) { } static const char *selection_end(Vis *vis, const char *keys, const Arg *arg) { - for (Cursor *c = view_cursors(vis_view(vis)); c; c = view_selections_next(c)) + for (Cursor *c = view_selections(vis_view(vis)); c; c = view_selections_next(c)) view_selections_flip(c); return keys; } @@ -1668,7 +1668,7 @@ static const char *selection_end(Vis *vis, const char *keys, const Arg *arg) { static const char *selection_restore(Vis *vis, const char *keys, const Arg *arg) { Text *txt = vis_text(vis); View *view = vis_view(vis); - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) view_selections_restore(c); Filerange sel = view_selection_get(view); if (text_range_is_linewise(txt, &sel)) @@ -1236,9 +1236,9 @@ enum SamError sam_cmd(Vis *vis, const char *s) { if (vis->win) { if (primary_pos != EPOS && view_selection_disposed(vis->win->view)) view_cursor_to(vis->win->view, primary_pos); - view_selections_primary_set(view_cursors(vis->win->view)); + view_selections_primary_set(view_selections(vis->win->view)); bool completed = true; - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) { if (view_selections_anchored(c)) { completed = false; break; @@ -1443,7 +1443,7 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur if (vis->mode->visual) count_init(cmd->cmd, view_selections_count(view)+1); - for (Cursor *c = view_cursors(view), *next; c && ret; c = next) { + for (Cursor *c = view_selections(view), *next; c && ret; c = next) { next = view_selections_next(c); size_t pos = view_cursors_pos(c); if (vis->mode->visual) { @@ -1486,7 +1486,7 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur } if (vis->win && vis->win->view == view && primary != view_selections_primary_get(view)) - view_selections_primary_set(view_cursors(view)); + view_selections_primary_set(view_selections(view)); return ret; } @@ -1562,7 +1562,7 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs bool visual = vis->mode->visual; - for (Cursor *c = view_cursors(win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(win->view); c; c = view_selections_next(c)) { Filerange range = visual ? view_selections_get(c) : *r; ssize_t written = text_write_range(text, &range, file->fd); if (written == -1 || (size_t)written != text_range_size(&range)) { @@ -1614,7 +1614,7 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs bool failure = false; bool visual = vis->mode->visual; - for (Cursor *c = view_cursors(win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(win->view); c; c = view_selections_next(c)) { Filerange range = visual ? view_selections_get(c) : *r; ssize_t written = text_save_write_range(ctx, &range); failure = (written == -1 || (size_t)written != text_range_size(&range)); @@ -1047,7 +1047,7 @@ Cursor *view_selection_disposed(View *view) { return c; } -Cursor *view_cursors(View *view) { +Cursor *view_selections(View *view) { view->cursor_generation++; return view->cursors; } @@ -146,7 +146,7 @@ void view_selections_dispose_all(View*); Cursor *view_selections_primary_get(View*); void view_selections_primary_set(Cursor*); /** Get first selection. */ -Cursor *view_cursors(View*); +Cursor *view_selections(View*); /** Get immediate predecessor of selection. */ Cursor *view_selections_prev(Cursor*); /** Get immediate successor of selection. */ @@ -1607,7 +1607,7 @@ static int window_cursors_iterator_next(lua_State *L) { static int window_cursors_iterator(lua_State *L) { Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW); Cursor **handle = lua_newuserdata(L, sizeof *handle); - *handle = view_cursors(win->view); + *handle = view_selections(win->view); lua_pushcclosure(L, window_cursors_iterator_next, 1); return 1; } @@ -1730,7 +1730,7 @@ static int window_cursors_index(lua_State *L) { size_t count = view_selections_count(view); if (index == 0 || index > count) goto err; - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) { if (!--index) { obj_lightref_new(L, c, VIS_LUA_TYPE_CURSOR); return 1; diff --git a/vis-modes.c b/vis-modes.c index d9a5091..c396b4a 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -145,7 +145,7 @@ static void vis_mode_normal_enter(Vis *vis, Mode *old) { return; if (vis->autoindent && strcmp(vis->key_prev, "<Enter>") == 0) { Text *txt = vis->win->file->text; - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) { size_t pos = view_cursors_pos(c); size_t start = text_line_start(txt, pos); size_t end = text_line_end(txt, pos); @@ -185,14 +185,14 @@ static void vis_mode_operator_input(Vis *vis, const char *str, size_t len) { static void vis_mode_visual_enter(Vis *vis, Mode *old) { if (!old->visual) { - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) view_selections_anchor(c); } } static void vis_mode_visual_line_enter(Vis *vis, Mode *old) { if (!old->visual) { - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) view_selections_anchor(c); } if (!vis->action.op) @@ -247,11 +247,11 @@ void vis_window_status(Win *win, const char *status) { void window_selection_save(Win *win) { Vis *vis = win->vis; File *file = win->file; - Filerange sel = view_selections_get(view_cursors(win->view)); + Filerange sel = view_selections_get(view_selections(win->view)); file->marks[VIS_MARK_SELECTION_START] = text_mark_set(file->text, sel.start); file->marks[VIS_MARK_SELECTION_END] = text_mark_set(file->text, sel.end); if (!vis->action.op) { - for (Selection *s = view_cursors(win->view); s; s = view_selections_next(s)) + for (Selection *s = view_selections(win->view); s; s = view_selections_next(s)) view_selections_save(s); } } @@ -754,7 +754,7 @@ void vis_insert(Vis *vis, size_t pos, const char *data, size_t len) { } void vis_insert_key(Vis *vis, const char *data, size_t len) { - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) { size_t pos = view_cursors_pos(c); vis_insert(vis, pos, data, len); view_cursors_scroll_to(c, pos + len); @@ -773,7 +773,7 @@ void vis_replace(Vis *vis, size_t pos, const char *data, size_t len) { } void vis_replace_key(Vis *vis, const char *data, size_t len) { - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) { size_t pos = view_cursors_pos(c); vis_replace(vis, pos, data, len); view_cursors_scroll_to(c, pos + len); @@ -844,7 +844,7 @@ void vis_do(Vis *vis) { if (a->op == &vis_operators[VIS_OP_PUT_AFTER] && multiple_cursors && vis_register_count(vis, reg) == 1) reg_slot = 0; - for (Cursor *cursor = view_cursors(view), *next; cursor; cursor = next) { + for (Cursor *cursor = view_selections(view), *next; cursor; cursor = next) { if (vis->interrupted) break; @@ -1578,7 +1578,7 @@ void vis_insert_tab(Vis *vis) { } char spaces[9]; int tabwidth = MIN(vis->tabwidth, LENGTH(spaces) - 1); - for (Cursor *c = view_cursors(vis->win->view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(vis->win->view); c; c = view_selections_next(c)) { size_t pos = view_cursors_pos(c); int width = text_line_width_get(vis->win->file->text, pos); int count = tabwidth - (width % tabwidth); @@ -1633,7 +1633,7 @@ void vis_insert_nl(Vis *vis) { Win *win = vis->win; View *view = win->view; Text *txt = win->file->text; - for (Cursor *c = view_cursors(view); c; c = view_selections_next(c)) { + for (Cursor *c = view_selections(view); c; c = view_selections_next(c)) { size_t pos = view_cursors_pos(c); size_t newpos = vis_text_insert_nl(vis, txt, pos); /* This is a bit of a hack to fix cursor positioning when |
