Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2022-10-28 16:01:10 +01:00
commit 9dd1f442c5
6 changed files with 36 additions and 21 deletions

View File

@ -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);
}
}

11
input.c
View File

@ -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);

View File

@ -152,6 +152,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);
@ -306,10 +308,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);
}
}

12
paste.c
View File

@ -150,7 +150,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);
@ -209,7 +209,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. */
@ -257,8 +257,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);
}
@ -308,7 +308,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);
}
@ -321,7 +321,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. */

4
tmux.1
View File

@ -6615,6 +6615,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

3
tmux.h
View File

@ -2164,7 +2164,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 *);
@ -3187,6 +3187,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;