Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2017-09-13 10:01:10 +01:00

View File

@ -57,9 +57,9 @@ static void window_copy_move_right(struct screen *, u_int *, u_int *);
static int window_copy_is_lowercase(const char *); static int window_copy_is_lowercase(const char *);
static int window_copy_search_jump(struct window_pane *, struct grid *, static int window_copy_search_jump(struct window_pane *, struct grid *,
struct grid *, u_int, u_int, u_int, int, int, int); struct grid *, u_int, u_int, u_int, int, int, int);
static int window_copy_search(struct window_pane *, int, int); static int window_copy_search(struct window_pane *, int);
static int window_copy_search_up(struct window_pane *, int); static int window_copy_search_up(struct window_pane *);
static int window_copy_search_down(struct window_pane *, int); static int window_copy_search_down(struct window_pane *);
static void window_copy_goto_line(struct window_pane *, const char *); static void window_copy_goto_line(struct window_pane *, const char *);
static void window_copy_update_cursor(struct window_pane *, u_int, u_int); static void window_copy_update_cursor(struct window_pane *, u_int, u_int);
static void window_copy_start_selection(struct window_pane *); static void window_copy_start_selection(struct window_pane *);
@ -91,8 +91,8 @@ static void window_copy_cursor_up(struct window_pane *, int);
static void window_copy_cursor_down(struct window_pane *, int); static void window_copy_cursor_down(struct window_pane *, int);
static void window_copy_cursor_jump(struct window_pane *); static void window_copy_cursor_jump(struct window_pane *);
static void window_copy_cursor_jump_back(struct window_pane *); static void window_copy_cursor_jump_back(struct window_pane *);
static void window_copy_cursor_jump_to(struct window_pane *, int); static void window_copy_cursor_jump_to(struct window_pane *);
static void window_copy_cursor_jump_to_back(struct window_pane *, int); static void window_copy_cursor_jump_to_back(struct window_pane *);
static void window_copy_cursor_next_word(struct window_pane *, static void window_copy_cursor_next_word(struct window_pane *,
const char *); const char *);
static void window_copy_cursor_next_word_end(struct window_pane *, static void window_copy_cursor_next_word_end(struct window_pane *,
@ -667,11 +667,11 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
break; break;
case WINDOW_COPY_JUMPTOFORWARD: case WINDOW_COPY_JUMPTOFORWARD:
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to(wp, 1); window_copy_cursor_jump_to(wp);
break; break;
case WINDOW_COPY_JUMPTOBACKWARD: case WINDOW_COPY_JUMPTOBACKWARD:
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to_back(wp, 1); window_copy_cursor_jump_to_back(wp);
break; break;
} }
} }
@ -687,11 +687,11 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
break; break;
case WINDOW_COPY_JUMPTOFORWARD: case WINDOW_COPY_JUMPTOFORWARD:
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to_back(wp, 1); window_copy_cursor_jump_to_back(wp);
break; break;
case WINDOW_COPY_JUMPTOBACKWARD: case WINDOW_COPY_JUMPTOBACKWARD:
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to(wp, 1); window_copy_cursor_jump_to(wp);
break; break;
} }
} }
@ -769,19 +769,19 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
if (strcmp(command, "search-again") == 0) { if (strcmp(command, "search-again") == 0) {
if (data->searchtype == WINDOW_COPY_SEARCHUP) { if (data->searchtype == WINDOW_COPY_SEARCHUP) {
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_up(wp, 1); window_copy_search_up(wp);
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) {
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_down(wp, 1); window_copy_search_down(wp);
} }
} }
if (strcmp(command, "search-reverse") == 0) { if (strcmp(command, "search-reverse") == 0) {
if (data->searchtype == WINDOW_COPY_SEARCHUP) { if (data->searchtype == WINDOW_COPY_SEARCHUP) {
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_down(wp, 1); window_copy_search_down(wp);
} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) {
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_up(wp, 1); window_copy_search_up(wp);
} }
} }
if (strcmp(command, "select-line") == 0) { if (strcmp(command, "select-line") == 0) {
@ -841,27 +841,27 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
data->jumptype = WINDOW_COPY_JUMPTOBACKWARD; data->jumptype = WINDOW_COPY_JUMPTOBACKWARD;
data->jumpchar = *argument; data->jumpchar = *argument;
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to_back(wp, 1); window_copy_cursor_jump_to_back(wp);
} }
if (strcmp(command, "jump-to-forward") == 0) { if (strcmp(command, "jump-to-forward") == 0) {
data->jumptype = WINDOW_COPY_JUMPTOFORWARD; data->jumptype = WINDOW_COPY_JUMPTOFORWARD;
data->jumpchar = *argument; data->jumpchar = *argument;
for (; np != 0; np--) for (; np != 0; np--)
window_copy_cursor_jump_to(wp, 1); window_copy_cursor_jump_to(wp);
} }
if (strcmp(command, "search-backward") == 0) { if (strcmp(command, "search-backward") == 0) {
data->searchtype = WINDOW_COPY_SEARCHUP; data->searchtype = WINDOW_COPY_SEARCHUP;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_up(wp, 1); window_copy_search_up(wp);
} }
if (strcmp(command, "search-forward") == 0) { if (strcmp(command, "search-forward") == 0) {
data->searchtype = WINDOW_COPY_SEARCHDOWN; data->searchtype = WINDOW_COPY_SEARCHDOWN;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
for (; np != 0; np--) for (; np != 0; np--)
window_copy_search_down(wp, 1); window_copy_search_down(wp);
} }
if (strcmp(command, "search-backward-incremental") == 0) { if (strcmp(command, "search-backward-incremental") == 0) {
prefix = *argument++; prefix = *argument++;
@ -883,7 +883,7 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
data->searchtype = WINDOW_COPY_SEARCHUP; data->searchtype = WINDOW_COPY_SEARCHUP;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
if (!window_copy_search_up(wp, 1)) { if (!window_copy_search_up(wp)) {
window_copy_clear_marks(wp); window_copy_clear_marks(wp);
redraw = 1; redraw = 1;
} }
@ -891,7 +891,7 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
data->searchtype = WINDOW_COPY_SEARCHDOWN; data->searchtype = WINDOW_COPY_SEARCHDOWN;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
if (!window_copy_search_down(wp, 1)) { if (!window_copy_search_down(wp)) {
window_copy_clear_marks(wp); window_copy_clear_marks(wp);
redraw = 1; redraw = 1;
} }
@ -917,7 +917,7 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
data->searchtype = WINDOW_COPY_SEARCHDOWN; data->searchtype = WINDOW_COPY_SEARCHDOWN;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
if (!window_copy_search_down(wp, 1)) { if (!window_copy_search_down(wp)) {
window_copy_clear_marks(wp); window_copy_clear_marks(wp);
redraw = 1; redraw = 1;
} }
@ -925,7 +925,7 @@ window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
data->searchtype = WINDOW_COPY_SEARCHUP; data->searchtype = WINDOW_COPY_SEARCHUP;
free(data->searchstr); free(data->searchstr);
data->searchstr = xstrdup(argument); data->searchstr = xstrdup(argument);
if (!window_copy_search_up(wp, 1)) { if (!window_copy_search_up(wp)) {
window_copy_clear_marks(wp); window_copy_clear_marks(wp);
redraw = 1; redraw = 1;
} }
@ -1128,11 +1128,10 @@ window_copy_search_jump(struct window_pane *wp, struct grid *gd,
/* /*
* Search in for text searchstr. If direction is 0 then search up, otherwise * Search in for text searchstr. If direction is 0 then search up, otherwise
* down. If moveflag is 0 then look for string at the current cursor position * down.
* as well.
*/ */
static int static int
window_copy_search(struct window_pane *wp, int direction, int moveflag) window_copy_search(struct window_pane *wp, int direction)
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct screen *s = data->backing, ss; struct screen *s = data->backing, ss;
@ -1152,12 +1151,10 @@ window_copy_search(struct window_pane *wp, int direction, int moveflag)
screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr); screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr);
screen_write_stop(&ctx); screen_write_stop(&ctx);
if (moveflag) { if (direction)
if (direction) window_copy_move_right(s, &fx, &fy);
window_copy_move_right(s, &fx, &fy); else
else window_copy_move_left(s, &fx, &fy);
window_copy_move_left(s, &fx, &fy);
}
window_copy_clear_selection(wp); window_copy_clear_selection(wp);
wrapflag = options_get_number(wp->window->options, "wrap-search"); wrapflag = options_get_number(wp->window->options, "wrap-search");
@ -1243,15 +1240,15 @@ window_copy_clear_marks(struct window_pane *wp)
} }
static int static int
window_copy_search_up(struct window_pane *wp, int moveflag) window_copy_search_up(struct window_pane *wp)
{ {
return (window_copy_search(wp, 0, moveflag)); return (window_copy_search(wp, 0));
} }
static int static int
window_copy_search_down(struct window_pane *wp, int moveflag) window_copy_search_down(struct window_pane *wp)
{ {
return (window_copy_search(wp, 1, moveflag)); return (window_copy_search(wp, 1));
} }
static void static void
@ -2166,14 +2163,14 @@ window_copy_cursor_jump_back(struct window_pane *wp)
} }
static void static void
window_copy_cursor_jump_to(struct window_pane *wp, int jump_again) window_copy_cursor_jump_to(struct window_pane *wp)
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct screen *back_s = data->backing; struct screen *back_s = data->backing;
struct grid_cell gc; struct grid_cell gc;
u_int px, py, xx; u_int px, py, xx;
px = data->cx + 1 + jump_again; px = data->cx + 2;
py = screen_hsize(back_s) + data->cy - data->oy; py = screen_hsize(back_s) + data->cy - data->oy;
xx = window_copy_find_length(wp, py); xx = window_copy_find_length(wp, py);
@ -2191,7 +2188,7 @@ window_copy_cursor_jump_to(struct window_pane *wp, int jump_again)
} }
static void static void
window_copy_cursor_jump_to_back(struct window_pane *wp, int jump_again) window_copy_cursor_jump_to_back(struct window_pane *wp)
{ {
struct window_copy_mode_data *data = wp->modedata; struct window_copy_mode_data *data = wp->modedata;
struct screen *back_s = data->backing; struct screen *back_s = data->backing;
@ -2204,7 +2201,7 @@ window_copy_cursor_jump_to_back(struct window_pane *wp, int jump_again)
if (px > 0) if (px > 0)
px--; px--;
if (jump_again && px > 0) if (px > 0)
px--; px--;
for (;;) { for (;;) {