Skip to content

Commit

Permalink
view: rename view_cursors_primary_{get,set}
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Jun 15, 2017
1 parent 948efb8 commit a9c3e2c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
22 changes: 11 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) {
switch (arg->i) {
case -1:
case +1:
cursor = view_cursors_primary_get(view);
cursor = view_selections_primary_get(view);
break;
case INT_MIN:
cursor = view_cursors(view);
Expand All @@ -1275,7 +1275,7 @@ static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) {
cursor_new = view_cursors_next(cursor);
}
if (cursor_new)
view_cursors_primary_set(cursor_new);
view_selections_primary_set(cursor_new);
}
vis_count_set(vis, VIS_COUNT_UNKNOWN);
return keys;
Expand Down Expand Up @@ -1348,7 +1348,7 @@ static const char *cursors_clear(Vis *vis, const char *keys, const Arg *arg) {
if (view_cursors_count(view) > 1)
view_selections_dispose_all(view);
else
view_cursors_selection_clear(view_cursors_primary_get(view));
view_cursors_selection_clear(view_selections_primary_get(view));
return keys;
}

Expand All @@ -1367,7 +1367,7 @@ static const char *cursors_select(Vis *vis, const char *keys, const Arg *arg) {
static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *arg) {
Text *txt = vis_text(vis);
View *view = vis_view(vis);
Cursor *cursor = view_cursors_primary_get(view);
Cursor *cursor = view_selections_primary_get(view);
Filerange sel = view_cursors_selection_get(cursor);
if (!text_range_valid(&sel))
return keys;
Expand All @@ -1380,7 +1380,7 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar
size_t pos = text_char_prev(txt, word.end);
if ((cursor = view_selections_new(view, pos))) {
view_cursors_selection_set(cursor, &word);
view_cursors_primary_set(cursor);
view_selections_primary_set(cursor);
goto out;
}
}
Expand All @@ -1392,7 +1392,7 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar
size_t pos = text_char_prev(txt, word.end);
if ((cursor = view_selections_new(view, pos))) {
view_cursors_selection_set(cursor, &word);
view_cursors_primary_set(cursor);
view_selections_primary_set(cursor);
}

out:
Expand All @@ -1402,16 +1402,16 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar

static const char *cursors_select_skip(Vis *vis, const char *keys, const Arg *arg) {
View *view = vis_view(vis);
Cursor *cursor = view_cursors_primary_get(view);
Cursor *cursor = view_selections_primary_get(view);
keys = cursors_select_next(vis, keys, arg);
if (cursor != view_cursors_primary_get(view))
if (cursor != view_selections_primary_get(view))
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_selections_dispose(view_cursors_primary_get(view));
view_selections_dispose(view_selections_primary_get(view));
view_cursor_to(view, view_cursor_get(view));
return keys;
}
Expand Down Expand Up @@ -1465,7 +1465,7 @@ static const char *cursors_navigate(Vis *vis, const char *keys, const Arg *arg)
View *view = vis_view(vis);
if (view_cursors_count(view) == 1)
return wscroll(vis, keys, arg);
Cursor *c = view_cursors_primary_get(view);
Cursor *c = view_selections_primary_get(view);
VisCountIterator it = vis_count_iterator_get(vis, 1);
while (vis_count_iterator_next(&it)) {
if (arg->i > 0) {
Expand All @@ -1481,7 +1481,7 @@ static const char *cursors_navigate(Vis *vis, const char *keys, const Arg *arg)
}
}
}
view_cursors_primary_set(c);
view_selections_primary_set(c);
vis_count_set(vis, VIS_COUNT_UNKNOWN);
return keys;
}
Expand Down
8 changes: 4 additions & 4 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ 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_cursors_primary_set(view_cursors(vis->win->view));
view_selections_primary_set(view_cursors(vis->win->view));
bool completed = true;
for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c)) {
if (view_selection_anchored(c)) {
Expand Down Expand Up @@ -1438,7 +1438,7 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
View *view = win->view;
Text *txt = win->file->text;
bool multiple_cursors = view_cursors_count(view) > 1;
Cursor *primary = view_cursors_primary_get(view);
Cursor *primary = view_selections_primary_get(view);

if (vis->mode->visual)
count_init(cmd->cmd, view_cursors_count(view)+1);
Expand Down Expand Up @@ -1485,8 +1485,8 @@ static bool cmd_select(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
break;
}

if (vis->win && vis->win->view == view && primary != view_cursors_primary_get(view))
view_cursors_primary_set(view_cursors(view));
if (vis->win && vis->win->view == view && primary != view_selections_primary_get(view))
view_selections_primary_set(view_cursors(view));
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion ui-terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static void ui_window_draw(UiWin *w) {
vis_window_draw(win->win);
line = view_lines_first(view);
size_t prev_lineno = 0;
Cursor *cursor = view_cursors_primary_get(view);
Cursor *cursor = view_selections_primary_get(view);
const Line *cursor_line = view_cursors_line_get(cursor);
size_t cursor_lineno = cursor_line->lineno;
char buf[sidebar_width+1];
Expand Down
6 changes: 3 additions & 3 deletions view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ bool view_selections_dispose(Cursor *c) {
if (!view->cursors || !view->cursors->next)
return false;
view_cursors_free(c);
view_cursors_primary_set(view->cursor);
view_selections_primary_set(view->cursor);
return true;
}

Expand All @@ -1052,12 +1052,12 @@ Cursor *view_cursors(View *view) {
return view->cursors;
}

Cursor *view_cursors_primary_get(View *view) {
Cursor *view_selections_primary_get(View *view) {
view->cursor_generation++;
return view->cursor;
}

void view_cursors_primary_set(Cursor *c) {
void view_selections_primary_set(Cursor *c) {
if (!c)
return;
c->view->cursor = c;
Expand Down
4 changes: 2 additions & 2 deletions view.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ void view_selections_dispose_all(View*);
* @defgroup view_navigate
* @{
*/
Cursor *view_cursors_primary_get(View*);
void view_cursors_primary_set(Cursor*);
Cursor *view_selections_primary_get(View*);
void view_selections_primary_set(Cursor*);
/** Get first selection. */
Cursor *view_cursors(View*);
/** Get immediate predecessor of selection. */
Expand Down
8 changes: 4 additions & 4 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void window_status_update(Vis *vis, Win *win) {

int cursor_count = view_cursors_count(view);
if (cursor_count > 1) {
Cursor *c = view_cursors_primary_get(view);
Cursor *c = view_selections_primary_get(view);
int cursor_number = view_cursors_number(c) + 1;
snprintf(right_parts[right_count], sizeof(right_parts[right_count])-1,
"%d/%d", cursor_number, cursor_count);
Expand All @@ -100,7 +100,7 @@ static void window_status_update(Vis *vis, Win *win) {
right_count++;

if (!(options & UI_OPTION_LARGE_FILE)) {
Cursor *cur = view_cursors_primary_get(win->view);
Cursor *cur = view_selections_primary_get(win->view);
size_t line = view_cursors_line(cur);
size_t col = view_cursors_col(cur);
if (col > UI_LARGE_FILE_LINE_SIZE) {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ static bool command_lua(Vis *vis, Win *win, void *data, bool force, const char *
if (!obj_ref_new(L, win, VIS_LUA_TYPE_WINDOW))
return false;
if (!cur)
cur = view_cursors_primary_get(win->view);
cur = view_selections_primary_get(win->view);
if (!obj_lightref_new(L, cur, VIS_LUA_TYPE_CURSOR))
return false;
pushrange(L, range);
Expand Down Expand Up @@ -1574,7 +1574,7 @@ static int window_index(lua_State *L) {
}

if (strcmp(key, "cursor") == 0) {
Cursor *cur = view_cursors_primary_get(win->view);
Cursor *cur = view_selections_primary_get(win->view);
obj_lightref_new(L, cur, VIS_LUA_TYPE_CURSOR);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion vis-prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void vis_prompt_show(Vis *vis, const char *title) {
window_selection_save(active);
Text *txt = prompt->file->text;
text_appendf(txt, "%s\n", title);
Cursor *cursor = view_cursors_primary_get(prompt->view);
Cursor *cursor = view_selections_primary_get(prompt->view);
view_cursors_scroll_to(cursor, text_size(txt)-1);
prompt->parent = active;
prompt->parent_mode = vis->mode;
Expand Down
4 changes: 2 additions & 2 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static void window_draw_cursorline(Win *win) {

int width = view_width_get(view);
CellStyle style = win->ui->style_get(win->ui, UI_STYLE_CURSOR_LINE);
Cursor *cursor = view_cursors_primary_get(view);
Cursor *cursor = view_selections_primary_get(view);
size_t lineno = view_cursors_line_get(cursor)->lineno;
for (Line *l = view_lines_first(view); l; l = l->next) {
if (l->lineno == lineno) {
Expand Down Expand Up @@ -399,7 +399,7 @@ static void window_draw_cursors(Win *win) {
View *view = win->view;
Filerange viewport = view_viewport_get(view);
bool multiple_cursors = view_cursors_count(view) > 1;
Cursor *cursor = view_cursors_primary_get(view);
Cursor *cursor = view_selections_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);
CellStyle style_selection = win->ui->style_get(win->ui, UI_STYLE_SELECTION);
Expand Down

0 comments on commit a9c3e2c

Please sign in to comment.