summaryrefslogtreecommitdiffstats
path: root/window-buffer.c
diff options
context:
space:
mode:
authornicm <nicm>2017-06-07 14:37:30 +0000
committernicm <nicm>2017-06-07 14:37:30 +0000
commit405cc337f35731614b37d7279ddfc3a5dc806694 (patch)
tree3f0962f6034f59e6cb6d09c4b8daaab180c517b9 /window-buffer.c
parent50b27c8c0dc65cb418ed422e2cdd035a7bafedfe (diff)
Add simple searching (C-s and n) to the various choose modes: by name
for client and tree, and by name and content for buffer.
Diffstat (limited to 'window-buffer.c')
-rw-r--r--window-buffer.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/window-buffer.c b/window-buffer.c
index 9c09c03f..db9d8a4f 100644
--- a/window-buffer.c
+++ b/window-buffer.c
@@ -227,6 +227,22 @@ window_buffer_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy)
return (&s);
}
+static int
+window_buffer_search(__unused void *modedata, void *itemdata, const char *ss)
+{
+ struct window_buffer_itemdata *item = itemdata;
+ struct paste_buffer *pb;
+ const char *bufdata;
+ size_t bufsize;
+
+ if ((pb = paste_get_name(item->name)) == NULL)
+ return (0);
+ if (strstr(item->name, ss) != NULL)
+ return (0);
+ bufdata = paste_buffer_data(pb, &bufsize);
+ return (memmem(bufdata, bufsize, ss, strlen(ss)) != NULL);
+}
+
static struct screen *
window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
struct args *args)
@@ -242,8 +258,8 @@ window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
data->command = xstrdup(args->argv[0]);
data->data = mode_tree_start(wp, window_buffer_build,
- window_buffer_draw, data, window_buffer_sort_list,
- nitems(window_buffer_sort_list), &s);
+ window_buffer_draw, window_buffer_search, data,
+ window_buffer_sort_list, nitems(window_buffer_sort_list), &s);
mode_tree_build(data->data);
mode_tree_draw(data->data);
@@ -312,7 +328,7 @@ window_buffer_key(struct window_pane *wp, struct client *c,
* Enter = paste buffer
*/
- finished = mode_tree_key(data->data, &key, m);
+ finished = mode_tree_key(data->data, c, &key, m);
switch (key) {
case 'd':
item = mode_tree_get_current(data->data);