mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 11:18:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
9f0973b711
@ -1660,8 +1660,6 @@ server_client_reset_state(struct client *c)
|
|||||||
s = wp->screen;
|
s = wp->screen;
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
mode = s->mode;
|
mode = s->mode;
|
||||||
if (c->prompt_string != NULL || c->message_string != NULL)
|
|
||||||
mode &= ~MODE_CURSOR;
|
|
||||||
log_debug("%s: client %s mode %x", __func__, c->name, mode);
|
log_debug("%s: client %s mode %x", __func__, c->name, mode);
|
||||||
|
|
||||||
/* Reset region and margin. */
|
/* Reset region and margin. */
|
||||||
|
@ -76,10 +76,10 @@ static void window_copy_move_right(struct screen *, u_int *, u_int *, 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_mode_entry *,
|
static int window_copy_search_jump(struct window_mode_entry *,
|
||||||
struct grid *, struct grid *, u_int, u_int, u_int, int, int,
|
struct grid *, struct grid *, u_int, u_int, u_int, int, int,
|
||||||
int, int);
|
int, int, u_int *);
|
||||||
static int window_copy_search(struct window_mode_entry *, int, int);
|
static int window_copy_search(struct window_mode_entry *, int, int, int);
|
||||||
static int window_copy_search_up(struct window_mode_entry *, int);
|
static int window_copy_search_up(struct window_mode_entry *, int, int);
|
||||||
static int window_copy_search_down(struct window_mode_entry *, int);
|
static int window_copy_search_down(struct window_mode_entry *, int, int);
|
||||||
static void window_copy_goto_line(struct window_mode_entry *, const char *);
|
static void window_copy_goto_line(struct window_mode_entry *, const char *);
|
||||||
static void window_copy_update_cursor(struct window_mode_entry *, u_int,
|
static void window_copy_update_cursor(struct window_mode_entry *, u_int,
|
||||||
u_int);
|
u_int);
|
||||||
@ -1685,10 +1685,10 @@ window_copy_cmd_search_again(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, data->searchregex);
|
window_copy_search_up(wme, data->searchregex, 1);
|
||||||
} 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, data->searchregex);
|
window_copy_search_down(wme, data->searchregex, 1);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -1702,10 +1702,10 @@ window_copy_cmd_search_reverse(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_down(wme, data->searchregex);
|
window_copy_search_down(wme, data->searchregex, 1);
|
||||||
} 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, data->searchregex);
|
window_copy_search_up(wme, data->searchregex, 1);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -1953,7 +1953,7 @@ window_copy_cmd_search_backward(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 1;
|
data->searchregex = 1;
|
||||||
data->timeout = 0;
|
data->timeout = 0;
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
window_copy_search_up(wme, 1);
|
window_copy_search_up(wme, 1, 0);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -1973,7 +1973,7 @@ window_copy_cmd_search_backward_text(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
data->searchregex = 0;
|
||||||
data->timeout = 0;
|
data->timeout = 0;
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
window_copy_search_up(wme, 0);
|
window_copy_search_up(wme, 0, 0);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -1993,7 +1993,7 @@ window_copy_cmd_search_forward(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 1;
|
data->searchregex = 1;
|
||||||
data->timeout = 0;
|
data->timeout = 0;
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
window_copy_search_down(wme, 1);
|
window_copy_search_down(wme, 1, 0);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -2013,7 +2013,7 @@ window_copy_cmd_search_forward_text(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
data->searchregex = 0;
|
||||||
data->timeout = 0;
|
data->timeout = 0;
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
window_copy_search_down(wme, 0);
|
window_copy_search_down(wme, 0, 0);
|
||||||
}
|
}
|
||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
@ -2052,7 +2052,7 @@ window_copy_cmd_search_backward_incremental(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
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, 1)) {
|
||||||
window_copy_clear_marks(wme);
|
window_copy_clear_marks(wme);
|
||||||
return (WINDOW_COPY_CMD_REDRAW);
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
}
|
}
|
||||||
@ -2062,7 +2062,7 @@ window_copy_cmd_search_backward_incremental(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
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, 0)) {
|
||||||
window_copy_clear_marks(wme);
|
window_copy_clear_marks(wme);
|
||||||
return (WINDOW_COPY_CMD_REDRAW);
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
}
|
}
|
||||||
@ -2105,7 +2105,7 @@ window_copy_cmd_search_forward_incremental(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
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, 1)) {
|
||||||
window_copy_clear_marks(wme);
|
window_copy_clear_marks(wme);
|
||||||
return (WINDOW_COPY_CMD_REDRAW);
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
}
|
}
|
||||||
@ -2115,7 +2115,7 @@ window_copy_cmd_search_forward_incremental(struct window_copy_cmd_state *cs)
|
|||||||
data->searchregex = 0;
|
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, 1)) {
|
||||||
window_copy_clear_marks(wme);
|
window_copy_clear_marks(wme);
|
||||||
return (WINDOW_COPY_CMD_REDRAW);
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
}
|
}
|
||||||
@ -2406,8 +2406,8 @@ window_copy_search_compare(struct grid *gd, u_int px, u_int py,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
window_copy_search_lr(struct grid *gd,
|
window_copy_search_lr(struct grid *gd, struct grid *sgd, u_int *ppx, u_int py,
|
||||||
struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis)
|
u_int first, u_int last, int cis)
|
||||||
{
|
{
|
||||||
u_int ax, bx, px, pywrap, endline;
|
u_int ax, bx, px, pywrap, endline;
|
||||||
int matched;
|
int matched;
|
||||||
@ -2854,7 +2854,7 @@ window_copy_is_lowercase(const char *ptr)
|
|||||||
static int
|
static int
|
||||||
window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
||||||
struct grid *sgd, u_int fx, u_int fy, u_int endline, int cis, int wrap,
|
struct grid *sgd, u_int fx, u_int fy, u_int endline, int cis, int wrap,
|
||||||
int direction, int regex)
|
int direction, int regex, u_int *foundlen)
|
||||||
{
|
{
|
||||||
u_int i, px, sx, ssize = 1;
|
u_int i, px, sx, ssize = 1;
|
||||||
int found = 0, cflags = REG_EXTENDED;
|
int found = 0, cflags = REG_EXTENDED;
|
||||||
@ -2878,15 +2878,20 @@ window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
|||||||
if (regex) {
|
if (regex) {
|
||||||
found = window_copy_search_lr_regex(gd,
|
found = window_copy_search_lr_regex(gd,
|
||||||
&px, &sx, i, fx, gd->sx, ®);
|
&px, &sx, i, fx, gd->sx, ®);
|
||||||
|
if (found)
|
||||||
|
*foundlen = sx;
|
||||||
} else {
|
} else {
|
||||||
found = window_copy_search_lr(gd, sgd,
|
found = window_copy_search_lr(gd, sgd,
|
||||||
&px, i, fx, gd->sx, cis);
|
&px, i, fx, gd->sx, cis);
|
||||||
|
if (found)
|
||||||
|
*foundlen = sgd->sx;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
fx = 0;
|
fx = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
*foundlen = 0;
|
||||||
for (i = fy + 1; endline < i; i--) {
|
for (i = fy + 1; endline < i; i--) {
|
||||||
if (regex) {
|
if (regex) {
|
||||||
found = window_copy_search_rl_regex(gd,
|
found = window_copy_search_rl_regex(gd,
|
||||||
@ -2915,7 +2920,7 @@ window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
|||||||
return (window_copy_search_jump(wme, gd, sgd,
|
return (window_copy_search_jump(wme, gd, sgd,
|
||||||
direction ? 0 : gd->sx - 1,
|
direction ? 0 : gd->sx - 1,
|
||||||
direction ? 0 : gd->hsize + gd->sy - 1, fy, cis, 0,
|
direction ? 0 : gd->hsize + gd->sy - 1, fy, cis, 0,
|
||||||
direction, regex));
|
direction, regex, foundlen));
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -2925,7 +2930,7 @@ window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
|||||||
* down.
|
* down.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
window_copy_search(struct window_mode_entry *wme, int direction, int regex)
|
window_copy_search(struct window_mode_entry *wme, int direction, int regex, int again)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = wme->wp;
|
struct window_pane *wp = wme->wp;
|
||||||
struct window_copy_mode_data *data = wme->data;
|
struct window_copy_mode_data *data = wme->data;
|
||||||
@ -2933,7 +2938,7 @@ window_copy_search(struct window_mode_entry *wme, int direction, int regex)
|
|||||||
struct screen_write_ctx ctx;
|
struct screen_write_ctx ctx;
|
||||||
struct grid *gd = s->grid;
|
struct grid *gd = s->grid;
|
||||||
const char *str = data->searchstr;
|
const char *str = data->searchstr;
|
||||||
u_int fx, fy, endline;
|
u_int fx, fy, endline, i, foundlen;
|
||||||
int wrapflag, cis, found, visible_only;
|
int wrapflag, cis, found, visible_only;
|
||||||
|
|
||||||
if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0')
|
if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0')
|
||||||
@ -2961,18 +2966,23 @@ window_copy_search(struct window_mode_entry *wme, int direction, int regex)
|
|||||||
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
||||||
cis = window_copy_is_lowercase(str);
|
cis = window_copy_is_lowercase(str);
|
||||||
|
|
||||||
if (direction) {
|
if (direction)
|
||||||
window_copy_move_right(s, &fx, &fy, wrapflag);
|
|
||||||
endline = gd->hsize + gd->sy - 1;
|
endline = gd->hsize + gd->sy - 1;
|
||||||
} else {
|
else {
|
||||||
|
if (again)
|
||||||
window_copy_move_left(s, &fx, &fy, wrapflag);
|
window_copy_move_left(s, &fx, &fy, wrapflag);
|
||||||
endline = 0;
|
endline = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis,
|
found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis,
|
||||||
wrapflag, direction, regex);
|
wrapflag, direction, regex, &foundlen);
|
||||||
if (found)
|
if (found) {
|
||||||
window_copy_search_marks(wme, &ss, regex, visible_only);
|
window_copy_search_marks(wme, &ss, regex, visible_only);
|
||||||
|
if (foundlen != 0) {
|
||||||
|
for (i = 0; i < foundlen; i++)
|
||||||
|
window_copy_cursor_right(wme);
|
||||||
|
}
|
||||||
|
}
|
||||||
window_copy_redraw_screen(wme);
|
window_copy_redraw_screen(wme);
|
||||||
|
|
||||||
screen_free(&ss);
|
screen_free(&ss);
|
||||||
@ -2995,8 +3005,8 @@ window_copy_visible_lines(struct window_copy_mode_data *data, u_int *start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
window_copy_search_mark_at(struct window_copy_mode_data *data, u_int px, u_int py,
|
window_copy_search_mark_at(struct window_copy_mode_data *data, u_int px,
|
||||||
u_int *at)
|
u_int py, u_int *at)
|
||||||
{
|
{
|
||||||
struct screen *s = data->backing;
|
struct screen *s = data->backing;
|
||||||
struct grid *gd = s->grid;
|
struct grid *gd = s->grid;
|
||||||
@ -3096,7 +3106,7 @@ again:
|
|||||||
data->searchgen++;
|
data->searchgen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
px++;
|
px += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
t = get_timer();
|
t = get_timer();
|
||||||
@ -3163,15 +3173,15 @@ window_copy_clear_marks(struct window_mode_entry *wme)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
window_copy_search_up(struct window_mode_entry *wme, int regex)
|
window_copy_search_up(struct window_mode_entry *wme, int regex, int again)
|
||||||
{
|
{
|
||||||
return (window_copy_search(wme, 0, regex));
|
return (window_copy_search(wme, 0, regex, again));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
window_copy_search_down(struct window_mode_entry *wme, int regex)
|
window_copy_search_down(struct window_mode_entry *wme, int regex, int again)
|
||||||
{
|
{
|
||||||
return (window_copy_search(wme, 1, regex));
|
return (window_copy_search(wme, 1, regex, again));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3256,7 +3266,7 @@ window_copy_update_style(struct window_mode_entry *wme, u_int fx, u_int fy,
|
|||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wme->data;
|
struct window_copy_mode_data *data = wme->data;
|
||||||
u_int mark, start, end, cy, cursor, current;
|
u_int mark, start, end, cy, cursor, current;
|
||||||
int inv = 0;
|
int inv = 0, found = 0;
|
||||||
|
|
||||||
if (data->showmark && fy == data->my) {
|
if (data->showmark && fy == data->my) {
|
||||||
gc->attr = mkgc->attr;
|
gc->attr = mkgc->attr;
|
||||||
@ -3282,8 +3292,15 @@ window_copy_update_style(struct window_mode_entry *wme, u_int fx, u_int fy,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
cy = screen_hsize(data->backing) - data->oy + data->cy;
|
cy = screen_hsize(data->backing) - data->oy + data->cy;
|
||||||
if (window_copy_search_mark_at(data, data->cx, cy, &cursor) == 0 &&
|
if (window_copy_search_mark_at(data, data->cx, cy, &cursor) == 0) {
|
||||||
data->searchmark[cursor] == mark) {
|
if (data->searchmark[cursor] == mark)
|
||||||
|
found = 1;
|
||||||
|
else if (cursor != 0) {
|
||||||
|
cursor--;
|
||||||
|
if (data->searchmark[cursor] == mark)
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
window_copy_match_start_end(data, cursor, &start, &end);
|
window_copy_match_start_end(data, cursor, &start, &end);
|
||||||
if (current >= start && current <= end) {
|
if (current >= start && current <= end) {
|
||||||
gc->attr = cgc->attr;
|
gc->attr = cgc->attr;
|
||||||
@ -3298,6 +3315,7 @@ window_copy_update_style(struct window_mode_entry *wme, u_int fx, u_int fy,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gc->attr = mgc->attr;
|
gc->attr = mgc->attr;
|
||||||
if (inv) {
|
if (inv) {
|
||||||
@ -3370,7 +3388,8 @@ window_copy_write_line(struct window_mode_entry *wme,
|
|||||||
} else if (data->searchthis == -1) {
|
} else if (data->searchthis == -1) {
|
||||||
size = xsnprintf(hdr, sizeof hdr,
|
size = xsnprintf(hdr, sizeof hdr,
|
||||||
"(%d%s results) [%u/%u]", data->searchcount,
|
"(%d%s results) [%u/%u]", data->searchcount,
|
||||||
data->searchmore ? "+" : "", data->oy, hsize);
|
data->searchmore ? "+" : "", data->oy,
|
||||||
|
hsize);
|
||||||
} else {
|
} else {
|
||||||
size = xsnprintf(hdr, sizeof hdr,
|
size = xsnprintf(hdr, sizeof hdr,
|
||||||
"(%d/%d results) [%u/%u]", data->searchthis,
|
"(%d/%d results) [%u/%u]", data->searchthis,
|
||||||
|
Loading…
Reference in New Issue
Block a user