=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window-copy.c,v retrieving revision 1.262 retrieving revision 1.263 diff -c -r1.262 -r1.263 *** src/usr.bin/tmux/window-copy.c 2020/04/01 08:07:05 1.262 --- src/usr.bin/tmux/window-copy.c 2020/04/01 09:36:37 1.263 *************** *** 1,4 **** ! /* $OpenBSD: window-copy.c,v 1.262 2020/04/01 08:07:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window-copy.c,v 1.263 2020/04/01 09:36:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 261,266 **** --- 261,269 ---- int searchy; int searcho; + int timeout; /* search has timed out */ + #define WINDOW_COPY_SEARCH_TIMEOUT 10 + int jumptype; char jumpchar; *************** *** 316,321 **** --- 319,325 ---- } data->searchmark = NULL; data->searchx = data->searchy = data->searcho = -1; + data->timeout = 0; data->jumptype = WINDOW_COPY_OFF; data->jumpchar = '\0'; *************** *** 680,687 **** window_copy_write_lines(wme, &ctx, 0, screen_size_y(s) - 1); screen_write_stop(&ctx); ! if (search) ! window_copy_search_marks(wme, NULL, 1); data->searchx = data->cx; data->searchy = data->cy; data->searcho = data->oy; --- 684,691 ---- window_copy_write_lines(wme, &ctx, 0, screen_size_y(s) - 1); screen_write_stop(&ctx); ! if (search && !data->timeout) ! window_copy_search_marks(wme, NULL, data->searchregex); data->searchx = data->cx; data->searchy = data->cy; data->searcho = data->oy; *************** *** 1800,1805 **** --- 1804,1810 ---- if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHUP; data->searchregex = 1; + data->timeout = 0; for (; np != 0; np--) window_copy_search_up(wme, 1); } *************** *** 1819,1824 **** --- 1824,1830 ---- if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHUP; data->searchregex = 0; + data->timeout = 0; for (; np != 0; np--) window_copy_search_up(wme, 0); } *************** *** 1838,1843 **** --- 1844,1850 ---- if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHDOWN; data->searchregex = 1; + data->timeout = 0; for (; np != 0; np--) window_copy_search_down(wme, 1); } *************** *** 1857,1862 **** --- 1864,1870 ---- if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHDOWN; data->searchregex = 0; + data->timeout = 0; for (; np != 0; np--) window_copy_search_down(wme, 0); } *************** *** 1873,1878 **** --- 1881,1888 ---- char prefix; enum window_copy_cmd_action action = WINDOW_COPY_CMD_NOTHING; + data->timeout = 0; + prefix = *argument++; if (data->searchx == -1 || data->searchy == -1) { data->searchx = data->cx; *************** *** 1924,1929 **** --- 1934,1941 ---- char prefix; enum window_copy_cmd_action action = WINDOW_COPY_CMD_NOTHING; + data->timeout = 0; + prefix = *argument++; if (data->searchx == -1 || data->searchy == -1) { data->searchx = data->cx; *************** *** 2721,2726 **** --- 2733,2741 ---- if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0') regex = 0; + if (data->timeout) + return (0); + free(wp->searchstr); wp->searchstr = xstrdup(str); wp->searchregex = regex; *************** *** 2768,2773 **** --- 2783,2789 ---- u_int ssize = 1; char *sbuf; regex_t reg; + time_t tstart, t; if (ssp == NULL) { width = screen_write_strlen("%s", data->searchstr); *************** *** 2797,2802 **** --- 2813,2819 ---- return (0); } } + time(&tstart); for (py = 0; py < gd->hsize + gd->sy; py++) { px = 0; for (;;) { *************** *** 2822,2832 **** --- 2839,2859 ---- px++; } + + time(&t); + if (t - tstart > WINDOW_COPY_SEARCH_TIMEOUT) { + data->timeout = 1; + break; + } } if (regex) { free(sbuf); regfree(®); } + if (data->timeout) { + window_copy_clear_marks(wme); + return (1); + } if (which != -1) data->searchthis = 1 + nfound - which; *************** *** 2836,2842 **** if (ssp == &ss) screen_free(&ss); ! return (nfound); } static void --- 2863,2869 ---- if (ssp == &ss) screen_free(&ss); ! return (1); } static void *************** *** 2895,2902 **** if (py == 0 && s->rupper < s->rlower && !data->hide_position) { if (data->searchmark == NULL) { ! size = xsnprintf(hdr, sizeof hdr, ! "[%u/%u]", data->oy, screen_hsize(data->backing)); } else { if (data->searchthis == -1) { size = xsnprintf(hdr, sizeof hdr, --- 2922,2936 ---- if (py == 0 && s->rupper < s->rlower && !data->hide_position) { if (data->searchmark == NULL) { ! if (data->timeout) { ! size = xsnprintf(hdr, sizeof hdr, ! "(timed out) [%u/%u]", data->oy, ! screen_hsize(data->backing)); ! } else { ! size = xsnprintf(hdr, sizeof hdr, ! "[%u/%u]", data->oy, ! screen_hsize(data->backing)); ! } } else { if (data->searchthis == -1) { size = xsnprintf(hdr, sizeof hdr,