Skip to content

Commit

Permalink
view: remove view_cursors_multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Jun 15, 2017
1 parent 2fa1bea commit 318837f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
12 changes: 6 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ static const char *cursors_align_indent(Vis *vis, const char *keys, const Arg *a

static const char *cursors_clear(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
if (view_cursors_multiple(view))
if (view_cursors_count(view) > 1)
view_cursors_clear(view);
else
view_cursors_selection_clear(view_cursors_primary_get(view));
Expand Down Expand Up @@ -1422,7 +1422,7 @@ static const char *cursors_remove_column(Vis *vis, const char *keys, const Arg *
int column = vis_count_get_default(vis, arg->i) - 1;
if (column >= max)
column = max - 1;
if (!view_cursors_multiple(view)) {
if (view_cursors_count(view) == 1) {
vis_mode_switch(vis, VIS_MODE_NORMAL);
return keys;
}
Expand All @@ -1442,7 +1442,7 @@ static const char *cursors_remove_column_except(Vis *vis, const char *keys, cons
int column = vis_count_get_default(vis, arg->i) - 1;
if (column >= max)
column = max - 1;
if (!view_cursors_multiple(view)) {
if (view_cursors_count(view) == 1) {
vis_redraw(vis);
return keys;
}
Expand All @@ -1463,7 +1463,7 @@ static const char *cursors_remove_column_except(Vis *vis, const char *keys, cons

static const char *cursors_navigate(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
if (!view_cursors_multiple(view))
if (view_cursors_count(view) == 1)
return wscroll(vis, keys, arg);
Cursor *c = view_cursors_primary_get(view);
VisCountIterator it = vis_count_iterator_get(vis, 1);
Expand Down Expand Up @@ -1710,7 +1710,7 @@ static const char *undo(Vis *vis, const char *keys, const Arg *arg) {
size_t pos = text_undo(vis_text(vis));
if (pos != EPOS) {
View *view = vis_view(vis);
if (!view_cursors_multiple(view))
if (view_cursors_count(view) == 1)
view_cursor_to(view, pos);
/* redraw all windows in case some display the same file */
vis_draw(vis);
Expand All @@ -1722,7 +1722,7 @@ static const char *redo(Vis *vis, const char *keys, const Arg *arg) {
size_t pos = text_redo(vis_text(vis));
if (pos != EPOS) {
View *view = vis_view(vis);
if (!view_cursors_multiple(view))
if (view_cursors_count(view) == 1)
view_cursor_to(view, pos);
/* redraw all windows in case some display the same file */
vis_draw(vis);
Expand Down
2 changes: 1 addition & 1 deletion sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
bool ret = true;
View *view = win->view;
Text *txt = win->file->text;
bool multiple_cursors = view_cursors_multiple(view);
bool multiple_cursors = view_cursors_count(view) > 1;
Cursor *primary = view_cursors_primary_get(view);

if (vis->mode->visual)
Expand Down
4 changes: 0 additions & 4 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,10 +998,6 @@ Cursor *view_cursors_column_next(Cursor *c, int column) {
return cursors_column_next(c->view, c, column);
}

bool view_cursors_multiple(View *view) {
return view->cursors && view->cursors->next;
}

static void view_cursors_free(Cursor *c) {
if (!c)
return;
Expand Down
2 changes: 0 additions & 2 deletions view.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ bool view_selection_anchored(Cursor*);
* @defgroup view_props
* @{
*/
/** TODO remove */
bool view_cursors_multiple(View*);
/** Get position of selection cursor. */
size_t view_cursors_pos(Cursor*);
/** Get 1-based line number of selection cursor. */
Expand Down
2 changes: 1 addition & 1 deletion vis-prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static const char *prompt_enter(Vis *vis, const char *keys, const Arg *arg) {

static const char *prompt_esc(Vis *vis, const char *keys, const Arg *arg) {
Win *prompt = vis->win;
if (view_cursors_multiple(prompt->view)) {
if (view_cursors_count(prompt->view) > 1) {
view_cursors_clear(prompt->view);
} else {
prompt_restore(prompt);
Expand Down
6 changes: 3 additions & 3 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static void window_draw_cursorline(Win *win) {
return;
if (vis->mode->visual || vis->win != win)
return;
if (view_cursors_multiple(view))
if (view_cursors_count(view) > 1)
return;

int width = view_width_get(view);
Expand Down Expand Up @@ -398,7 +398,7 @@ static void window_draw_cursor(Win *win, Cursor *cur, CellStyle *style, CellStyl
static void window_draw_cursors(Win *win) {
View *view = win->view;
Filerange viewport = view_viewport_get(view);
bool multiple_cursors = view_cursors_multiple(view);
bool multiple_cursors = view_cursors_count(view) > 1;
Cursor *cursor = view_cursors_primary_get(view);
CellStyle style_cursor = win->ui->style_get(win->ui, UI_STYLE_CURSOR);
CellStyle style_cursor_primary = win->ui->style_get(win->ui, UI_STYLE_CURSOR_PRIMARY);
Expand Down Expand Up @@ -830,7 +830,7 @@ void vis_do(Vis *vis) {
if (a->op == &vis_operators[VIS_OP_MODESWITCH])
count = 1; /* count should apply to inserted text not motion */
bool repeatable = a->op && !vis->macro_operator && !vis->win->parent;
bool multiple_cursors = view_cursors_multiple(view);
bool multiple_cursors = view_cursors_count(view) > 1;
bool linewise = !(a->type & CHARWISE) && (
a->type & LINEWISE || (a->movement && a->movement->type & LINEWISE) ||
vis->mode == &vis_modes[VIS_MODE_VISUAL_LINE]);
Expand Down

0 comments on commit 318837f

Please sign in to comment.