Skip to content

Commit

Permalink
view: rename view_cursors_dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Jun 15, 2017
1 parent e7717eb commit dc9f1cd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,13 +1405,13 @@ static const char *cursors_select_skip(Vis *vis, const char *keys, const Arg *ar
Cursor *cursor = view_cursors_primary_get(view);
keys = cursors_select_next(vis, keys, arg);
if (cursor != view_cursors_primary_get(view))
view_cursors_dispose(cursor);
view_selections_dispose(cursor);
return keys;
}

static const char *cursors_remove(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
view_cursors_dispose(view_cursors_primary_get(view));
view_selections_dispose(view_cursors_primary_get(view));
view_cursor_to(view, view_cursor_get(view));
return keys;
}
Expand All @@ -1429,7 +1429,7 @@ static const char *cursors_remove_column(Vis *vis, const char *keys, const Arg *

for (Cursor *c = view_cursors_column(view, column), *next; c; c = next) {
next = view_cursors_column_next(c, column);
view_cursors_dispose(c);
view_selections_dispose(c);
}

vis_count_set(vis, VIS_COUNT_UNKNOWN);
Expand All @@ -1454,7 +1454,7 @@ static const char *cursors_remove_column_except(Vis *vis, const char *keys, cons
if (cur == col)
col = view_cursors_column_next(col, column);
else
view_cursors_dispose(cur);
view_selections_dispose(cur);
}

vis_count_set(vis, VIS_COUNT_UNKNOWN);
Expand Down Expand Up @@ -1567,7 +1567,7 @@ static const char *selections_trim(Vis *vis, const char *keys, const Arg *arg) {
&& isspace((unsigned char)b); sel.start++);
if (sel.start < sel.end) {
view_cursors_selection_set(c, &sel);
} else if (!view_cursors_dispose(c)) {
} else if (!view_selections_dispose(c)) {
vis_mode_switch(vis, VIS_MODE_NORMAL);
}
}
Expand Down
8 changes: 4 additions & 4 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ static bool sam_execute(Vis *vis, Win *win, Command *cmd, Cursor *cur, Filerange
{
for (Command *c = cmd->cmd; c && ret; c = c->next)
ret &= sam_execute(vis, win, c, NULL, range);
view_cursors_dispose_force(cur);
view_selections_dispose_force(cur);
break;
}
default:
Expand Down Expand Up @@ -1200,7 +1200,7 @@ enum SamError sam_cmd(Vis *vis, const char *s) {
delta -= text_range_size(&c->range);
if (c->cursor && c->type == TRANSCRIPT_DELETE) {
if (visual)
view_cursors_dispose_force(c->cursor);
view_selections_dispose_force(c->cursor);
else
view_cursors_to(c->cursor, c->range.start);
}
Expand Down Expand Up @@ -1335,7 +1335,7 @@ static bool cmd_guard(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs
text_range_size(range), cmd->regex, 0, NULL, 0);
if ((count_evaluate(cmd) && match) ^ (argv[0][0] == 'v'))
return sam_execute(vis, win, cmd->cmd, cur, range);
view_cursors_dispose_force(cur);
view_selections_dispose_force(cur);
return true;
}

Expand Down Expand Up @@ -1416,7 +1416,7 @@ static int extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor
}

if (!simulate)
view_cursors_dispose_force(cur);
view_selections_dispose_force(cur);
return simulate ? count : ret;
}

Expand Down
8 changes: 4 additions & 4 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static Cursor *cursors_new(View *view, size_t pos, bool force) {
}
view->cursor_latest = c;
view->cursor_count++;
view_cursors_dispose(view->cursor_dead);
view_selections_dispose(view->cursor_dead);
view_cursors_to(c, pos);
return c;
err:
Expand Down Expand Up @@ -1019,7 +1019,7 @@ static void view_cursors_free(Cursor *c) {
free(c);
}

bool view_cursors_dispose(Cursor *c) {
bool view_selections_dispose(Cursor *c) {
if (!c)
return true;
View *view = c->view;
Expand All @@ -1030,8 +1030,8 @@ bool view_cursors_dispose(Cursor *c) {
return true;
}

bool view_cursors_dispose_force(Cursor *c) {
if (view_cursors_dispose(c))
bool view_selections_dispose_force(Cursor *c) {
if (view_selections_dispose(c))
return true;
View *view = c->view;
if (view->cursor_dead)
Expand Down
4 changes: 2 additions & 2 deletions view.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ Cursor *view_selections_new_force(View*, size_t pos);
* .. warning:: Not applicaple for the last existing selection.
* @endrst
*/
bool view_cursors_dispose(Cursor*);
bool view_selections_dispose(Cursor*);
/**
* Forcefully dispose an existing selection.
*
* If called for the last existing selection, it will be reduced and
* marked for destruction. As soon as a new selection is created this one
* will be disposed.
*/
bool view_cursors_dispose_force(Cursor*);
bool view_selections_dispose_force(Cursor*);
/**
* Query state of primary selection.
*
Expand Down
4 changes: 2 additions & 2 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void vis_do(Vis *vis) {

size_t pos = view_cursors_pos(cursor);
if (pos == EPOS) {
if (!view_cursors_dispose(cursor))
if (!view_selections_dispose(cursor))
view_cursors_to(cursor, 0);
continue;
}
Expand Down Expand Up @@ -977,7 +977,7 @@ void vis_do(Vis *vis) {
if (a->op) {
size_t pos = a->op->func(vis, txt, &c);
if (pos == EPOS) {
view_cursors_dispose(cursor);
view_selections_dispose(cursor);
} else if (pos <= text_size(txt)) {
if (vis->mode->visual)
view_cursors_selection_save(cursor);
Expand Down

0 comments on commit dc9f1cd

Please sign in to comment.