=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window-copy.c,v retrieving revision 1.183 retrieving revision 1.184 diff -c -r1.183 -r1.184 *** src/usr.bin/tmux/window-copy.c 2017/09/04 09:18:51 1.183 --- src/usr.bin/tmux/window-copy.c 2017/09/13 07:31:07 1.184 *************** *** 1,4 **** ! /* $OpenBSD: window-copy.c,v 1.183 2017/09/04 09:18:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window-copy.c,v 1.184 2017/09/13 07:31:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 57,65 **** static int window_copy_is_lowercase(const char *); static int window_copy_search_jump(struct window_pane *, struct grid *, 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_up(struct window_pane *, int); ! static int window_copy_search_down(struct window_pane *, int); 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_start_selection(struct window_pane *); --- 57,65 ---- static int window_copy_is_lowercase(const char *); static int window_copy_search_jump(struct window_pane *, struct grid *, struct grid *, u_int, u_int, u_int, int, int, int); ! static int window_copy_search(struct window_pane *, int); ! static int window_copy_search_up(struct window_pane *); ! static int window_copy_search_down(struct window_pane *); 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_start_selection(struct window_pane *); *************** *** 91,98 **** 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_back(struct window_pane *); ! static void window_copy_cursor_jump_to(struct window_pane *, int); ! static void window_copy_cursor_jump_to_back(struct window_pane *, int); static void window_copy_cursor_next_word(struct window_pane *, const char *); static void window_copy_cursor_next_word_end(struct window_pane *, --- 91,98 ---- 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_back(struct window_pane *); ! static void window_copy_cursor_jump_to(struct window_pane *); ! static void window_copy_cursor_jump_to_back(struct window_pane *); static void window_copy_cursor_next_word(struct window_pane *, const char *); static void window_copy_cursor_next_word_end(struct window_pane *, *************** *** 667,677 **** break; case WINDOW_COPY_JUMPTOFORWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to(wp, 1); break; case WINDOW_COPY_JUMPTOBACKWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp, 1); break; } } --- 667,677 ---- break; case WINDOW_COPY_JUMPTOFORWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to(wp); break; case WINDOW_COPY_JUMPTOBACKWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp); break; } } *************** *** 687,697 **** break; case WINDOW_COPY_JUMPTOFORWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp, 1); break; case WINDOW_COPY_JUMPTOBACKWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to(wp, 1); break; } } --- 687,697 ---- break; case WINDOW_COPY_JUMPTOFORWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp); break; case WINDOW_COPY_JUMPTOBACKWARD: for (; np != 0; np--) ! window_copy_cursor_jump_to(wp); break; } } *************** *** 769,787 **** if (strcmp(command, "search-again") == 0) { if (data->searchtype == WINDOW_COPY_SEARCHUP) { for (; np != 0; np--) ! window_copy_search_up(wp, 1); } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { for (; np != 0; np--) ! window_copy_search_down(wp, 1); } } if (strcmp(command, "search-reverse") == 0) { if (data->searchtype == WINDOW_COPY_SEARCHUP) { for (; np != 0; np--) ! window_copy_search_down(wp, 1); } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { for (; np != 0; np--) ! window_copy_search_up(wp, 1); } } if (strcmp(command, "select-line") == 0) { --- 769,787 ---- if (strcmp(command, "search-again") == 0) { if (data->searchtype == WINDOW_COPY_SEARCHUP) { for (; np != 0; np--) ! window_copy_search_up(wp); } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { for (; np != 0; np--) ! window_copy_search_down(wp); } } if (strcmp(command, "search-reverse") == 0) { if (data->searchtype == WINDOW_COPY_SEARCHUP) { for (; np != 0; np--) ! window_copy_search_down(wp); } else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) { for (; np != 0; np--) ! window_copy_search_up(wp); } } if (strcmp(command, "select-line") == 0) { *************** *** 841,867 **** data->jumptype = WINDOW_COPY_JUMPTOBACKWARD; data->jumpchar = *argument; for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp, 1); } if (strcmp(command, "jump-to-forward") == 0) { data->jumptype = WINDOW_COPY_JUMPTOFORWARD; data->jumpchar = *argument; for (; np != 0; np--) ! window_copy_cursor_jump_to(wp, 1); } if (strcmp(command, "search-backward") == 0) { data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); for (; np != 0; np--) ! window_copy_search_up(wp, 1); } if (strcmp(command, "search-forward") == 0) { data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); for (; np != 0; np--) ! window_copy_search_down(wp, 1); } if (strcmp(command, "search-backward-incremental") == 0) { prefix = *argument++; --- 841,867 ---- data->jumptype = WINDOW_COPY_JUMPTOBACKWARD; data->jumpchar = *argument; for (; np != 0; np--) ! window_copy_cursor_jump_to_back(wp); } if (strcmp(command, "jump-to-forward") == 0) { data->jumptype = WINDOW_COPY_JUMPTOFORWARD; data->jumpchar = *argument; for (; np != 0; np--) ! window_copy_cursor_jump_to(wp); } if (strcmp(command, "search-backward") == 0) { data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); for (; np != 0; np--) ! window_copy_search_up(wp); } if (strcmp(command, "search-forward") == 0) { data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); for (; np != 0; np--) ! window_copy_search_down(wp); } if (strcmp(command, "search-backward-incremental") == 0) { prefix = *argument++; *************** *** 883,889 **** data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_up(wp, 1)) { window_copy_clear_marks(wp); redraw = 1; } --- 883,889 ---- data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_up(wp)) { window_copy_clear_marks(wp); redraw = 1; } *************** *** 891,897 **** data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_down(wp, 1)) { window_copy_clear_marks(wp); redraw = 1; } --- 891,897 ---- data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_down(wp)) { window_copy_clear_marks(wp); redraw = 1; } *************** *** 917,923 **** data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_down(wp, 1)) { window_copy_clear_marks(wp); redraw = 1; } --- 917,923 ---- data->searchtype = WINDOW_COPY_SEARCHDOWN; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_down(wp)) { window_copy_clear_marks(wp); redraw = 1; } *************** *** 925,931 **** data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_up(wp, 1)) { window_copy_clear_marks(wp); redraw = 1; } --- 925,931 ---- data->searchtype = WINDOW_COPY_SEARCHUP; free(data->searchstr); data->searchstr = xstrdup(argument); ! if (!window_copy_search_up(wp)) { window_copy_clear_marks(wp); redraw = 1; } *************** *** 1128,1138 **** /* * 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 ! * as well. */ static int ! window_copy_search(struct window_pane *wp, int direction, int moveflag) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = data->backing, ss; --- 1128,1137 ---- /* * Search in for text searchstr. If direction is 0 then search up, otherwise ! * down. */ static int ! window_copy_search(struct window_pane *wp, int direction) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = data->backing, ss; *************** *** 1152,1163 **** screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr); screen_write_stop(&ctx); ! if (moveflag) { ! if (direction) ! window_copy_move_right(s, &fx, &fy); ! else ! window_copy_move_left(s, &fx, &fy); ! } window_copy_clear_selection(wp); wrapflag = options_get_number(wp->window->options, "wrap-search"); --- 1151,1160 ---- screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr); screen_write_stop(&ctx); ! if (direction) ! window_copy_move_right(s, &fx, &fy); ! else ! window_copy_move_left(s, &fx, &fy); window_copy_clear_selection(wp); wrapflag = options_get_number(wp->window->options, "wrap-search"); *************** *** 1243,1257 **** } static int ! window_copy_search_up(struct window_pane *wp, int moveflag) { ! return (window_copy_search(wp, 0, moveflag)); } static int ! window_copy_search_down(struct window_pane *wp, int moveflag) { ! return (window_copy_search(wp, 1, moveflag)); } static void --- 1240,1254 ---- } static int ! window_copy_search_up(struct window_pane *wp) { ! return (window_copy_search(wp, 0)); } static int ! window_copy_search_down(struct window_pane *wp) { ! return (window_copy_search(wp, 1)); } static void *************** *** 2166,2179 **** } static void ! window_copy_cursor_jump_to(struct window_pane *wp, int jump_again) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; struct grid_cell gc; u_int px, py, xx; ! px = data->cx + 1 + jump_again; py = screen_hsize(back_s) + data->cy - data->oy; xx = window_copy_find_length(wp, py); --- 2163,2176 ---- } static void ! window_copy_cursor_jump_to(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; struct grid_cell gc; u_int px, py, xx; ! px = data->cx + 2; py = screen_hsize(back_s) + data->cy - data->oy; xx = window_copy_find_length(wp, py); *************** *** 2191,2197 **** } static void ! window_copy_cursor_jump_to_back(struct window_pane *wp, int jump_again) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; --- 2188,2194 ---- } static void ! window_copy_cursor_jump_to_back(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; struct screen *back_s = data->backing; *************** *** 2204,2210 **** if (px > 0) px--; ! if (jump_again && px > 0) px--; for (;;) { --- 2201,2207 ---- if (px > 0) px--; ! if (px > 0) px--; for (;;) {