summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/window-buffer.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-06-09 16:01:39 +0000
committernicm <nicm@openbsd.org>2017-06-09 16:01:39 +0000
commit024c311a845aceb9006eee42585000674918f9dc (patch)
tree87ce14a59c122a9f1f89daf60fa0106908dfbee8 /usr.bin/tmux/window-buffer.c
parentCorrect number of players, the program enforces a range from 2 to 9. (diff)
downloadwireguard-openbsd-024c311a845aceb9006eee42585000674918f9dc.tar.xz
wireguard-openbsd-024c311a845aceb9006eee42585000674918f9dc.zip
Extend filters (f key) to buffer and client mode and add -f flag to
specify to command.
Diffstat (limited to 'usr.bin/tmux/window-buffer.c')
-rw-r--r--usr.bin/tmux/window-buffer.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.bin/tmux/window-buffer.c b/usr.bin/tmux/window-buffer.c
index 12995e64695..8aab9f051cc 100644
--- a/usr.bin/tmux/window-buffer.c
+++ b/usr.bin/tmux/window-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-buffer.c,v 1.7 2017/06/09 15:29:15 nicm Exp $ */
+/* $OpenBSD: window-buffer.c,v 1.8 2017/06/09 16:01:39 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -125,14 +125,15 @@ window_buffer_cmp_size(const void *a0, const void *b0)
}
static void
-window_buffer_build(void *modedata, u_int sort_type, __unused uint64_t *tag)
+window_buffer_build(void *modedata, u_int sort_type, __unused uint64_t *tag,
+ const char *filter)
{
struct window_buffer_modedata *data = modedata;
struct window_buffer_itemdata *item;
u_int i;
struct paste_buffer *pb;
- char *tim;
- char *text;
+ char *tim, *text, *cp;
+ struct format_tree *ft;
for (i = 0; i < data->item_size; i++)
window_buffer_free_item(data->item_list[i]);
@@ -167,6 +168,22 @@ window_buffer_build(void *modedata, u_int sort_type, __unused uint64_t *tag)
for (i = 0; i < data->item_size; i++) {
item = data->item_list[i];
+ if (filter != NULL) {
+ pb = paste_get_name(item->name);
+ if (pb == NULL)
+ continue;
+ ft = format_create(NULL, NULL, FORMAT_NONE, 0);
+ format_defaults_paste_buffer(ft, pb);
+ cp = format_expand(ft, filter);
+ if (!format_true(cp)) {
+ free(cp);
+ format_free(ft);
+ continue;
+ }
+ free(cp);
+ format_free(ft);
+ }
+
tim = ctime(&item->created);
*strchr(tim, '\n') = '\0';