aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2022-10-28 13:00:02 +0000
committernicm <nicm>2022-10-28 13:00:02 +0000
commit8edece2cdb7b4425526bae904506a246edbb6409 (patch)
treedeaaac60c890b8fd4e26913c21fcbfcf54c07508
parentc2580cfe2466589c8bd9348225820888a3fc4c0a (diff)
downloadrtmux-8edece2cdb7b4425526bae904506a246edbb6409.tar.gz
rtmux-8edece2cdb7b4425526bae904506a246edbb6409.tar.bz2
rtmux-8edece2cdb7b4425526bae904506a246edbb6409.zip
Add paste-buffer-deleted notification and fix name of paste-buffer-changed.
-rw-r--r--control-notify.c15
-rw-r--r--input.c11
-rw-r--r--notify.c12
-rw-r--r--paste.c12
-rw-r--r--tmux.14
-rw-r--r--tmux.h3
6 files changed, 36 insertions, 21 deletions
diff --git a/control-notify.c b/control-notify.c
index a252dd05..30f94194 100644
--- a/control-notify.c
+++ b/control-notify.c
@@ -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/input.c b/input.c
index 8b174769..779b9013 100644
--- a/input.c
+++ b/input.c
@@ -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;
@@ -1797,17 +1796,7 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
screen_write_mode_set(sctx, MODE_MOUSE_ALL);
break;
case 1004:
- if (sctx->s->mode & MODE_FOCUSON)
- break;
screen_write_mode_set(sctx, MODE_FOCUSON);
- if (wp == NULL)
- break;
- if (!options_get_number(global_options, "focus-events"))
- break;
- if (wp->flags & PANE_FOCUSED)
- bufferevent_write(wp->event, "\033[I", 3);
- else
- bufferevent_write(wp->event, "\033[O", 3);
break;
case 1005:
screen_write_mode_set(sctx, MODE_MOUSE_UTF8);
diff --git a/notify.c b/notify.c
index 03730b98..138fbeb1 100644
--- a/notify.c
+++ b/notify.c
@@ -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/paste.c b/paste.c
index 53477387..7565c207 100644
--- a/paste.c
+++ b/paste.c
@@ -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/tmux.1 b/tmux.1
index 5e896902..dbfc85b1 100644
--- a/tmux.1
+++ b/tmux.1
@@ -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/tmux.h b/tmux.h
index 77019edc..a0f9f461 100644
--- a/tmux.h
+++ b/tmux.h
@@ -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;