summaryrefslogtreecommitdiffstats
path: root/window-copy.c
diff options
context:
space:
mode:
authornicm <nicm>2017-03-24 07:14:27 +0000
committernicm <nicm>2017-03-24 07:14:27 +0000
commit591b26e46f48f2e6b59f97e6cfb037c6fec48e15 (patch)
tree381f4245f61d6ad11994a7836044f77fbeea5dcc /window-copy.c
parentdf3ab87964fc52c6f44b2bbe014c8bec202d0528 (diff)
Show count of search results in copy mode.
Diffstat (limited to 'window-copy.c')
-rw-r--r--window-copy.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/window-copy.c b/window-copy.c
index 07129c5a..9b13926e 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -174,6 +174,8 @@ struct window_copy_mode_data {
int searchtype;
char *searchstr;
bitstr_t *searchmark;
+ u_int searchcount;
+ int searchthis;
int searchx;
int searchy;
int searcho;
@@ -1170,7 +1172,7 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
struct screen *s = data->backing, ss;
struct screen_write_ctx ctx;
struct grid *gd = s->grid;
- int found, cis;
+ int found, cis, which = -1;
u_int px, py, b, nfound = 0, width;
if (ssp == NULL) {
@@ -1196,7 +1198,10 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
px, gd->sx, cis);
if (!found)
break;
+
nfound++;
+ if (px == data->cx && py == gd->hsize + data->cy - data->oy)
+ which = nfound;
b = (py * gd->sx) + px;
bit_nset(data->searchmark, b, b + width - 1);
@@ -1205,6 +1210,12 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
}
}
+ if (which != -1)
+ data->searchthis = 1 + nfound - which;
+ else
+ data->searchthis = -1;
+ data->searchcount = nfound;
+
if (ssp == &ss)
screen_free(&ss);
return (nfound);
@@ -1262,8 +1273,21 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
gc.flags |= GRID_FLAG_NOPALETTE;
if (py == 0) {
- size = xsnprintf(hdr, sizeof hdr,
- "[%u/%u]", data->oy, screen_hsize(data->backing));
+ 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,
+ "(%u results) [%d/%u]", data->searchcount,
+ data->oy, screen_hsize(data->backing));
+ } else {
+ size = xsnprintf(hdr, sizeof hdr,
+ "(%u/%u results) [%d/%u]", data->searchthis,
+ data->searchcount, data->oy,
+ screen_hsize(data->backing));
+ }
+ }
if (size > screen_size_x(s))
size = screen_size_x(s);
screen_write_cursormove(ctx, screen_size_x(s) - size, 0);