Switch all of the various choose- and list- commands over to the format

infrastructure, from Thomas Adam.
This commit is contained in:
Nicholas Marriott 2012-05-22 11:35:37 +00:00
parent 682884edc5
commit ebf94bc9cb
16 changed files with 211 additions and 112 deletions

View File

@ -93,9 +93,10 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
server_status_session_group(s); server_status_session_group(s);
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
template = "#{session_name}:#{window_index}";
if (args_has(args, 'F')) if ((template = args_get(args, 'F')) == NULL)
template = args_get(args, 'F'); template = DEFAULT_PANE_INFO_TEMPLATE;
ft = format_create(); ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL) if ((c = cmd_find_client(ctx, NULL)) != NULL)
format_client(ft, c); format_client(ft, c);

View File

@ -33,8 +33,8 @@ void cmd_choose_buffer_free(void *);
const struct cmd_entry cmd_choose_buffer_entry = { const struct cmd_entry cmd_choose_buffer_entry = {
"choose-buffer", NULL, "choose-buffer", NULL,
"t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL, NULL,
NULL, NULL,
@ -53,14 +53,19 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_choose_buffer_data *cdata; struct cmd_choose_buffer_data *cdata;
struct winlink *wl; struct winlink *wl;
struct paste_buffer *pb; struct paste_buffer *pb;
struct format_tree *ft;
u_int idx; u_int idx;
char *tmp; char *line;
const char *template;
if (ctx->curclient == NULL) { if (ctx->curclient == NULL) {
ctx->error(ctx, "must be run interactively"); ctx->error(ctx, "must be run interactively");
return (-1); return (-1);
} }
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_BUFFER_LIST_TEMPLATE;
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
return (-1); return (-1);
@ -72,10 +77,15 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
idx = 0; idx = 0;
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) { while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
tmp = paste_print(pb, 50); ft = format_create();
window_choose_add(wl->window->active, idx - 1, format_add(ft, "line", "%u", idx - 1);
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); format_paste_buffer(ft, pb);
xfree(tmp);
line = format_expand(ft, template);
window_choose_add(wl->window->active, idx - 1, "%s", line);
xfree(line);
format_free(ft);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -33,8 +33,8 @@ void cmd_choose_client_free(void *);
const struct cmd_entry cmd_choose_client_entry = { const struct cmd_entry cmd_choose_client_entry = {
"choose-client", NULL, "choose-client", NULL,
"t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL, NULL,
NULL, NULL,
@ -51,8 +51,11 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct args *args = self->args; struct args *args = self->args;
struct cmd_choose_client_data *cdata; struct cmd_choose_client_data *cdata;
struct format_tree *ft;
struct winlink *wl; struct winlink *wl;
struct client *c; struct client *c;
char *line;
const char *template;
u_int i, idx, cur; u_int i, idx, cur;
if (ctx->curclient == NULL) { if (ctx->curclient == NULL) {
@ -66,6 +69,9 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return (0); return (0);
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_CLIENT_TEMPLATE;
cur = idx = 0; cur = idx = 0;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i); c = ARRAY_ITEM(&clients, i);
@ -75,12 +81,16 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
cur = idx; cur = idx;
idx++; idx++;
window_choose_add(wl->window->active, i, ft = format_create();
"%s: %s [%ux%u %s]%s%s", c->tty.path, format_add(ft, "line", "%u", i);
c->session->name, c->tty.sx, c->tty.sy, format_session(ft, c->session);
c->tty.termname, format_client(ft, c);
c->tty.flags & TTY_UTF8 ? " (utf8)" : "",
c->flags & CLIENT_READONLY ? " (ro)" : ""); line = format_expand(ft, template);
window_choose_add(wl->window->active, i, "%s", line);
xfree(line);
format_free(ft);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -33,8 +33,8 @@ void cmd_choose_session_free(void *);
const struct cmd_entry cmd_choose_session_entry = { const struct cmd_entry cmd_choose_session_entry = {
"choose-session", NULL, "choose-session", NULL,
"t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL, NULL,
NULL, NULL,
@ -53,9 +53,10 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_choose_session_data *cdata; struct cmd_choose_session_data *cdata;
struct winlink *wl; struct winlink *wl;
struct session *s; struct session *s;
struct session_group *sg; struct format_tree *ft;
u_int idx, sgidx, cur; const char *template;
char tmp[64]; char *line;
u_int idx, cur;
if (ctx->curclient == NULL) { if (ctx->curclient == NULL) {
ctx->error(ctx, "must be run interactively"); ctx->error(ctx, "must be run interactively");
@ -68,24 +69,24 @@ cmd_choose_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return (0); return (0);
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_SESSION_TEMPLATE;
cur = idx = 0; cur = idx = 0;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {
if (s == ctx->curclient->session) if (s == ctx->curclient->session)
cur = idx; cur = idx;
idx++; idx++;
sg = session_group_find(s); ft = format_create();
if (sg == NULL) format_add(ft, "line", "%u", idx);
*tmp = '\0'; format_session(ft, s);
else {
sgidx = session_group_index(sg);
xsnprintf(tmp, sizeof tmp, " (group %u)", sgidx);
}
window_choose_add(wl->window->active, s->idx, line = format_expand(ft, template);
"%s: %u windows [%ux%u]%s%s", s->name, window_choose_add(wl->window->active, s->idx, "%s", line);
winlink_count(&s->windows), s->sx, s->sy, xfree(line);
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)");
format_free(ft);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -33,8 +33,8 @@ void cmd_choose_window_free(void *);
const struct cmd_entry cmd_choose_window_entry = { const struct cmd_entry cmd_choose_window_entry = {
"choose-window", NULL, "choose-window", NULL,
"t:", 0, 1, "F:t:", 0, 1,
CMD_TARGET_WINDOW_USAGE " [template]", CMD_TARGET_WINDOW_USAGE " [-F format] [template]",
0, 0,
NULL, NULL,
NULL, NULL,
@ -54,10 +54,10 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_choose_window_data *cdata; struct cmd_choose_window_data *cdata;
struct session *s; struct session *s;
struct winlink *wl, *wm; struct winlink *wl, *wm;
struct window *w; struct format_tree *ft;
const char *template;
char *line;
u_int idx, cur; u_int idx, cur;
char *flags, *title;
const char *left, *right;
if (ctx->curclient == NULL) { if (ctx->curclient == NULL) {
ctx->error(ctx, "must be run interactively"); ctx->error(ctx, "must be run interactively");
@ -71,30 +71,25 @@ cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
return (0); return (0);
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_WINDOW_TEMPLATE;
cur = idx = 0; cur = idx = 0;
RB_FOREACH(wm, winlinks, &s->windows) { RB_FOREACH(wm, winlinks, &s->windows) {
w = wm->window;
if (wm == s->curw) if (wm == s->curw)
cur = idx; cur = idx;
idx++; idx++;
flags = window_printable_flags(s, wm); ft = format_create();
title = w->active->screen->title; format_add(ft, "line", "%u", idx);
if (wm == wl) format_session(ft, s);
title = w->active->base.title; format_winlink(ft, s, wm);
left = " \"";
right = "\"";
if (*title == '\0')
left = right = "";
window_choose_add(wl->window->active, line = format_expand(ft, template);
wm->idx, "%3d: %s%s [%ux%u] (%u panes%s)%s%s%s", window_choose_add(wl->window->active, idx, "%s", line);
wm->idx, w->name, flags, w->sx, w->sy, window_count_panes(w),
w->active->fd == -1 ? ", dead" : "",
left, title, right);
xfree(flags); xfree(line);
format_free(ft);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -75,7 +75,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args->argc != 0) if (args->argc != 0)
template = args->argv[0]; template = args->argv[0];
if (template == NULL) if (template == NULL)
template = "[#S] #I:#W, current pane #P - (%H:%M %d-%b-%y)"; template = DEFAULT_DISPLAY_MESSAGE_TEMPLATE;
ft = format_create(); ft = format_create();
format_client(ft, c); format_client(ft, c);

View File

@ -46,8 +46,8 @@ void cmd_find_window_free(void *);
const struct cmd_entry cmd_find_window_entry = { const struct cmd_entry cmd_find_window_entry = {
"find-window", "findw", "find-window", "findw",
"CNt:T", 1, 4, "F:CNt:T", 1, 4,
"[-CNT] " CMD_TARGET_WINDOW_USAGE " match-string", "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string",
0, 0,
NULL, NULL,
NULL, NULL,
@ -85,11 +85,13 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
struct cmd_find_window_data *cdata; struct cmd_find_window_data *cdata;
struct session *s; struct session *s;
struct winlink *wl, *wm; struct winlink *wl, *wm;
struct window *w;
struct window_pane *wp; struct window_pane *wp;
struct format_tree *ft;
ARRAY_DECL(, u_int) list_idx; ARRAY_DECL(, u_int) list_idx;
ARRAY_DECL(, char *) list_ctx; ARRAY_DECL(, char *) list_ctx;
char *str, *sres, *sctx, *searchstr; char *str, *sres, *sctx, *searchstr;
char *find_line;
const char *template;
u_int i, line, match_flags; u_int i, line, match_flags;
if (ctx->curclient == NULL) { if (ctx->curclient == NULL) {
@ -101,6 +103,9 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
return (-1); return (-1);
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_FIND_WINDOW_TEMPLATE;
match_flags = cmd_find_window_match_flags(args); match_flags = cmd_find_window_match_flags(args);
str = args->argv[0]; str = args->argv[0];
@ -167,13 +172,20 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
for (i = 0; i < ARRAY_LENGTH(&list_idx); i++) { for (i = 0; i < ARRAY_LENGTH(&list_idx); i++) {
wm = winlink_find_by_index( wm = winlink_find_by_index(
&s->windows, ARRAY_ITEM(&list_idx, i)); &s->windows, ARRAY_ITEM(&list_idx, i));
w = wm->window;
sctx = ARRAY_ITEM(&list_ctx, i); ft = format_create();
window_choose_add(wl->window->active, format_add(ft, "line", "%u", i);
wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name, format_add(ft, "window_find_matches", "%s",
w->sx, w->sy, window_count_panes(w), sctx); ARRAY_ITEM(&list_ctx, i));
xfree(sctx); format_session(ft, s);
format_winlink(ft, s, wm);
find_line = format_expand(ft, template);
window_choose_add(wl->window->active, wm->idx, "%s", find_line);
xfree(find_line);
format_free(ft);
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -30,8 +30,8 @@ int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_buffers_entry = { const struct cmd_entry cmd_list_buffers_entry = {
"list-buffers", "lsb", "list-buffers", "lsb",
"", 0, 0, "F:", 0, 0,
"", "[-F format]",
0, 0,
NULL, NULL,
NULL, NULL,
@ -42,16 +42,27 @@ const struct cmd_entry cmd_list_buffers_entry = {
int int
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx) cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
{ {
struct args *args = self->args;
struct paste_buffer *pb; struct paste_buffer *pb;
struct format_tree *ft;
u_int idx; u_int idx;
char *tmp; char *line;
const char *template;
if ((template = args_get(args, 'F')) == NULL)
template = DEFAULT_BUFFER_LIST_TEMPLATE;
idx = 0; idx = 0;
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) { while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
tmp = paste_print(pb, 50); ft = format_create();
ctx->print(ctx, format_add(ft, "line", "%u", idx - 1);
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); format_paste_buffer(ft, pb);
xfree(tmp);
line = format_expand(ft, template);
ctx->print(ctx, "%s", line);
xfree(line);
format_free(ft);
} }
return (0); return (0);

View File

@ -58,13 +58,8 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
} else } else
s = NULL; s = NULL;
template = args_get(args, 'F'); if ((template = args_get(args, 'F')) == NULL)
if (template == NULL) { template = DEFAULT_CLIENT_TEMPLATE;
template = "#{client_tty}: #{session_name} "
"[#{client_width}x#{client_height} #{client_termname}]"
"#{?client_utf8, (utf8),}"
"#{?client_readonly, (ro),}";
}
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i); c = ARRAY_ITEM(&clients, i);

View File

@ -49,14 +49,8 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
const char *template; const char *template;
char *line; char *line;
template = args_get(args, 'F'); if ((template = args_get(args, 'F')) == NULL)
if (template == NULL) { template = DEFAULT_SESSION_TEMPLATE;
template = "#{session_name}: #{session_windows} windows "
"(created #{session_created_string}) [#{session_width}x"
"#{session_height}]#{?session_grouped, (group ,}"
"#{session_group}#{?session_grouped,),}"
"#{?session_attached, (attached),}";
}
n = 0; n = 0;
RB_FOREACH(s, sessions, &sessions) { RB_FOREACH(s, sessions, &sessions) {

View File

@ -34,7 +34,7 @@ void cmd_list_windows_session(
const struct cmd_entry cmd_list_windows_entry = { const struct cmd_entry cmd_list_windows_entry = {
"list-windows", "lsw", "list-windows", "lsw",
"aF:t:", 0, 0, "F:at:", 0, 0,
"[-a] [-F format] " CMD_TARGET_SESSION_USAGE, "[-a] [-F format] " CMD_TARGET_SESSION_USAGE,
0, 0,
NULL, NULL,
@ -84,18 +84,10 @@ cmd_list_windows_session(
if (template == NULL) { if (template == NULL) {
switch (type) { switch (type) {
case 0: case 0:
template = "#{window_index}: " template = DEFAULT_WINDOW_TEMPLATE;
"#{window_name} "
"[#{window_width}x#{window_height}] "
"[layout #{window_layout}] #{window_id}"
"#{?window_active, (active),}";
break; break;
case 1: case 1:
template = "#{session_name}:#{window_index}: " template = "#{session_name}:" DEFAULT_WINDOW_TEMPLATE;
"#{window_name} "
"[#{window_width}x#{window_height}] "
"[layout #{window_layout}] #{window_id}"
"#{?window_active, (active),}";
break; break;
} }
} }

View File

@ -122,15 +122,15 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
server_status_session_group(s); server_status_session_group(s);
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
template = "#{session_name}:#{window_index}"; if ((template = args_get(args, 'F')) == NULL)
if (args_has(args, 'F')) template = DEFAULT_PANE_INFO_TEMPLATE;
template = args_get(args, 'F');
ft = format_create(); ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL) if ((c = cmd_find_client(ctx, NULL)) != NULL)
format_client(ft, c); format_client(ft, c);
format_session(ft, s); format_session(ft, s);
format_winlink(ft, s, wl); format_winlink(ft, s, wl);
format_window_pane(ft, wl->window->active);
cp = format_expand(ft, template); cp = format_expand(ft, template);
ctx->print(ctx, "%s", cp); ctx->print(ctx, "%s", cp);

View File

@ -139,9 +139,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
environ_free(&env); environ_free(&env);
if (args_has(args, 'P')) { if (args_has(args, 'P')) {
template = "#{session_name}:#{window_index}.#{pane_index}"; if ((template = args_get(args, 'F')) == NULL)
if (args_has(args, 'F')) template = DEFAULT_PANE_INFO_TEMPLATE;
template = args_get(args, 'F');
ft = format_create(); ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL) if ((c = cmd_find_client(ctx, NULL)) != NULL)

View File

@ -349,6 +349,7 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
format_add(ft, "window_flags", "%s", flags); format_add(ft, "window_flags", "%s", flags);
format_add(ft, "window_layout", "%s", layout); format_add(ft, "window_layout", "%s", layout);
format_add(ft, "window_active", "%d", wl == s->curw); format_add(ft, "window_active", "%d", wl == s->curw);
format_add(ft, "window_panes", "%u", window_count_panes(w));
xfree(flags); xfree(flags);
xfree(layout); xfree(layout);
@ -393,3 +394,14 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "pane_pid", "%ld", (long) wp->pid); format_add(ft, "pane_pid", "%ld", (long) wp->pid);
format_add(ft, "pane_tty", "%s", wp->tty); format_add(ft, "pane_tty", "%s", wp->tty);
} }
void
format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb)
{
char *pb_print = paste_print(pb, 50);
format_add(ft, "buffer_size", "%zu", pb->size);
format_add(ft, "buffer_sample", "%s", pb_print);
xfree(pb_print);
}

51
tmux.1
View File

@ -1033,6 +1033,7 @@ visible pane and negative numbers are lines in the history.
The default is to capture only the visible contents of the pane. The default is to capture only the visible contents of the pane.
.It Xo .It Xo
.Ic choose-client .Ic choose-client
.Op Fl F Ar format
.Op Fl t Ar target-window .Op Fl t Ar target-window
.Op Ar template .Op Ar template
.Xc .Xc
@ -1048,10 +1049,16 @@ and the result executed as a command.
If If
.Ar template .Ar template
is not given, "detach-client -t '%%'" is used. is not given, "detach-client -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only from inside This command works only from inside
.Nm . .Nm .
.It Xo .It Xo
.Ic choose-session .Ic choose-session
.Op Fl F Ar format
.Op Fl t Ar target-window .Op Fl t Ar target-window
.Op Ar template .Op Ar template
.Xc .Xc
@ -1065,10 +1072,16 @@ and the result executed as a command.
If If
.Ar template .Ar template
is not given, "switch-client -t '%%'" is used. is not given, "switch-client -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only from inside This command works only from inside
.Nm . .Nm .
.It Xo .It Xo
.Ic choose-window .Ic choose-window
.Op Fl F Ar format
.Op Fl t Ar target-window .Op Fl t Ar target-window
.Op Ar template .Op Ar template
.Xc .Xc
@ -1082,6 +1095,11 @@ and the result executed as a command.
If If
.Ar template .Ar template
is not given, "select-window -t '%%'" is used. is not given, "select-window -t '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only from inside This command works only from inside
.Nm . .Nm .
.It Ic display-panes Op Fl t Ar target-client .It Ic display-panes Op Fl t Ar target-client
@ -1101,6 +1119,7 @@ to
keys. keys.
.It Xo Ic find-window .It Xo Ic find-window
.Op Fl CNT .Op Fl CNT
.Op Fl F Ar format
.Op Fl t Ar target-window .Op Fl t Ar target-window
.Ar match-string .Ar match-string
.Xc .Xc
@ -1121,6 +1140,11 @@ The default is
.Fl CNT . .Fl CNT .
If only one window is matched, it'll be automatically selected, If only one window is matched, it'll be automatically selected,
otherwise a choice list is shown. otherwise a choice list is shown.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command only works from inside This command only works from inside
.Nm . .Nm .
.It Xo Ic join-pane .It Xo Ic join-pane
@ -2761,13 +2785,7 @@ or the global window options if
is used. is used.
.El .El
.Sh FORMATS .Sh FORMATS
The Certain commands accept the
.Ic list-clients ,
.Ic list-sessions ,
.Ic list-windows
and
.Ic list-panes
commands accept the
.Fl F .Fl F
flag with a flag with a
.Ar format .Ar format
@ -2800,6 +2818,8 @@ if it is unattached.
The following variables are available, where appropriate: The following variables are available, where appropriate:
.Bl -column "session_created_string" "Replaced with" -offset indent .Bl -column "session_created_string" "Replaced with" -offset indent
.It Sy "Variable name" Ta Sy "Replaced with" .It Sy "Variable name" Ta Sy "Replaced with"
.It Li "buffer_sample" Ta "First 50 characters from the specified buffer"
.It Li "buffer_size" Ta "Size of the specified buffer in bytes"
.It Li "client_activity" Ta "Integer time client last had activity" .It Li "client_activity" Ta "Integer time client last had activity"
.It Li "client_activity_string" Ta "String time client last had activity" .It Li "client_activity_string" Ta "String time client last had activity"
.It Li "client_created" Ta "Integer time client created" .It Li "client_created" Ta "Integer time client created"
@ -2834,11 +2854,13 @@ The following variables are available, where appropriate:
.It Li "session_width" Ta "Width of session" .It Li "session_width" Ta "Width of session"
.It Li "session_windows" Ta "Number of windows in session" .It Li "session_windows" Ta "Number of windows in session"
.It Li "window_active" Ta "1 if window active" .It Li "window_active" Ta "1 if window active"
.It Li "window_find_matches" Ta "Matched data from the find-window command if available"
.It Li "window_flags" Ta "Window flags" .It Li "window_flags" Ta "Window flags"
.It Li "window_height" Ta "Height of window" .It Li "window_height" Ta "Height of window"
.It Li "window_index" Ta "Index of window" .It Li "window_index" Ta "Index of window"
.It Li "window_layout" Ta "Window layout description" .It Li "window_layout" Ta "Window layout description"
.It Li "window_name" Ta "Name of window" .It Li "window_name" Ta "Name of window"
.It Li "window_panes" Ta "Number of panes in window"
.It Li "window_width" Ta "Width of window" .It Li "window_width" Ta "Width of window"
.El .El
.Sh NAMES AND TITLES .Sh NAMES AND TITLES
@ -3145,6 +3167,7 @@ The buffer commands are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Xo .It Xo
.Ic choose-buffer .Ic choose-buffer
.Op Fl F Ar format
.Op Fl t Ar target-window .Op Fl t Ar target-window
.Op Ar template .Op Ar template
.Xc .Xc
@ -3158,6 +3181,11 @@ and the result executed as a command.
If If
.Ar template .Ar template
is not given, "paste-buffer -b '%%'" is used. is not given, "paste-buffer -b '%%'" is used.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
This command works only from inside This command works only from inside
.Nm . .Nm .
.It Ic clear-history Op Fl t Ar target-pane .It Ic clear-history Op Fl t Ar target-pane
@ -3168,9 +3196,16 @@ Remove and free the history for the specified pane.
Delete the buffer at Delete the buffer at
.Ar buffer-index , .Ar buffer-index ,
or the top buffer if not specified. or the top buffer if not specified.
.It Ic list-buffers .It Xo Ic list-buffers
.Op Fl F Ar format
.Xc
.D1 (alias: Ic lsb ) .D1 (alias: Ic lsb )
List the global buffers. List the global buffers.
For the meaning of the
.Fl F
flag, see the
.Sx FORMATS
section.
.It Xo Ic load-buffer .It Xo Ic load-buffer
.Op Fl b Ar buffer-index .Op Fl b Ar buffer-index
.Ar path .Ar path

32
tmux.h
View File

@ -92,6 +92,37 @@ extern char **environ;
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif #endif
/* Default format templates. */
#define DEFAULT_BUFFER_LIST_TEMPLATE \
"#{line}: #{buffer_size} bytes: \"#{buffer_sample}\""
#define DEFAULT_CLIENT_TEMPLATE \
"#{client_tty}: #{session_name} " \
"[#client_width}x#{client_height} #{client_termname}]" \
"{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
#define DEFAULT_DISPLAY_MESSAGE_TEMPLATE \
"[#{session_name}] #{window_index}:" \
"#{window_name}, current pane #{pane_index} " \
"- (%H:%M %d-%b-%y)"
#define DEFAULT_FIND_WINDOW_TEMPLATE \
"#{window_index}: #{window_name} " \
"[#{window_width}x#{window_height}] " \
"(#{window_panes} panes) #{window_find_matches}"
#define DEFAULT_SESSION_TEMPLATE \
"#{session_name}: #{session_windows} windows " \
"(created #{session_created_string}) " \
"[#{session_width}x#{session_height}]" \
"#{?session_grouped, (group ,}" \
"#{session_group}#{?session_grouped,),}" \
"#{?session_attached, (attached),}"
#define DEFAULT_WINDOW_TEMPLATE \
"#{window_index}: #{window_name}#{window_flags} " \
"(#{window_panes} panes) " \
"[#{window_width}x#{window_height}] " \
"[layout #{window_layout}] #{window_id}" \
"#{?window_active, (active),}"
#define DEFAULT_PANE_INFO_TEMPLATE \
"#{session_name}:#{window_index}.#{pane_index}"
/* Bell option values. */ /* Bell option values. */
#define BELL_NONE 0 #define BELL_NONE 0
#define BELL_ANY 1 #define BELL_ANY 1
@ -1406,6 +1437,7 @@ void format_client(struct format_tree *, struct client *);
void format_winlink( void format_winlink(
struct format_tree *, struct session *, struct winlink *); struct format_tree *, struct session *, struct winlink *);
void format_window_pane(struct format_tree *, struct window_pane *); void format_window_pane(struct format_tree *, struct window_pane *);
void format_paste_buffer(struct format_tree *, struct paste_buffer *);
/* mode-key.c */ /* mode-key.c */
extern const struct mode_key_table mode_key_tables[]; extern const struct mode_key_table mode_key_tables[];