-/* $OpenBSD: cmd-display-message.c,v 1.62 2022/11/03 08:33:57 nicm Exp $ */
+/* $OpenBSD: cmd-display-message.c,v 1.63 2023/02/05 21:15:32 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
struct window_pane *wp = target->wp;
const char *template;
char *msg, *cause;
- int delay = -1, flags;
+ int delay = -1, flags, Nflag = args_has(args, 'N');
struct format_tree *ft;
u_int count = args_count(args);
+ struct evbuffer *evb;
if (args_has(args, 'I')) {
if (wp == NULL)
cmdq_error(item, "%s", msg);
else if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
- else if (tc != NULL) {
- status_message_set(tc, delay, 0, args_has(args, 'N'), "%s",
- msg);
- }
+ else if (tc != NULL && (tc->flags & CLIENT_CONTROL)) {
+ evb = evbuffer_new();
+ if (evb == NULL)
+ fatalx("out of memory");
+ evbuffer_add_printf(evb, "%%message %s", msg);
+ server_client_print(tc, 0, evb);
+ evbuffer_free(evb);
+ } else if (tc != NULL)
+ status_message_set(tc, delay, 0, Nflag, "%s", msg);
free(msg);
format_free(ft);
-/* $OpenBSD: cmd-queue.c,v 1.113 2023/01/03 11:43:24 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.114 2023/02/05 21:15:32 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
void
cmdq_print_data(struct cmdq_item *item, int parse, struct evbuffer *evb)
{
- struct client *c = item->client;
- void *data = EVBUFFER_DATA(evb);
- size_t size = EVBUFFER_LENGTH(evb);
- struct window_pane *wp;
- struct window_mode_entry *wme;
- char *sanitized, *msg, *line;
-
- if (!parse) {
- utf8_stravisx(&msg, data, size,
- VIS_OCTAL|VIS_CSTYLE|VIS_NOSLASH);
- log_debug("%s: %s", __func__, msg);
- } else {
- msg = EVBUFFER_DATA(evb);
- if (msg[size - 1] != '\0')
- evbuffer_add(evb, "", 1);
- }
-
- if (c == NULL)
- goto out;
-
- if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
- if (~c->flags & CLIENT_UTF8) {
- sanitized = utf8_sanitize(msg);
- if (c->flags & CLIENT_CONTROL)
- control_write(c, "%s", sanitized);
- else
- file_print(c, "%s\n", sanitized);
- free(sanitized);
- } else {
- if (c->flags & CLIENT_CONTROL)
- control_write(c, "%s", msg);
- else
- file_print(c, "%s\n", msg);
- }
- goto out;
- }
-
- wp = server_client_get_pane(c);
- wme = TAILQ_FIRST(&wp->modes);
- if (wme == NULL || wme->mode != &window_view_mode)
- window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
- if (parse) {
- do {
- line = evbuffer_readln(evb, NULL, EVBUFFER_EOL_LF);
- if (line != NULL) {
- window_copy_add(wp, 1, "%s", line);
- free(line);
- }
- } while (line != NULL);
-
- size = EVBUFFER_LENGTH(evb);
- if (size != 0) {
- line = EVBUFFER_DATA(evb);
- window_copy_add(wp, 1, "%.*s", (int)size, line);
- }
- } else
- window_copy_add(wp, 0, "%s", msg);
-
-out:
- if (!parse)
- free(msg);
-
+ server_client_print(item->client, parse, evb);
}
/* Show message from command. */
-/* $OpenBSD: server-client.c,v 1.399 2023/01/16 11:26:14 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.400 2023/02/05 21:15:32 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <vis.h>
#include "tmux.h"
}
}
}
+
+/* Print to a client. */
+void
+server_client_print(struct client *c, int parse, struct evbuffer *evb)
+{
+ void *data = EVBUFFER_DATA(evb);
+ size_t size = EVBUFFER_LENGTH(evb);
+ struct window_pane *wp;
+ struct window_mode_entry *wme;
+ char *sanitized, *msg, *line;
+
+ if (!parse) {
+ utf8_stravisx(&msg, data, size,
+ VIS_OCTAL|VIS_CSTYLE|VIS_NOSLASH);
+ log_debug("%s: %s", __func__, msg);
+ } else {
+ msg = EVBUFFER_DATA(evb);
+ if (msg[size - 1] != '\0')
+ evbuffer_add(evb, "", 1);
+ }
+
+ if (c == NULL)
+ goto out;
+
+ if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
+ if (~c->flags & CLIENT_UTF8) {
+ sanitized = utf8_sanitize(msg);
+ if (c->flags & CLIENT_CONTROL)
+ control_write(c, "%s", sanitized);
+ else
+ file_print(c, "%s\n", sanitized);
+ free(sanitized);
+ } else {
+ if (c->flags & CLIENT_CONTROL)
+ control_write(c, "%s", msg);
+ else
+ file_print(c, "%s\n", msg);
+ }
+ goto out;
+ }
+
+ wp = server_client_get_pane(c);
+ wme = TAILQ_FIRST(&wp->modes);
+ if (wme == NULL || wme->mode != &window_view_mode)
+ window_pane_set_mode(wp, NULL, &window_view_mode, NULL, NULL);
+ if (parse) {
+ do {
+ line = evbuffer_readln(evb, NULL, EVBUFFER_EOL_LF);
+ if (line != NULL) {
+ window_copy_add(wp, 1, "%s", line);
+ free(line);
+ }
+ } while (line != NULL);
+
+ size = EVBUFFER_LENGTH(evb);
+ if (size != 0) {
+ line = EVBUFFER_DATA(evb);
+ window_copy_add(wp, 1, "%.*s", (int)size, line);
+ }
+ } else
+ window_copy_add(wp, 0, "%s", msg);
+
+out:
+ if (!parse)
+ free(msg);
+}
-.\" $OpenBSD: tmux.1,v 1.913 2023/01/23 09:33:51 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.914 2023/02/05 21:15:33 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" 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: January 23 2023 $
+.Dd $Mdocdate: February 5 2023 $
.Dt TMUX 1
.Os
.Sh NAME
.Ar window-visible-layout
and the window flags are
.Ar window-flags .
+.It Ic %message Ar message
+A message sent with the
+.Ic display-message
+command.
.It Ic %output Ar pane-id Ar value
A window pane produced output.
.Ar value
-/* $OpenBSD: tmux.h,v 1.1193 2023/01/20 21:36:00 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1194 2023/02/05 21:15:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
struct window_pane *server_client_get_pane(struct client *);
void server_client_set_pane(struct client *, struct window_pane *);
void server_client_remove_pane(struct window_pane *);
+void server_client_print(struct client *, int, struct evbuffer *);
/* server-fn.c */
void server_redraw_client(struct client *);