mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
e25926d3c4
@ -68,9 +68,10 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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)
|
||||
@ -141,10 +142,15 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
|
||||
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);
|
||||
|
63
cmd-queue.c
63
cmd-queue.c
@ -825,68 +825,7 @@ cmdq_guard(struct cmdq_item *item, const char *guard, int flags)
|
||||
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. */
|
||||
|
2
menu.c
2
menu.c
@ -64,6 +64,8 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
|
||||
line = (item == NULL || item->name == NULL || *item->name == '\0');
|
||||
if (line && menu->count == 0)
|
||||
return;
|
||||
if (line && menu->items[menu->count - 1].name == NULL)
|
||||
return;
|
||||
|
||||
menu->items = xreallocarray(menu->items, menu->count + 1,
|
||||
sizeof *menu->items);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <vis.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@ -3240,3 +3241,69 @@ server_client_remove_pane(struct window_pane *wp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
4
tmux.1
4
tmux.1
@ -6630,6 +6630,10 @@ The window's visible layout is
|
||||
.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
|
||||
|
1
tmux.h
1
tmux.h
@ -2680,6 +2680,7 @@ struct client_window *server_client_add_client_window(struct client *, u_int);
|
||||
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 *);
|
||||
|
Loading…
Reference in New Issue
Block a user