Merge branch 'obsd-master'

pull/3307/head
Thomas Adam 2022-08-15 13:54:47 +01:00
commit 9c34aad21c
10 changed files with 99 additions and 43 deletions

View File

@ -234,3 +234,16 @@ control_notify_session_window_changed(struct session *s)
s->curw->window->id);
}
}
void
control_notify_paste_buffer_changed(const char *name)
{
struct client *c;
TAILQ_FOREACH(c, &clients, entry) {
if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
continue;
control_write(c, "%%paste-changed %s", name);
}
}

View File

@ -182,9 +182,11 @@ void
environ_update(struct options *oo, struct environ *src, struct environ *dst)
{
struct environ_entry *envent;
struct environ_entry *envent1;
struct options_entry *o;
struct options_array_item *a;
union options_value *ov;
int found;
o = options_get(oo, "update-environment");
if (o == NULL)
@ -192,14 +194,15 @@ environ_update(struct options *oo, struct environ *src, struct environ *dst)
a = options_array_first(o);
while (a != NULL) {
ov = options_array_item_value(a);
RB_FOREACH(envent, environ, src) {
if (fnmatch(ov->string, envent->name, 0) == 0)
break;
found = 0;
RB_FOREACH_SAFE(envent, environ, src, envent1) {
if (fnmatch(ov->string, envent->name, 0) == 0) {
environ_set(dst, envent->name, 0, "%s", envent->value);
found = 1;
}
}
if (envent == NULL)
if (!found)
environ_clear(dst, ov->string);
else
environ_set(dst, envent->name, 0, "%s", envent->value);
a = options_array_next(a);
}
}

View File

@ -344,7 +344,7 @@ key_bindings_init_done(__unused struct cmdq_item *item, __unused void *data)
void
key_bindings_init(void)
{
static const char *defaults[] = {
static const char *const defaults[] = {
/* Prefix keys. */
"bind -N 'Send the prefix key' C-b { send-prefix }",
"bind -N 'Rotate through the panes' C-o { rotate-window }",

View File

@ -32,6 +32,7 @@ struct notify_entry {
struct session *session;
struct window *window;
int pane;
const char *pbname;
};
static struct cmdq_item *
@ -149,6 +150,8 @@ notify_callback(struct cmdq_item *item, void *data)
control_notify_session_closed(ne->session);
if (strcmp(ne->name, "session-window-changed") == 0)
control_notify_session_window_changed(ne->session);
if (strcmp(ne->name, "paste-buffer-changed") == 0)
control_notify_paste_buffer_changed(ne->pbname);
notify_insert_hook(item, ne);
@ -164,6 +167,7 @@ notify_callback(struct cmdq_item *item, void *data)
format_free(ne->formats);
free((void *)ne->name);
free((void *)ne->pbname);
free(ne);
return (CMD_RETURN_NORMAL);
@ -171,7 +175,8 @@ notify_callback(struct cmdq_item *item, void *data)
static void
notify_add(const char *name, struct cmd_find_state *fs, struct client *c,
struct session *s, struct window *w, struct window_pane *wp)
struct session *s, struct window *w, struct window_pane *wp,
const char *pbname)
{
struct notify_entry *ne;
struct cmdq_item *item;
@ -187,6 +192,7 @@ notify_add(const char *name, struct cmd_find_state *fs, struct client *c,
ne->session = s;
ne->window = w;
ne->pane = (wp != NULL ? wp->id : -1);
ne->pbname = (pbname != NULL ? xstrdup(pbname) : NULL);
ne->formats = format_create(NULL, NULL, 0, FORMAT_NOJOBS);
format_add(ne->formats, "hook", "%s", name);
@ -248,7 +254,7 @@ notify_client(const char *name, struct client *c)
struct cmd_find_state fs;
cmd_find_from_client(&fs, c, 0);
notify_add(name, &fs, c, NULL, NULL, NULL);
notify_add(name, &fs, c, NULL, NULL, NULL, NULL);
}
void
@ -260,7 +266,7 @@ notify_session(const char *name, struct session *s)
cmd_find_from_session(&fs, s, 0);
else
cmd_find_from_nothing(&fs, 0);
notify_add(name, &fs, NULL, s, NULL, NULL);
notify_add(name, &fs, NULL, s, NULL, NULL, NULL);
}
void
@ -269,7 +275,7 @@ notify_winlink(const char *name, struct winlink *wl)
struct cmd_find_state fs;
cmd_find_from_winlink(&fs, wl, 0);
notify_add(name, &fs, NULL, wl->session, wl->window, NULL);
notify_add(name, &fs, NULL, wl->session, wl->window, NULL, NULL);
}
void
@ -278,7 +284,7 @@ notify_session_window(const char *name, struct session *s, struct window *w)
struct cmd_find_state fs;
cmd_find_from_session_window(&fs, s, w, 0);
notify_add(name, &fs, NULL, s, w, NULL);
notify_add(name, &fs, NULL, s, w, NULL, NULL);
}
void
@ -287,7 +293,7 @@ notify_window(const char *name, struct window *w)
struct cmd_find_state fs;
cmd_find_from_window(&fs, w, 0);
notify_add(name, &fs, NULL, NULL, w, NULL);
notify_add(name, &fs, NULL, NULL, w, NULL, NULL);
}
void
@ -296,5 +302,14 @@ notify_pane(const char *name, struct window_pane *wp)
struct cmd_find_state fs;
cmd_find_from_pane(&fs, wp, 0);
notify_add(name, &fs, NULL, NULL, NULL, wp);
notify_add(name, &fs, NULL, NULL, NULL, wp, NULL);
}
void
notify_paste_buffer(const char *pbname)
{
struct cmd_find_state fs;
cmd_find_clear_state(&fs, 0);
notify_add("paste-buffer-changed", &fs, NULL, NULL, NULL, NULL, pbname);
}

11
paste.c
View File

@ -150,6 +150,8 @@ paste_get_name(const char *name)
void
paste_free(struct paste_buffer *pb)
{
notify_paste_buffer(pb->name);
RB_REMOVE(paste_name_tree, &paste_by_name, pb);
RB_REMOVE(paste_time_tree, &paste_by_time, pb);
if (pb->automatic)
@ -206,6 +208,8 @@ paste_add(const char *prefix, char *data, size_t size)
pb->order = paste_next_order++;
RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb);
notify_paste_buffer(pb->name);
}
/* Rename a paste buffer. */
@ -253,6 +257,9 @@ 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);
return (0);
}
@ -301,6 +308,8 @@ 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);
return (0);
}
@ -311,6 +320,8 @@ paste_replace(struct paste_buffer *pb, char *data, size_t size)
free(pb->data);
pb->data = data;
pb->size = size;
notify_paste_buffer(pb->name);
}
/* Convert start of buffer into a nice string. */

8
tmux.1
View File

@ -6433,6 +6433,10 @@ These are set automatically if the
capability is present.
.It Em \&Hls
Set or clear a hyperlink annotation.
.It Em \&Nobr
Tell
.Nm
that the terminal does not use bright colors for bold display.
.It Em \&Rect
Tell
.Nm
@ -6595,6 +6599,10 @@ escapes non-printable characters and backslash as octal \\xxx.
The pane with ID
.Ar pane-id
has changed mode.
.It Ic %paste-buffer-changed Ar name
Paste buffer
.Ar name
has been changed.
.It Ic %pause Ar pane-id
The pane has been paused (if the
.Ar pause-after

3
tmux.h
View File

@ -515,6 +515,7 @@ enum tty_code_code {
TTYC_KUP6,
TTYC_KUP7,
TTYC_MS,
TTYC_NOBR,
TTYC_OL,
TTYC_OP,
TTYC_RECT,
@ -2154,6 +2155,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 *);
/* options.c */
struct options *options_create(struct options *);
@ -3175,6 +3177,7 @@ void control_notify_session_renamed(struct session *);
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 *);
/* session.c */
extern struct sessions sessions;

View File

@ -42,13 +42,13 @@
/* A named terminal feature. */
struct tty_feature {
const char *name;
const char **capabilities;
int flags;
const char *name;
const char *const *capabilities;
int flags;
};
/* Terminal has xterm(1) title setting. */
static const char *tty_feature_title_capabilities[] = {
static const char *const tty_feature_title_capabilities[] = {
"tsl=\\E]0;", /* should be using TS really */
"fsl=\\a",
NULL
@ -60,7 +60,7 @@ static const struct tty_feature tty_feature_title = {
};
/* Terminal has OSC 7 working directory. */
static const char *tty_feature_osc7_capabilities[] = {
static const char *const tty_feature_osc7_capabilities[] = {
"Swd=\\E]7;",
"fsl=\\a",
NULL
@ -72,7 +72,7 @@ static const struct tty_feature tty_feature_osc7 = {
};
/* Terminal has mouse support. */
static const char *tty_feature_mouse_capabilities[] = {
static const char *const tty_feature_mouse_capabilities[] = {
"kmous=\\E[M",
NULL
};
@ -83,7 +83,7 @@ static const struct tty_feature tty_feature_mouse = {
};
/* Terminal can set the clipboard with OSC 52. */
static const char *tty_feature_clipboard_capabilities[] = {
static const char *const tty_feature_clipboard_capabilities[] = {
"Ms=\\E]52;%p1%s;%p2%s\\a",
NULL
};
@ -113,7 +113,7 @@ static const struct tty_feature tty_feature_hyperlinks = {
* terminals with RGB have versions that do not allow setting colours from the
* 256 palette.
*/
static const char *tty_feature_rgb_capabilities[] = {
static const char *const tty_feature_rgb_capabilities[] = {
"AX",
"setrgbf=\\E[38;2;%p1%d;%p2%d;%p3%dm",
"setrgbb=\\E[48;2;%p1%d;%p2%d;%p3%dm",
@ -128,7 +128,7 @@ static const struct tty_feature tty_feature_rgb = {
};
/* Terminal supports 256 colours. */
static const char *tty_feature_256_capabilities[] = {
static const char *const tty_feature_256_capabilities[] = {
"AX",
"setab=\\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
"setaf=\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
@ -141,7 +141,7 @@ static const struct tty_feature tty_feature_256 = {
};
/* Terminal supports overline. */
static const char *tty_feature_overline_capabilities[] = {
static const char *const tty_feature_overline_capabilities[] = {
"Smol=\\E[53m",
NULL
};
@ -152,7 +152,7 @@ static const struct tty_feature tty_feature_overline = {
};
/* Terminal supports underscore styles. */
static const char *tty_feature_usstyle_capabilities[] = {
static const char *const tty_feature_usstyle_capabilities[] = {
"Smulx=\\E[4::%p1%dm",
"Setulc=\\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m",
"ol=\\E[59m",
@ -165,7 +165,7 @@ static const struct tty_feature tty_feature_usstyle = {
};
/* Terminal supports bracketed paste. */
static const char *tty_feature_bpaste_capabilities[] = {
static const char *const tty_feature_bpaste_capabilities[] = {
"Enbp=\\E[?2004h",
"Dsbp=\\E[?2004l",
NULL
@ -177,7 +177,7 @@ static const struct tty_feature tty_feature_bpaste = {
};
/* Terminal supports focus reporting. */
static const char *tty_feature_focus_capabilities[] = {
static const char *const tty_feature_focus_capabilities[] = {
"Enfcs=\\E[?1004h",
"Dsfcs=\\E[?1004l",
NULL
@ -189,7 +189,7 @@ static const struct tty_feature tty_feature_focus = {
};
/* Terminal supports cursor styles. */
static const char *tty_feature_cstyle_capabilities[] = {
static const char *const tty_feature_cstyle_capabilities[] = {
"Ss=\\E[%p1%d q",
"Se=\\E[2 q",
NULL
@ -201,7 +201,7 @@ static const struct tty_feature tty_feature_cstyle = {
};
/* Terminal supports cursor colours. */
static const char *tty_feature_ccolour_capabilities[] = {
static const char *const tty_feature_ccolour_capabilities[] = {
"Cs=\\E]12;%p1%s\\a",
"Cr=\\E]112\\a",
NULL
@ -213,7 +213,7 @@ static const struct tty_feature tty_feature_ccolour = {
};
/* Terminal supports strikethrough. */
static const char *tty_feature_strikethrough_capabilities[] = {
static const char *const tty_feature_strikethrough_capabilities[] = {
"smxx=\\E[9m",
NULL
};
@ -224,7 +224,7 @@ static const struct tty_feature tty_feature_strikethrough = {
};
/* Terminal supports synchronized updates. */
static const char *tty_feature_sync_capabilities[] = {
static const char *const tty_feature_sync_capabilities[] = {
"Sync=\\EP=%p1%ds\\E\\\\",
NULL
};
@ -235,7 +235,7 @@ static const struct tty_feature tty_feature_sync = {
};
/* Terminal supports extended keys. */
static const char *tty_feature_extkeys_capabilities[] = {
static const char *const tty_feature_extkeys_capabilities[] = {
"Eneks=\\E[>4;1m",
"Dseks=\\E[>4m",
NULL
@ -247,7 +247,7 @@ static const struct tty_feature tty_feature_extkeys = {
};
/* Terminal supports DECSLRM margins. */
static const char *tty_feature_margins_capabilities[] = {
static const char *const tty_feature_margins_capabilities[] = {
"Enmg=\\E[?69h",
"Dsmg=\\E[?69l",
"Clmg=\\E[s",
@ -261,7 +261,7 @@ static const struct tty_feature tty_feature_margins = {
};
/* Terminal supports DECFRA rectangle fill. */
static const char *tty_feature_rectfill_capabilities[] = {
static const char *const tty_feature_rectfill_capabilities[] = {
"Rect",
NULL
};
@ -272,7 +272,7 @@ static const struct tty_feature tty_feature_rectfill = {
};
/* Use builtin function keys only. */
static const char *tty_feature_ignorefkeys_capabilities[] = {
static const char *const tty_feature_ignorefkeys_capabilities[] = {
"kf0@",
"kf1@",
"kf2@",
@ -346,7 +346,7 @@ static const struct tty_feature tty_feature_ignorefkeys = {
};
/* Available terminal features. */
static const struct tty_feature *tty_features[] = {
static const struct tty_feature *const tty_features[] = {
&tty_feature_256,
&tty_feature_bpaste,
&tty_feature_ccolour,
@ -420,9 +420,9 @@ tty_get_features(int feat)
int
tty_apply_features(struct tty_term *term, int feat)
{
const struct tty_feature *tf;
const char **capability;
u_int i;
const struct tty_feature *tf;
const char *const *capability;
u_int i;
if (feat == 0)
return (0);
@ -453,7 +453,7 @@ tty_apply_features(struct tty_term *term, int feat)
void
tty_default_features(int *feat, const char *name, u_int version)
{
static struct {
static const struct {
const char *name;
u_int version;
const char *features;

View File

@ -250,6 +250,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
[TTYC_KUP6] = { TTYCODE_STRING, "kUP6" },
[TTYC_KUP7] = { TTYCODE_STRING, "kUP7" },
[TTYC_MS] = { TTYCODE_STRING, "Ms" },
[TTYC_NOBR] = { TTYCODE_STRING, "Nobr" },
[TTYC_OL] = { TTYCODE_STRING, "ol" },
[TTYC_OP] = { TTYCODE_STRING, "op" },
[TTYC_RECT] = { TTYCODE_STRING, "Rect" },

8
tty.c
View File

@ -2690,12 +2690,14 @@ tty_check_fg(struct tty *tty, struct colour_palette *palette,
/*
* Perform substitution if this pane has a palette. If the bright
* attribute is set, use the bright entry in the palette by changing to
* the aixterm colour.
* attribute is set and Nobr is not present, use the bright entry in
* the palette by changing to the aixterm colour
*/
if (~gc->flags & GRID_FLAG_NOPALETTE) {
c = gc->fg;
if (c < 8 && gc->attr & GRID_ATTR_BRIGHT)
if (c < 8 &&
gc->attr & GRID_ATTR_BRIGHT &&
!tty_term_has(tty->term, TTYC_NOBR))
c += 90;
if ((c = colour_palette_get(palette, c)) != -1)
gc->fg = c;