diff options
author | 2017-03-24 07:14:27 +0000 | |
---|---|---|
committer | 2017-03-24 07:14:27 +0000 | |
commit | 77f2227a764dacd3e77b39d4684398c1e9af2f09 (patch) | |
tree | b8b5944a182022b98b96c81cdcf67d8de20789f7 | |
parent | Add "supported targets" in lld --help output to be compatible with what (diff) | |
download | wireguard-openbsd-77f2227a764dacd3e77b39d4684398c1e9af2f09.tar.xz wireguard-openbsd-77f2227a764dacd3e77b39d4684398c1e9af2f09.zip |
Show count of search results in copy mode.
-rw-r--r-- | usr.bin/tmux/colour.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 32 |
2 files changed, 30 insertions, 6 deletions
diff --git a/usr.bin/tmux/colour.c b/usr.bin/tmux/colour.c index 188285ecc4b..3097c3c218c 100644 --- a/usr.bin/tmux/colour.c +++ b/usr.bin/tmux/colour.c @@ -1,4 +1,4 @@ -/* $OpenBSD: colour.c,v 1.14 2016/07/15 00:42:56 nicm Exp $ */ +/* $OpenBSD: colour.c,v 1.15 2017/03/24 07:14:27 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -48,7 +48,7 @@ colour_to_6cube(int v) * map our RGB colour to the closest in the cube, also work out the closest * grey, and use the nearest of the two. * - * Note that the xterm has much lower resolution for darker colors (they are + * Note that the xterm has much lower resolution for darker colours (they are * not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f * (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more * evenly spread (8, 18, 28 ... 238). diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index e0e755945e8..eaaaa75c195 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.169 2017/03/21 09:51:00 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.170 2017/03/24 07:14:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); |