summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-12-10 09:16:53 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-12-10 09:16:53 +0000
commit864a9954f2f11f85ca75e63be11507fbb7a0290c (patch)
tree88d1c713c81ac99fccff4e2a382c0df66f3ab0f4 /usr.bin
parent6680a8a4fbf96310b997d48bfb3a92d99fe2efa5 (diff)
Add "server options" which are server-wide and not bound to a session or
window. Set and displayed with "set -s" and "show -s". Currently the only option is "quiet" (like command-line -q, allowing it to be set from .tmux.conf), but others will come along.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-server-info.c6
-rw-r--r--usr.bin/tmux/cmd-set-option.c15
-rw-r--r--usr.bin/tmux/cmd-show-options.c11
-rw-r--r--usr.bin/tmux/key-bindings.c4
-rw-r--r--usr.bin/tmux/server-client.c4
-rw-r--r--usr.bin/tmux/tmux.189
-rw-r--r--usr.bin/tmux/tmux.c14
-rw-r--r--usr.bin/tmux/tmux.h4
8 files changed, 95 insertions, 52 deletions
diff --git a/usr.bin/tmux/cmd-server-info.c b/usr.bin/tmux/cmd-server-info.c
index ed307b83e68..0ea3559051d 100644
--- a/usr.bin/tmux/cmd-server-info.c
+++ b/usr.bin/tmux/cmd-server-info.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-server-info.c,v 1.17 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: cmd-server-info.c,v 1.18 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -70,8 +70,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
tim = ctime(&start_time);
*strchr(tim, '\n') = '\0';
ctx->print(ctx, "pid %ld, started %s", (long) getpid(), tim);
- ctx->print(ctx, "socket path %s, debug level %d%s",
- socket_path, debug_level, be_quiet ? ", quiet" : "");
+ ctx->print(
+ ctx, "socket path %s, debug level %d", socket_path, debug_level);
if (uname(&un) == 0) {
ctx->print(ctx, "system is %s %s %s %s",
un.sysname, un.release, un.version, un.machine);
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index 7ba726d3712..e5374ed2ce4 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-option.c,v 1.28 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.29 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -48,8 +48,8 @@ void cmd_set_option_choice(struct cmd_ctx *,
const struct cmd_entry cmd_set_option_entry = {
"set-option", "set",
- "[-aguw] [-t target-session|target-window] option [value]",
- CMD_ARG12, "aguw",
+ "[-agsuw] [-t target-session|target-window] option [value]",
+ CMD_ARG12, "agsuw",
NULL,
cmd_target_parse,
cmd_set_option_exec,
@@ -73,6 +73,10 @@ const char *set_option_bell_action_list[] = {
"none", "any", "current", NULL
};
+const struct set_option_entry set_option_table[] = {
+ { "quiet", SET_OPTION_FLAG, 0, 0, NULL },
+};
+
const struct set_option_entry set_session_option_table[] = {
{ "base-index", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
@@ -172,7 +176,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int i;
int try_again;
- if (cmd_check_flag(data->chflags, 'w')) {
+ if (cmd_check_flag(data->chflags, 's')) {
+ oo = &global_options;
+ table = set_option_table;
+ } else if (cmd_check_flag(data->chflags, 'w')) {
table = set_window_option_table;
if (cmd_check_flag(data->chflags, 'g'))
oo = &global_w_options;
diff --git a/usr.bin/tmux/cmd-show-options.c b/usr.bin/tmux/cmd-show-options.c
index 613df1f9fcd..39250421f80 100644
--- a/usr.bin/tmux/cmd-show-options.c
+++ b/usr.bin/tmux/cmd-show-options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-show-options.c,v 1.9 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: cmd-show-options.c,v 1.10 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,8 +31,8 @@ int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_show_options_entry = {
"show-options", "show",
- "[-gw] [-t target-session|target-window]",
- 0, "gw",
+ "[-gsw] [-t target-session|target-window]",
+ 0, "gsw",
cmd_target_init,
cmd_target_parse,
cmd_show_options_exec,
@@ -52,7 +52,10 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
const struct set_option_entry *entry;
const char *optval;
- if (cmd_check_flag(data->chflags, 'w')) {
+ if (cmd_check_flag(data->chflags, 's')) {
+ oo = &global_options;
+ table = set_option_table;
+ } else if (cmd_check_flag(data->chflags, 'w')) {
table = set_window_option_table;
if (cmd_check_flag(data->chflags, 'g'))
oo = &global_w_options;
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c
index 99f8f139c0e..bff573139ed 100644
--- a/usr.bin/tmux/key-bindings.c
+++ b/usr.bin/tmux/key-bindings.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-bindings.c,v 1.15 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.16 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -224,7 +224,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
va_list ap;
char *msg;
- if (be_quiet)
+ if (options_get_number(&global_options, "quiet"))
return;
va_start(ap, fmt);
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 6a1ea524db3..2e33154ec15 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.25 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.26 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -640,7 +640,7 @@ server_client_msg_info(struct cmd_ctx *ctx, const char *fmt, ...)
struct msg_print_data data;
va_list ap;
- if (be_quiet)
+ if (options_get_number(&global_options, "quiet"))
return;
va_start(ap, fmt);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 41956c0890a..b9b816e78f3 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.132 2009/12/08 07:49:31 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.133 2009/12/10 09:16:52 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" 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: December 8 2009 $
+.Dd $Mdocdate: December 10 2009 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -151,8 +151,9 @@ signal may be sent to the
.Nm
server process to recreate it.
.It Fl q
-Prevent the server sending various informational messages, for example when
-window flags are altered.
+Set the
+.Ic quiet
+server option to prevent the server sending various informational messages.
.It Fl S Ar socket-path
Specify a full alternative path to the server socket.
If
@@ -1209,13 +1210,26 @@ or for normal mode without.
The appearance and behaviour of
.Nm
may be modified by changing the value of various options.
-There are two types of option:
+There are three types of option:
+.Em server options ,
.Em session options
and
.Em window options .
.Pp
-Each individual session may have a set of session options, and there is a
-separate set of global session options.
+The
+.Nm
+server has a set of global options which do not apply to any particular
+window or session.
+These are altered with the
+.Ic set-option
+.Fl s
+command, or displayed with the
+.Ic show-options
+.Fl s
+command.
+.Pp
+In addition, each individual session may have a set of session options, and
+there is a separate set of global session options.
Sessions which do not have a particular option configured inherit the value
from the global session options.
Session options are set or unset with the
@@ -1223,7 +1237,7 @@ Session options are set or unset with the
command and may be listed with the
.Ic show-options
command.
-The available session options are listed under the
+The available server and session options are listed under the
.Ic set-option
command.
.Pp
@@ -1241,31 +1255,44 @@ command.
Commands which set options are as follows:
.Bl -tag -width Ds
.It Xo Ic set-option
-.Op Fl aguw
+.Op Fl agsuw
.Op Fl t Ar target-session | Ar target-window
.Ar option Ar value
.Xc
.D1 (alias: Ic set )
-Set a session option.
+Set a window option with
+.Fl w
+(equivalent to the
+.Ic set-window-option
+command),
+a server option with
+.Fl s ,
+otherwise a session option.
+.Pp
+If
+.Fl g
+is specified, the global session or window option is set.
With
.Fl a ,
and if the option expects a string,
.Ar value
is appended to the existing setting.
-If
-.Fl g
-is specified, the global session option is set.
The
.Fl u
flag unsets an option, so a session inherits the option from the global
-options - it is not possible to unset a global option.
+options.
+It is not possible to unset a global option.
.Pp
-With
-.Fl w ,
-this command is equivalent to
-.Ic set-window-option
-with
-.Ar target-window .
+Available window options are listed under
+.Ic set-window-option .
+.Pp
+Available server options are:
+.Bl -tag -width Ds
+.It Ic quiet
+Enable of disable the display of various informational messages (see also the
+.Fl q
+command line flag).
+.El
.Pp
Available session options are:
.Bl -tag -width Ds
@@ -1850,21 +1877,21 @@ as Shift, Alt or Ctrl.
The default is off.
.El
.It Xo Ic show-options
-.Op Fl gw
+.Op Fl gsw
.Op Fl t Ar target-session | Ar target-window
.Xc
.D1 (alias: Ic show )
-Show the session options for
-.Ar target session ,
-or the global session options with
-.Fl g .
-.Pp
-If
+Show the window options with
.Fl w
-is used, this command is equivalent to
-.Ic show-window-options
-with
-.Ar target-window .
+(equivalent to
+.Ic show-window-options ),
+the server options with
+.Fl s ,
+otherwise the session options for
+.Ar target session .
+Global session or window options are listed if
+.Fl g
+is used.
.It Xo Ic show-window-options
.Op Fl g
.Op Fl t Ar target-window
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 15ad3379382..d9a6dc95192 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.62 2009/12/03 22:50:10 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.63 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -36,12 +36,12 @@ extern char *malloc_options;
#endif
char *cfg_file;
+struct options global_options; /* server options */
struct options global_s_options; /* session options */
struct options global_w_options; /* window options */
struct environ global_environ;
int debug_level;
-int be_quiet;
time_t start_time;
char *socket_path;
int login_shell;
@@ -222,14 +222,14 @@ main(int argc, char **argv)
struct cmd *cmd;
enum msgtype msg;
struct passwd *pw;
- struct options *so, *wo;
+ struct options *oo, *so, *wo;
struct keylist *keylist;
struct msg_command_data cmddata;
char *s, *shellcmd, *path, *label, *home, *cause;
char cwd[MAXPATHLEN], **var;
void *buf;
size_t len;
- int opt, flags, cmdflags = 0;
+ int opt, flags, quiet, cmdflags = 0;
short events;
#ifdef DEBUG
@@ -268,7 +268,7 @@ main(int argc, char **argv)
label = xstrdup(optarg);
break;
case 'q':
- be_quiet = 1;
+ quiet = 1;
break;
case 'S':
if (path != NULL)
@@ -314,6 +314,10 @@ main(int argc, char **argv)
for (var = environ; *var != NULL; var++)
environ_put(&global_environ, *var);
+ options_init(&global_options, NULL);
+ oo = &global_options;
+ options_set_number(oo, "quiet", 0);
+
options_init(&global_s_options, NULL);
so = &global_s_options;
options_set_number(so, "base-index", 0);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index b6594da58eb..4b89862436c 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.193 2009/12/08 07:49:31 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.194 2009/12/10 09:16:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1235,6 +1235,7 @@ struct set_option_entry {
};
/* tmux.c */
+extern struct options global_options;
extern struct options global_s_options;
extern struct options global_w_options;
extern struct environ global_environ;
@@ -1391,6 +1392,7 @@ extern const char clock_table[14][5][5];
void clock_draw(struct screen_write_ctx *, int, int);
/* cmd-set-option.c */
+extern const struct set_option_entry set_option_table[];
extern const struct set_option_entry set_session_option_table[];
extern const struct set_option_entry set_window_option_table[];
const char *cmd_set_option_print(