summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-08-14 08:51:54 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-08-14 08:51:54 +0000
commitceb0febbf7366d592fd86c245af2aa37825075fc (patch)
tree3cfd5957b6401903bd3622b839febd277896c5f7 /usr.bin
parentf42d95ecf548405292b659dbd2074126b0a043d8 (diff)
Use a separate define for each default format template and strip clutter
from the choose-tree defaults.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-break-pane.c4
-rw-r--r--usr.bin/tmux/cmd-choose-buffer.c4
-rw-r--r--usr.bin/tmux/cmd-choose-client.c4
-rw-r--r--usr.bin/tmux/cmd-choose-tree.c12
-rw-r--r--usr.bin/tmux/cmd-display-message.c4
-rw-r--r--usr.bin/tmux/cmd-find-window.c4
-rw-r--r--usr.bin/tmux/cmd-list-buffers.c4
-rw-r--r--usr.bin/tmux/cmd-list-clients.c4
-rw-r--r--usr.bin/tmux/cmd-list-sessions.c4
-rw-r--r--usr.bin/tmux/cmd-list-windows.c8
-rw-r--r--usr.bin/tmux/cmd-new-window.c4
-rw-r--r--usr.bin/tmux/cmd-split-window.c4
-rw-r--r--usr.bin/tmux/tmux.h62
13 files changed, 79 insertions, 43 deletions
diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c
index 51cf84ec1b7..715b8ce5b84 100644
--- a/usr.bin/tmux/cmd-break-pane.c
+++ b/usr.bin/tmux/cmd-break-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-break-pane.c,v 1.16 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-break-pane.c,v 1.17 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -95,7 +95,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_PANE_INFO_TEMPLATE;
+ template = BREAK_PANE_TEMPLATE;
ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL)
diff --git a/usr.bin/tmux/cmd-choose-buffer.c b/usr.bin/tmux/cmd-choose-buffer.c
index 848de832af9..026a77fe520 100644
--- a/usr.bin/tmux/cmd-choose-buffer.c
+++ b/usr.bin/tmux/cmd-choose-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-buffer.c,v 1.9 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-choose-buffer.c,v 1.10 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -59,7 +59,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_BUFFER_LIST_TEMPLATE;
+ template = CHOOSE_BUFFER_TEMPLATE;
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
diff --git a/usr.bin/tmux/cmd-choose-client.c b/usr.bin/tmux/cmd-choose-client.c
index c844632a7f4..31789b0f886 100644
--- a/usr.bin/tmux/cmd-choose-client.c
+++ b/usr.bin/tmux/cmd-choose-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-client.c,v 1.11 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-choose-client.c,v 1.12 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -70,7 +70,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (CMD_RETURN_NORMAL);
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_CLIENT_TEMPLATE;
+ template = CHOOSE_CLIENT_TEMPLATE;
if (args->argc != 0)
action = xstrdup(args->argv[0]);
diff --git a/usr.bin/tmux/cmd-choose-tree.c b/usr.bin/tmux/cmd-choose-tree.c
index 4ed2f34d42b..ab5b5fca999 100644
--- a/usr.bin/tmux/cmd-choose-tree.c
+++ b/usr.bin/tmux/cmd-choose-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-tree.c,v 1.6 2012/08/11 06:46:47 nicm Exp $ */
+/* $OpenBSD: cmd-choose-tree.c,v 1.7 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2012 Thomas Adam <thomas@xteddy.org>
@@ -27,8 +27,6 @@
#define CMD_CHOOSE_TREE_WINDOW_ACTION "select-window -t '%%'"
#define CMD_CHOOSE_TREE_SESSION_ACTION "switch-client -t '%%'"
-#define CMD_CHOOSE_TREE_WINDOW_TEMPLATE \
- DEFAULT_WINDOW_TEMPLATE " \"#{pane_title}\""
/*
* Enter choice mode to choose a session and/or window.
@@ -104,7 +102,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
if (self->entry == &cmd_choose_session_entry) {
sflag = 1;
if ((ses_template = args_get(args, 'F')) == NULL)
- ses_template = DEFAULT_SESSION_TEMPLATE;
+ ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
if (args->argc != 0)
ses_action = args->argv[0];
@@ -113,7 +111,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
} else if (self->entry == &cmd_choose_window_entry) {
wflag = 1;
if ((win_template = args_get(args, 'F')) == NULL)
- win_template = CMD_CHOOSE_TREE_WINDOW_TEMPLATE;
+ win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
if (args->argc != 0)
win_action = args->argv[0];
@@ -130,10 +128,10 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
win_action = CMD_CHOOSE_TREE_WINDOW_ACTION;
if ((ses_template = args_get(args, 'S')) == NULL)
- ses_template = DEFAULT_SESSION_TEMPLATE;
+ ses_template = CHOOSE_TREE_SESSION_TEMPLATE;
if ((win_template = args_get(args, 'W')) == NULL)
- win_template = CMD_CHOOSE_TREE_WINDOW_TEMPLATE;
+ win_template = CHOOSE_TREE_WINDOW_TEMPLATE;
}
/*
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c
index 784e278c15c..65ecd6c73f2 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.15 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-display-message.c,v 1.16 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -76,7 +76,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args->argc != 0)
template = args->argv[0];
if (template == NULL)
- template = DEFAULT_DISPLAY_MESSAGE_TEMPLATE;
+ template = DISPLAY_MESSAGE_TEMPLATE;
ft = format_create();
format_client(ft, c);
diff --git a/usr.bin/tmux/cmd-find-window.c b/usr.bin/tmux/cmd-find-window.c
index 7bbd5cb7f49..a7a0ddd276c 100644
--- a/usr.bin/tmux/cmd-find-window.c
+++ b/usr.bin/tmux/cmd-find-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find-window.c,v 1.17 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-find-window.c,v 1.18 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -98,7 +98,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return (CMD_RETURN_ERROR);
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_FIND_WINDOW_TEMPLATE;
+ template = FIND_WINDOW_TEMPLATE;
match_flags = cmd_find_window_match_flags(args);
str = args->argv[0];
diff --git a/usr.bin/tmux/cmd-list-buffers.c b/usr.bin/tmux/cmd-list-buffers.c
index aed200c0cf7..eba64fc4c55 100644
--- a/usr.bin/tmux/cmd-list-buffers.c
+++ b/usr.bin/tmux/cmd-list-buffers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-buffers.c,v 1.14 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-list-buffers.c,v 1.15 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -51,7 +51,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
const char *template;
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_BUFFER_LIST_TEMPLATE;
+ template = LIST_BUFFERS_TEMPLATE;
idx = 0;
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) {
diff --git a/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c
index db6a0275540..a8ae46fd6fa 100644
--- a/usr.bin/tmux/cmd-list-clients.c
+++ b/usr.bin/tmux/cmd-list-clients.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-clients.c,v 1.12 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-list-clients.c,v 1.13 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -60,7 +60,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
s = NULL;
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_CLIENT_TEMPLATE;
+ template = LIST_CLIENTS_TEMPLATE;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
diff --git a/usr.bin/tmux/cmd-list-sessions.c b/usr.bin/tmux/cmd-list-sessions.c
index ac17d6e853b..6f2c758e3be 100644
--- a/usr.bin/tmux/cmd-list-sessions.c
+++ b/usr.bin/tmux/cmd-list-sessions.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-sessions.c,v 1.13 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-list-sessions.c,v 1.14 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -51,7 +51,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
char *line;
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_SESSION_TEMPLATE;
+ template = LIST_SESSIONS_TEMPLATE;
n = 0;
RB_FOREACH(s, sessions, &sessions) {
diff --git a/usr.bin/tmux/cmd-list-windows.c b/usr.bin/tmux/cmd-list-windows.c
index c03e2d370e7..2848faa07a9 100644
--- a/usr.bin/tmux/cmd-list-windows.c
+++ b/usr.bin/tmux/cmd-list-windows.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-windows.c,v 1.23 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-list-windows.c,v 1.24 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -85,12 +85,10 @@ cmd_list_windows_session(
if (template == NULL) {
switch (type) {
case 0:
- template = DEFAULT_WINDOW_TEMPLATE \
- " [layout #{window_layout}] #{window_id}" \
- "#{?window_active, (active),}";
+ template = LIST_WINDOWS_TEMPLATE;
break;
case 1:
- template = "#{session_name}:" DEFAULT_WINDOW_TEMPLATE;
+ template = LIST_WINDOWS_WITH_SESSION_TEMPLATE;
break;
}
}
diff --git a/usr.bin/tmux/cmd-new-window.c b/usr.bin/tmux/cmd-new-window.c
index 21bd7279a73..b1b1fa60f03 100644
--- a/usr.bin/tmux/cmd-new-window.c
+++ b/usr.bin/tmux/cmd-new-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-new-window.c,v 1.26 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-new-window.c,v 1.27 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -123,7 +123,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_PANE_INFO_TEMPLATE;
+ template = NEW_WINDOW_TEMPLATE;
ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL)
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index 7ab9ee4f907..4f0218c8e1f 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.35 2012/07/11 07:10:15 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.36 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -140,7 +140,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (args_has(args, 'P')) {
if ((template = args_get(args, 'F')) == NULL)
- template = DEFAULT_PANE_INFO_TEMPLATE;
+ template = SPLIT_WINDOW_TEMPLATE;
ft = format_create();
if ((c = cmd_find_client(ctx, NULL)) != NULL)
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 1efa224fdd4..27791c72803 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.350 2012/08/11 06:45:33 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.351 2012/08/14 08:51:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -92,34 +92,74 @@ extern char **environ;
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
-/* Default format templates. */
-#define DEFAULT_BUFFER_LIST_TEMPLATE \
+/* Default template for choose-buffer. */
+#define CHOOSE_BUFFER_TEMPLATE \
"#{line}: #{buffer_size} bytes: \"#{buffer_sample}\""
-#define DEFAULT_CLIENT_TEMPLATE \
+
+/* Default template for choose-client. */
+#define CHOOSE_CLIENT_TEMPLATE \
"#{client_tty}: #{session_name} " \
"[#{client_width}x#{client_height} #{client_termname}]" \
"#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
-#define DEFAULT_DISPLAY_MESSAGE_TEMPLATE \
+
+/* Default templates for choose-tree. */
+#define CHOOSE_TREE_SESSION_TEMPLATE \
+ "#{session_name}: #{session_windows} windows " \
+ "#{?session_grouped, (group ,}" \
+ "#{session_group}#{?session_grouped,),}" \
+ "#{?session_attached, (attached),}"
+#define CHOOSE_TREE_WINDOW_TEMPLATE \
+ "#{window_index}: #{window_name}#{window_flags} " \
+ "\"#{pane_title}\""
+
+/* Default template for display-message. */
+#define DISPLAY_MESSAGE_TEMPLATE \
"[#{session_name}] #{window_index}:" \
"#{window_name}, current pane #{pane_index} " \
"- (%H:%M %d-%b-%y)"
-#define DEFAULT_FIND_WINDOW_TEMPLATE \
+
+/* Default template for find-window. */
+#define FIND_WINDOW_TEMPLATE \
"#{window_index}: #{window_name} " \
"[#{window_width}x#{window_height}] " \
"(#{window_panes} panes) #{window_find_matches}"
-#define DEFAULT_SESSION_TEMPLATE \
+
+/* Default template for list-buffers. */
+#define LIST_BUFFERS_TEMPLATE \
+ "#{line}: #{buffer_size} bytes: \"#{buffer_sample}\""
+
+/* Default template for list-clients. */
+#define LIST_CLIENTS_TEMPLATE \
+ "#{client_tty}: #{session_name} " \
+ "[#{client_width}x#{client_height} #{client_termname}]" \
+ "#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
+
+/* Default template for list-sessions. */
+#define LIST_SESSIONS_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 \
+
+/* Default templates for list-windows. */
+#define LIST_WINDOWS_TEMPLATE \
"#{window_index}: #{window_name}#{window_flags} " \
"(#{window_panes} panes) " \
- "[#{window_width}x#{window_height}]"
-#define DEFAULT_PANE_INFO_TEMPLATE \
- "#{session_name}:#{window_index}.#{pane_index}"
+ "[#{window_width}x#{window_height}] " \
+ "[layout #{window_layout}] #{window_id}" \
+ "#{?window_active, (active),}";
+#define LIST_WINDOWS_WITH_SESSION_TEMPLATE \
+ "#{session_name}: " \
+ "#{window_index}: #{window_name}#{window_flags} " \
+ "(#{window_panes} panes) " \
+ "[#{window_width}x#{window_height}] "
+
+/* Default templates for break-pane, new-window and split-window. */
+#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
+#define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
+#define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
/* Bell option values. */
#define BELL_NONE 0