summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-05-16 15:54:21 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-05-16 15:54:21 +0000
commitef694b32fd2bc6693d9baff4d2af211a11714165 (patch)
tree21f8c7613c049a85542c0111f4b54b0319eabc25 /usr.bin
parent311969b5a86107ad1ec94ea14664ec4ab8d8b76b (diff)
Support embedded styles in the display-message message, GitHub issue
2206.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/alerts.c10
-rw-r--r--usr.bin/tmux/cmd-display-message.c4
-rw-r--r--usr.bin/tmux/cmd-list-keys.c4
-rw-r--r--usr.bin/tmux/cmd-queue.c4
-rw-r--r--usr.bin/tmux/mode-tree.c4
-rw-r--r--usr.bin/tmux/status.c10
-rw-r--r--usr.bin/tmux/tmux.h6
7 files changed, 25 insertions, 17 deletions
diff --git a/usr.bin/tmux/alerts.c b/usr.bin/tmux/alerts.c
index d220008ed54..98170ddc717 100644
--- a/usr.bin/tmux/alerts.c
+++ b/usr.bin/tmux/alerts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alerts.c,v 1.29 2017/12/28 12:10:50 nicm Exp $ */
+/* $OpenBSD: alerts.c,v 1.30 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -316,8 +316,10 @@ alerts_set_message(struct winlink *wl, const char *type, const char *option)
if (visual == VISUAL_OFF)
continue;
if (c->session->curw == wl)
- status_message_set(c, "%s in current window", type);
- else
- status_message_set(c, "%s in window %d", type, wl->idx);
+ status_message_set(c, 1, "%s in current window", type);
+ else {
+ status_message_set(c, 1, "%s in window %d", type,
+ wl->idx);
+ }
}
}
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c
index f3e6900239b..bca113f3ef3 100644
--- a/usr.bin/tmux/cmd-display-message.c
+++ b/usr.bin/tmux/cmd-display-message.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-message.c,v 1.53 2020/04/13 20:51:57 nicm Exp $ */
+/* $OpenBSD: cmd-display-message.c,v 1.54 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -117,7 +117,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
else if (tc != NULL)
- status_message_set(tc, "%s", msg);
+ status_message_set(tc, 0, "%s", msg);
free(msg);
format_free(ft);
diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c
index c6c1ed57eff..d61d8c682fc 100644
--- a/usr.bin/tmux/cmd-list-keys.c
+++ b/usr.bin/tmux/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-keys.c,v 1.56 2020/04/13 20:51:57 nicm Exp $ */
+/* $OpenBSD: cmd-list-keys.c,v 1.57 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -112,7 +112,7 @@ cmd_list_keys_print_notes(struct cmdq_item *item, struct args *args,
note = xstrdup(bd->note);
tmp = utf8_padcstr(key, keywidth + 1);
if (args_has(args, '1') && tc != NULL)
- status_message_set(tc, "%s%s%s", prefix, tmp, note);
+ status_message_set(tc, 1, "%s%s%s", prefix, tmp, note);
else
cmdq_print(item, "%s%s%s", prefix, tmp, note);
free(tmp);
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index f4e5a3a5b13..3e3fb6216fc 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.93 2020/05/16 15:47:22 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.94 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -856,7 +856,7 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
c->retval = 1;
} else {
*msg = toupper((u_char) *msg);
- status_message_set(c, "%s", msg);
+ status_message_set(c, 1, "%s", msg);
}
free(msg);
diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c
index 36e447cf00d..1169238398e 100644
--- a/usr.bin/tmux/mode-tree.c
+++ b/usr.bin/tmux/mode-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-tree.c,v 1.44 2020/05/16 15:46:01 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.45 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1110,7 +1110,7 @@ mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
if (status == CMD_PARSE_ERROR) {
if (c != NULL) {
*error = toupper((u_char)*error);
- status_message_set(c, "%s", error);
+ status_message_set(c, 1, "%s", error);
}
free(error);
}
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 3e0f0157af0..73d6845fcfe 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.209 2020/05/16 15:47:22 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.210 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -423,7 +423,7 @@ status_redraw(struct client *c)
/* Set a status line message. */
void
-status_message_set(struct client *c, const char *fmt, ...)
+status_message_set(struct client *c, int ignore_styles, const char *fmt, ...)
{
struct timeval tv;
va_list ap;
@@ -433,6 +433,7 @@ status_message_set(struct client *c, const char *fmt, ...)
status_push_screen(c);
va_start(ap, fmt);
+ c->message_ignore_styles = ignore_styles;
xvasprintf(&c->message_string, fmt, ap);
va_end(ap);
@@ -515,7 +516,10 @@ status_message_redraw(struct client *c)
for (offset = 0; offset < c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
screen_write_cursormove(&ctx, 0, lines - 1, 0);
- screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
+ if (c->message_ignore_styles)
+ screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
+ else
+ format_draw(&ctx, &gc, c->tty.sx, c->message_string, NULL);
screen_write_stop(&ctx);
if (grid_compare(sl->active->grid, old_screen.grid) == 0) {
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 17674a7fff4..a115c6503dd 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1035 2020/05/16 15:49:20 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1036 2020/05/16 15:54:20 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1603,6 +1603,7 @@ struct client {
uint64_t redraw_panes;
+ int message_ignore_styles;
char *message_string;
struct event message_timer;
@@ -2340,7 +2341,8 @@ struct style_range *status_get_range(struct client *, u_int, u_int);
void status_init(struct client *);
void status_free(struct client *);
int status_redraw(struct client *);
-void printflike(2, 3) status_message_set(struct client *, const char *, ...);
+void printflike(3, 4) status_message_set(struct client *, int, const char *,
+ ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
void status_prompt_set(struct client *, const char *, const char *,