Replace the notification system with events. Events can carry a payload of

additional payload (to reduce problems with lifetime of objects) and are
delivered to one or more event sinks. This is more powerful and reduces the
complex dependencies between control mode and hooks. Events are now used for
hooks, control mode notifications and for monitors (set-hook -B).

wait-for can now wait for an event to fire (-E flag, with -F to for filter),
with -v to print the payload, as well as listing (-l) waiting clients on an
event and forcing one to wake (-w).

A few additional hooks are also now available (pane-created, pane-resized, etc)
and some of the existing ones have additional format variables available.
This commit is contained in:
nicm
2026-07-10 13:38:45 +00:00
parent 1508bec957
commit d29aa12117
153 changed files with 2543 additions and 1787 deletions

24
paste.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */
/* $OpenBSD: paste.c,v 1.53 2026/07/10 13:38:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -44,6 +44,16 @@ static int paste_cmp_times(const struct paste_buffer *,
const struct paste_buffer *);
RB_GENERATE_STATIC(paste_time_tree, paste_buffer, time_entry, paste_cmp_times);
static void
paste_fire_event(const char *name, const char *pbname)
{
struct event_payload *ep;
ep = event_payload_create();
event_payload_set_string(ep, "paste_buffer", "%s", pbname);
events_fire(name, ep);
}
static int
paste_cmp_names(const struct paste_buffer *a, const struct paste_buffer *b)
{
@@ -138,7 +148,7 @@ paste_get_name(const char *name)
void
paste_free(struct paste_buffer *pb)
{
notify_paste_buffer(pb->name, 1);
paste_fire_event("paste-buffer-deleted", pb->name);
RB_REMOVE(paste_name_tree, &paste_by_name, pb);
RB_REMOVE(paste_time_tree, &paste_by_time, pb);
@@ -196,7 +206,7 @@ paste_add(const char *prefix, char *data, size_t size)
RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb);
notify_paste_buffer(pb->name, 0);
paste_fire_event("paste-buffer-changed", pb->name);
}
/* Rename a paste buffer. */
@@ -254,8 +264,8 @@ paste_rename(const char *oldname, const char *newname, char **cause)
RB_INSERT(paste_name_tree, &paste_by_name, pb);
notify_paste_buffer(oldname, 1);
notify_paste_buffer(pb->name, 0);
paste_fire_event("paste-buffer-deleted", oldname);
paste_fire_event("paste-buffer-changed", pb->name);
return (0);
}
@@ -312,7 +322,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb);
notify_paste_buffer(pb->name, 0);
paste_fire_event("paste-buffer-changed", pb->name);
return (0);
}
@@ -325,7 +335,7 @@ paste_replace(struct paste_buffer *pb, char *data, size_t size)
pb->data = data;
pb->size = size;
notify_paste_buffer(pb->name, 0);
paste_fire_event("paste-buffer-changed", pb->name);
}
/* Convert start of buffer into a nice string. */