version 1.258, 2020/03/21 13:19:56 |
version 1.259, 2020/03/31 16:53:23 |
|
|
u_int lastsx; /* size of last line w/ content */ |
u_int lastsx; /* size of last line w/ content */ |
|
|
int searchtype; |
int searchtype; |
|
int searchregex; |
char *searchstr; |
char *searchstr; |
bitstr_t *searchmark; |
bitstr_t *searchmark; |
u_int searchcount; |
u_int searchcount; |
|
|
|
|
if (wp->searchstr != NULL) { |
if (wp->searchstr != NULL) { |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
|
data->searchregex = wp->searchregex; |
data->searchstr = xstrdup(wp->searchstr); |
data->searchstr = xstrdup(wp->searchstr); |
} else { |
} else { |
data->searchtype = WINDOW_COPY_OFF; |
data->searchtype = WINDOW_COPY_OFF; |
|
data->searchregex = 0; |
data->searchstr = NULL; |
data->searchstr = NULL; |
} |
} |
data->searchmark = NULL; |
data->searchmark = NULL; |
|
|
return ("copy-mode"); |
return ("copy-mode"); |
} |
} |
|
|
|
static int |
|
window_copy_expand_search_string(struct window_copy_cmd_state *cs) |
|
{ |
|
struct window_mode_entry *wme = cs->wme; |
|
struct window_copy_mode_data *data = wme->data; |
|
const char *argument; |
|
char *expanded; |
|
|
|
if (cs->args->argc == 2) { |
|
argument = cs->args->argv[1]; |
|
if (*argument != '\0') { |
|
if (args_has(cs->args, 'F')) { |
|
expanded = format_single(NULL, argument, NULL, |
|
NULL, NULL, wme->wp); |
|
if (*expanded == '\0') { |
|
free(expanded); |
|
return (0); |
|
} |
|
free(data->searchstr); |
|
data->searchstr = expanded; |
|
} else { |
|
free(data->searchstr); |
|
data->searchstr = xstrdup(argument); |
|
} |
|
} |
|
} |
|
return (1); |
|
} |
|
|
static enum window_copy_cmd_action |
static enum window_copy_cmd_action |
window_copy_cmd_append_selection(struct window_copy_cmd_state *cs) |
window_copy_cmd_append_selection(struct window_copy_cmd_state *cs) |
{ |
{ |
|
|
|
|
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_up(wme, 1); |
window_copy_search_up(wme, data->searchregex); |
} 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(wme, 1); |
window_copy_search_down(wme, data->searchregex); |
} |
} |
return (WINDOW_COPY_CMD_NOTHING); |
return (WINDOW_COPY_CMD_NOTHING); |
} |
} |
|
|
|
|
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
if (data->searchtype == WINDOW_COPY_SEARCHUP) { |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_down(wme, 1); |
window_copy_search_down(wme, data->searchregex); |
} 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(wme, 1); |
window_copy_search_up(wme, data->searchregex); |
} |
} |
return (WINDOW_COPY_CMD_NOTHING); |
return (WINDOW_COPY_CMD_NOTHING); |
} |
} |
|
|
struct window_mode_entry *wme = cs->wme; |
struct window_mode_entry *wme = cs->wme; |
struct window_copy_mode_data *data = wme->data; |
struct window_copy_mode_data *data = wme->data; |
u_int np = wme->prefix; |
u_int np = wme->prefix; |
const char *argument; |
|
char *expanded; |
|
|
|
if (cs->args->argc == 2) { |
if (!window_copy_expand_search_string(cs)) |
argument = cs->args->argv[1]; |
return (WINDOW_COPY_CMD_NOTHING); |
if (*argument != '\0') { |
|
if (args_has(cs->args, 'F')) { |
|
expanded = format_single(NULL, argument, NULL, |
|
NULL, NULL, wme->wp); |
|
if (*expanded == '\0') { |
|
free(expanded); |
|
return (WINDOW_COPY_CMD_NOTHING); |
|
} |
|
free(data->searchstr); |
|
data->searchstr = expanded; |
|
} else { |
|
free(data->searchstr); |
|
data->searchstr = xstrdup(argument); |
|
} |
|
} |
|
} |
|
if (data->searchstr != NULL) { |
if (data->searchstr != NULL) { |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
|
data->searchregex = 1; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_up(wme, 1); |
window_copy_search_up(wme, 1); |
} |
} |
|
|
} |
} |
|
|
static enum window_copy_cmd_action |
static enum window_copy_cmd_action |
window_copy_cmd_search_forward(struct window_copy_cmd_state *cs) |
window_copy_cmd_search_backward_text(struct window_copy_cmd_state *cs) |
{ |
{ |
struct window_mode_entry *wme = cs->wme; |
struct window_mode_entry *wme = cs->wme; |
struct window_copy_mode_data *data = wme->data; |
struct window_copy_mode_data *data = wme->data; |
u_int np = wme->prefix; |
u_int np = wme->prefix; |
const char *argument; |
|
char *expanded; |
|
|
|
if (cs->args->argc == 2) { |
if (!window_copy_expand_search_string(cs)) |
argument = cs->args->argv[1]; |
return (WINDOW_COPY_CMD_NOTHING); |
if (*argument != '\0') { |
|
if (args_has(cs->args, 'F')) { |
if (data->searchstr != NULL) { |
expanded = format_single(NULL, argument, NULL, |
data->searchtype = WINDOW_COPY_SEARCHUP; |
NULL, NULL, wme->wp); |
data->searchregex = 0; |
if (*expanded == '\0') { |
for (; np != 0; np--) |
free(expanded); |
window_copy_search_up(wme, 0); |
return (WINDOW_COPY_CMD_NOTHING); |
|
} |
|
free(data->searchstr); |
|
data->searchstr = expanded; |
|
} else { |
|
free(data->searchstr); |
|
data->searchstr = xstrdup(argument); |
|
} |
|
} |
|
} |
} |
|
return (WINDOW_COPY_CMD_NOTHING); |
|
} |
|
|
|
static enum window_copy_cmd_action |
|
window_copy_cmd_search_forward(struct window_copy_cmd_state *cs) |
|
{ |
|
struct window_mode_entry *wme = cs->wme; |
|
struct window_copy_mode_data *data = wme->data; |
|
u_int np = wme->prefix; |
|
|
|
if (!window_copy_expand_search_string(cs)) |
|
return (WINDOW_COPY_CMD_NOTHING); |
|
|
if (data->searchstr != NULL) { |
if (data->searchstr != NULL) { |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
|
data->searchregex = 1; |
for (; np != 0; np--) |
for (; np != 0; np--) |
window_copy_search_down(wme, 1); |
window_copy_search_down(wme, 1); |
} |
} |
|
|
} |
} |
|
|
static enum window_copy_cmd_action |
static enum window_copy_cmd_action |
|
window_copy_cmd_search_forward_text(struct window_copy_cmd_state *cs) |
|
{ |
|
struct window_mode_entry *wme = cs->wme; |
|
struct window_copy_mode_data *data = wme->data; |
|
u_int np = wme->prefix; |
|
|
|
if (!window_copy_expand_search_string(cs)) |
|
return (WINDOW_COPY_CMD_NOTHING); |
|
|
|
if (data->searchstr != NULL) { |
|
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
|
data->searchregex = 0; |
|
for (; np != 0; np--) |
|
window_copy_search_down(wme, 0); |
|
} |
|
return (WINDOW_COPY_CMD_NOTHING); |
|
} |
|
|
|
static enum window_copy_cmd_action |
window_copy_cmd_search_backward_incremental(struct window_copy_cmd_state *cs) |
window_copy_cmd_search_backward_incremental(struct window_copy_cmd_state *cs) |
{ |
{ |
struct window_mode_entry *wme = cs->wme; |
struct window_mode_entry *wme = cs->wme; |
|
|
case '=': |
case '=': |
case '-': |
case '-': |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
|
data->searchregex = 0; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_up(wme, 0)) { |
if (!window_copy_search_up(wme, 0)) { |
|
|
break; |
break; |
case '+': |
case '+': |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
|
data->searchregex = 0; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_down(wme, 0)) { |
if (!window_copy_search_down(wme, 0)) { |
|
|
case '=': |
case '=': |
case '+': |
case '+': |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
data->searchtype = WINDOW_COPY_SEARCHDOWN; |
|
data->searchregex = 0; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_down(wme, 0)) { |
if (!window_copy_search_down(wme, 0)) { |
|
|
break; |
break; |
case '-': |
case '-': |
data->searchtype = WINDOW_COPY_SEARCHUP; |
data->searchtype = WINDOW_COPY_SEARCHUP; |
|
data->searchregex = 0; |
free(data->searchstr); |
free(data->searchstr); |
data->searchstr = xstrdup(argument); |
data->searchstr = xstrdup(argument); |
if (!window_copy_search_up(wme, 0)) { |
if (!window_copy_search_up(wme, 0)) { |
|
|
window_copy_cmd_search_again }, |
window_copy_cmd_search_again }, |
{ "search-backward", 0, 1, 0, |
{ "search-backward", 0, 1, 0, |
window_copy_cmd_search_backward }, |
window_copy_cmd_search_backward }, |
|
{ "search-backward-text", 0, 1, 0, |
|
window_copy_cmd_search_backward_text }, |
{ "search-backward-incremental", 1, 1, 0, |
{ "search-backward-incremental", 1, 1, 0, |
window_copy_cmd_search_backward_incremental }, |
window_copy_cmd_search_backward_incremental }, |
{ "search-forward", 0, 1, 0, |
{ "search-forward", 0, 1, 0, |
window_copy_cmd_search_forward }, |
window_copy_cmd_search_forward }, |
|
{ "search-forward-text", 0, 1, 0, |
|
window_copy_cmd_search_forward_text }, |
{ "search-forward-incremental", 1, 1, 0, |
{ "search-forward-incremental", 1, 1, 0, |
window_copy_cmd_search_forward_incremental }, |
window_copy_cmd_search_forward_incremental }, |
{ "search-reverse", 0, 0, 0, |
{ "search-reverse", 0, 0, 0, |
|
|
|
|
free(wp->searchstr); |
free(wp->searchstr); |
wp->searchstr = xstrdup(data->searchstr); |
wp->searchstr = xstrdup(data->searchstr); |
|
wp->searchregex = regex; |
|
|
fx = data->cx; |
fx = data->cx; |
fy = screen_hsize(data->backing) - data->oy + data->cy; |
fy = screen_hsize(data->backing) - data->oy + data->cy; |