Revision: 2708
http://tmux.svn.sourceforge.net/tmux/?rev=2708&view=rev
Author: tcunha
Date: 2012-03-03 09:16:52 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Sync OpenBSD patchset 1032:
Allow a single option to be specified to show-options to show just that
option.
Modified Paths:
--------------
trunk/cmd-set-option.c
trunk/cmd-show-options.c
trunk/options-table.c
trunk/tmux.1
trunk/tmux.h
Modified: trunk/cmd-set-option.c
===================================================================
--- trunk/cmd-set-option.c 2012-03-03 09:14:21 UTC (rev 2707)
+++ trunk/cmd-set-option.c 2012-03-03 09:16:52 UTC (rev 2708)
@@ -29,9 +29,6 @@
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
-int cmd_set_option_find(const char *, const struct options_table_entry **,
- const struct options_table_entry **);
-
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
const struct options_table_entry *, struct options *,
const char *);
@@ -81,40 +78,7 @@
cmd_set_option_exec
};
-/* Look for an option in all three tables. */
int
-cmd_set_option_find(
- const char *optstr, const struct options_table_entry **table,
- const struct options_table_entry **oe)
-{
- static const struct options_table_entry *tables[] = {
- server_options_table,
- window_options_table,
- session_options_table
- };
- const struct options_table_entry *oe_loop;
- u_int i;
-
- for (i = 0; i < nitems(tables); i++) {
- for (oe_loop = tables[i]; oe_loop->name != NULL; oe_loop++) {
- if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
- continue;
-
- /* If already found, ambiguous. */
- if (*oe != NULL)
- return (-1);
- *oe = oe_loop;
- *table = tables[i];
-
- /* Bail now if an exact match. */
- if (strcmp((*oe)->name, optstr) == 0)
- break;
- }
- }
- return (0);
-}
-
-int
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
@@ -139,7 +103,7 @@
/* Find the option entry, try each table. */
table = oe = NULL;
- if (cmd_set_option_find(optstr, &table, &oe) != 0) {
+ if (options_table_find(optstr, &table, &oe) != 0) {
ctx->error(ctx, "ambiguous option: %s", optstr);
return (-1);
}
Modified: trunk/cmd-show-options.c
===================================================================
--- trunk/cmd-show-options.c 2012-03-03 09:14:21 UTC (rev 2707)
+++ trunk/cmd-show-options.c 2012-03-03 09:16:52 UTC (rev 2708)
@@ -31,8 +31,8 @@
const struct cmd_entry cmd_show_options_entry = {
"show-options", "show",
- "gst:w", 0, 0,
- "[-gsw] [-t target-session|target-window]",
+ "gst:w", 0, 1,
+ "[-gsw] [-t target-session|target-window] [option]",
0,
NULL,
NULL,
@@ -41,8 +41,8 @@
const struct cmd_entry cmd_show_window_options_entry = {
"show-window-options", "showw",
- "gt:", 0, 0,
- "[-g] " CMD_TARGET_WINDOW_USAGE,
+ "gt:", 0, 1,
+ "[-g] " CMD_TARGET_WINDOW_USAGE " [option]",
0,
NULL,
NULL,
@@ -86,11 +86,27 @@
}
}
- for (oe = table; oe->name != NULL; oe++) {
+ if (args->argc != 0) {
+ table = oe = NULL;
+ if (options_table_find(args->argv[0], &table, &oe) != 0) {
+ ctx->error(ctx, "ambiguous option: %s", args->argv[0]);
+ return (-1);
+ }
+ if (oe == NULL) {
+ ctx->error(ctx, "unknown option: %s", args->argv[0]);
+ return (-1);
+ }
if ((o = options_find1(oo, oe->name)) == NULL)
- continue;
+ return (0);
optval = options_table_print_entry(oe, o);
ctx->print(ctx, "%s %s", oe->name, optval);
+ } else {
+ for (oe = table; oe->name != NULL; oe++) {
+ if ((o = options_find1(oo, oe->name)) == NULL)
+ continue;
+ optval = options_table_print_entry(oe, o);
+ ctx->print(ctx, "%s %s", oe->name, optval);
+ }
}
return (0);
Modified: trunk/options-table.c
===================================================================
--- trunk/options-table.c 2012-03-03 09:14:21 UTC (rev 2707)
+++ trunk/options-table.c 2012-03-03 09:16:52 UTC (rev 2708)
@@ -731,3 +731,36 @@
}
return (out);
}
+
+/* Find an option. */
+int
+options_table_find(
+ const char *optstr, const struct options_table_entry **table,
+ const struct options_table_entry **oe)
+{
+ static const struct options_table_entry *tables[] = {
+ server_options_table,
+ window_options_table,
+ session_options_table
+ };
+ const struct options_table_entry *oe_loop;
+ u_int i;
+
+ for (i = 0; i < nitems(tables); i++) {
+ for (oe_loop = tables[i]; oe_loop->name != NULL; oe_loop++) {
+ if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
+ continue;
+
+ /* If already found, ambiguous. */
+ if (*oe != NULL)
+ return (-1);
+ *oe = oe_loop;
+ *table = tables[i];
+
+ /* Bail now if an exact match. */
+ if (strcmp((*oe)->name, optstr) == 0)
+ break;
+ }
+ }
+ return (0);
+}
Modified: trunk/tmux.1
===================================================================
--- trunk/tmux.1 2012-03-03 09:14:21 UTC (rev 2707)
+++ trunk/tmux.1 2012-03-03 09:16:52 UTC (rev 2708)
@@ -2626,9 +2626,10 @@
.It Xo Ic show-options
.Op Fl gsw
.Op Fl t Ar target-session | Ar target-window
+.Op Ar option
.Xc
.D1 (alias: Ic show )
-Show the window options with
+Show the window options (or a single window option if given) with
.Fl w
(equivalent to
.Ic show-window-options ) ,
@@ -2642,9 +2643,10 @@
.It Xo Ic show-window-options
.Op Fl g
.Op Fl t Ar target-window
+.Op Ar option
.Xc
.D1 (alias: Ic showw )
-List the window options for
+List the window options or a single option for
.Ar target-window ,
or the global window options if
.Fl g
Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h 2012-03-03 09:14:21 UTC (rev 2707)
+++ trunk/tmux.h 2012-03-03 09:16:52 UTC (rev 2708)
@@ -1415,6 +1415,9 @@
const struct options_table_entry *, struct options *);
const char *options_table_print_entry(
const struct options_table_entry *, struct options_entry *);
+int options_table_find(
+ const char *, const struct options_table_entry **,
+ const struct options_table_entry **);
/* job.c */
extern struct joblist all_jobs;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs