From: nicm Date: Fri, 28 Oct 2022 13:00:02 +0000 (+0000) Subject: Add paste-buffer-deleted notification and fix name of paste-buffer-changed. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=99acee14adedf06a250aaae2661fad6eb8f61e88;p=openbsd Add paste-buffer-deleted notification and fix name of paste-buffer-changed. --- diff --git a/usr.bin/tmux/control-notify.c b/usr.bin/tmux/control-notify.c index 3eab6d97a46..e181086bc91 100644 --- a/usr.bin/tmux/control-notify.c +++ b/usr.bin/tmux/control-notify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control-notify.c,v 1.30 2022/08/15 09:10:34 nicm Exp $ */ +/* $OpenBSD: control-notify.c,v 1.31 2022/10/28 13:00:02 nicm Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott @@ -244,6 +244,19 @@ control_notify_paste_buffer_changed(const char *name) if (!CONTROL_SHOULD_NOTIFY_CLIENT(c)) continue; - control_write(c, "%%paste-changed %s", name); + control_write(c, "%%paste-buffer-changed %s", name); + } +} + +void +control_notify_paste_buffer_deleted(const char *name) +{ + struct client *c; + + TAILQ_FOREACH(c, &clients, entry) { + if (!CONTROL_SHOULD_NOTIFY_CLIENT(c)) + continue; + + control_write(c, "%%paste-buffer-deleted %s", name); } } diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index a5974a7c555..6d2974c383f 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.210 2022/10/28 12:20:28 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.211 2022/10/28 13:00:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1755,7 +1755,6 @@ static void input_csi_dispatch_sm_private(struct input_ctx *ictx) { struct screen_write_ctx *sctx = &ictx->ctx; - struct window_pane *wp = ictx->wp; struct grid_cell *gc = &ictx->cell.cell; u_int i; diff --git a/usr.bin/tmux/notify.c b/usr.bin/tmux/notify.c index 18cee5c4f3f..8fc3704428d 100644 --- a/usr.bin/tmux/notify.c +++ b/usr.bin/tmux/notify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: notify.c,v 1.42 2022/08/15 09:10:34 nicm Exp $ */ +/* $OpenBSD: notify.c,v 1.43 2022/10/28 13:00:02 nicm Exp $ */ /* * Copyright (c) 2012 George Nachman @@ -153,6 +153,8 @@ notify_callback(struct cmdq_item *item, void *data) control_notify_session_window_changed(ne->session); if (strcmp(ne->name, "paste-buffer-changed") == 0) control_notify_paste_buffer_changed(ne->pbname); + if (strcmp(ne->name, "paste-buffer-deleted") == 0) + control_notify_paste_buffer_deleted(ne->pbname); notify_insert_hook(item, ne); @@ -307,10 +309,16 @@ notify_pane(const char *name, struct window_pane *wp) } void -notify_paste_buffer(const char *pbname) +notify_paste_buffer(const char *pbname, int deleted) { struct cmd_find_state fs; cmd_find_clear_state(&fs, 0); - notify_add("paste-buffer-changed", &fs, NULL, NULL, NULL, NULL, pbname); + if (deleted) { + notify_add("paste-buffer-deleted", &fs, NULL, NULL, NULL, NULL, + pbname); + } else { + notify_add("paste-buffer-changed", &fs, NULL, NULL, NULL, NULL, + pbname); + } } diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c index f50549cd233..ba4e6a5da71 100644 --- a/usr.bin/tmux/paste.c +++ b/usr.bin/tmux/paste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paste.c,v 1.44 2022/08/15 09:10:34 nicm Exp $ */ +/* $OpenBSD: paste.c,v 1.45 2022/10/28 13:00:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -151,7 +151,7 @@ paste_get_name(const char *name) void paste_free(struct paste_buffer *pb) { - notify_paste_buffer(pb->name); + notify_paste_buffer(pb->name, 1); RB_REMOVE(paste_name_tree, &paste_by_name, pb); RB_REMOVE(paste_time_tree, &paste_by_time, pb); @@ -210,7 +210,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); + notify_paste_buffer(pb->name, 0); } /* Rename a paste buffer. */ @@ -258,8 +258,8 @@ paste_rename(const char *oldname, const char *newname, char **cause) RB_INSERT(paste_name_tree, &paste_by_name, pb); - notify_paste_buffer(oldname); - notify_paste_buffer(newname); + notify_paste_buffer(oldname, 1); + notify_paste_buffer(newname, 0); return (0); } @@ -309,7 +309,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(name); + notify_paste_buffer(name, 0); return (0); } @@ -322,7 +322,7 @@ paste_replace(struct paste_buffer *pb, char *data, size_t size) pb->data = data; pb->size = size; - notify_paste_buffer(pb->name); + notify_paste_buffer(pb->name, 0); } /* Convert start of buffer into a nice string. */ diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 32a08a0ba92..5a2dcada717 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.903 2022/09/28 07:59:50 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.904 2022/10/28 13:00:02 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 28 2022 $ +.Dd $Mdocdate: October 28 2022 $ .Dt TMUX 1 .Os .Sh NAME @@ -6612,6 +6612,10 @@ has changed mode. Paste buffer .Ar name has been changed. +.It Ic %paste-buffer-deleted Ar name +Paste buffer +.Ar name +has been deleted. .It Ic %pause Ar pane-id The pane has been paused (if the .Ar pause-after diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 8b1405e0e7c..7c7dbd56080 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1182 2022/09/28 07:55:29 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1183 2022/10/28 13:00:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2163,7 +2163,7 @@ void notify_winlink(const char *, struct winlink *); void notify_session_window(const char *, struct session *, struct window *); void notify_window(const char *, struct window *); void notify_pane(const char *, struct window_pane *); -void notify_paste_buffer(const char *); +void notify_paste_buffer(const char *, int); /* options.c */ struct options *options_create(struct options *); @@ -3185,6 +3185,7 @@ void control_notify_session_created(struct session *); void control_notify_session_closed(struct session *); void control_notify_session_window_changed(struct session *); void control_notify_paste_buffer_changed(const char *); +void control_notify_paste_buffer_deleted(const char *); /* session.c */ extern struct sessions sessions;