On Thu, Oct 20, 2011 at 12:17:48 -0400, Ben Boeckel wrote: > @@ -64,7 +75,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) > oo = &global_options; > table = server_options_table; > } else if (args_has(self->args, 'w') || > - self->entry == &cmd_show_window_options_entry) { > + self->entry == &cmd_show_window_options_entry) { > table = window_options_table; > if (args_has(self->args, 'g')) > oo = &global_w_options; > @@ -74,6 +85,17 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx > *ctx) > return (-1); > oo = &wl->window->options; > } > + } else if (args_has(self->args, 'c') || > + self->entry == &cmd_show_client_options_entry) { > + table = client_options_table; > + if (args_has(self->args, 'g')) > + oo = &global_c_options; > + else { > + cl = cmd_find_client(ctx, args_get(args, 't')); > + if (cl == NULL) > + return (-1); > + oo = &cl->options; > + } > } else { > table = session_options_table; > if (args_has(self->args, 'g'))
Whoops on the indentation here. Replacement 0001 patch attached. --Ben
From ee9a3162228f330c70f0343b63dddd5a2951786b Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 01:42:19 -0400 Subject: [PATCH 1/8] Add word-separator option to clients This is for the next-word, next-word-end, previous-word, and delete-word commands in edit mode. Currently only a window has word-separators as an option. This commit adds the client option and the related code to get client options available including: - set-client-option command - show-client-option command - word-separators option - documentation for the above - update vim syntax highlighting There are a few incidental whitespace fixes as well. --- trunk/cmd-set-option.c | 25 ++++++++++++++++++++- trunk/cmd-show-options.c | 26 +++++++++++++++++++++- trunk/cmd.c | 2 + trunk/compat/getopt.c | 2 +- trunk/examples/tmux.vim | 4 +++ trunk/options-table.c | 10 ++++++++ trunk/server-client.c | 2 + trunk/tmux.1 | 52 +++++++++++++++++++++++++++++++++++++++++---- trunk/tmux.c | 4 +++ trunk/tmux.h | 6 +++++ 10 files changed, 123 insertions(+), 10 deletions(-) diff --git a/trunk/cmd-set-option.c b/trunk/cmd-set-option.c index c19f023..cd43546 100644 --- a/trunk/cmd-set-option.c +++ b/trunk/cmd-set-option.c @@ -63,8 +63,18 @@ struct options_entry *cmd_set_option_choice(struct cmd *, struct cmd_ctx *, const struct cmd_entry cmd_set_option_entry = { "set-option", "set", - "agst:uw", 1, 2, - "[-agsuw] [-t target-session|target-window] option [value]", + "acgst:uw", 1, 2, + "[-acgsuw] [-t target-session|target-client|target-window] option [value]", + 0, + NULL, + NULL, + cmd_set_option_exec +}; + +const struct cmd_entry cmd_set_client_option_entry = { + "set-client-option", "setc", + "agt:u", 1, 2, + "[-agu] " CMD_TARGET_CLIENT_USAGE " option [value]", 0, NULL, NULL, @@ -89,6 +99,7 @@ cmd_set_option_find( { static const struct options_table_entry *tables[] = { server_options_table, + client_options_table, window_options_table, session_options_table }; @@ -120,6 +131,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; const struct options_table_entry *table, *oe; struct session *s; + struct client *cl; struct winlink *wl; struct client *c; struct options *oo; @@ -160,6 +172,15 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); oo = &wl->window->options; } + } else if (table == client_options_table) { + if (args_has(self->args, 'g')) + oo = &global_c_options; + else { + cl = cmd_find_client(ctx, args_get(args, 't')); + if (cl == NULL) + return (-1); + oo = &cl->options; + } } else if (table == session_options_table) { if (args_has(self->args, 'g')) oo = &global_s_options; diff --git a/trunk/cmd-show-options.c b/trunk/cmd-show-options.c index 397b0c9..5d10822 100644 --- a/trunk/cmd-show-options.c +++ b/trunk/cmd-show-options.c @@ -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", - "gst:w", 0, 0, - "[-gsw] [-t target-session|target-window]", + "cgst:w", 0, 0, + "[-cgsw] [-t target-session|target-window]", 0, NULL, NULL, @@ -49,12 +49,23 @@ const struct cmd_entry cmd_show_window_options_entry = { cmd_show_options_exec }; +const struct cmd_entry cmd_show_client_options_entry = { + "show-client-options", "showc", + "gt:", 0, 0, + "[-g] " CMD_TARGET_CLIENT_USAGE, + 0, + NULL, + NULL, + cmd_show_options_exec +}; + int cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; const struct options_table_entry *table, *oe; struct session *s; + struct client *cl; struct winlink *wl; struct options *oo; struct options_entry *o; @@ -74,6 +85,17 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); oo = &wl->window->options; } + } else if (args_has(self->args, 'c') || + self->entry == &cmd_show_client_options_entry) { + table = client_options_table; + if (args_has(self->args, 'g')) + oo = &global_c_options; + else { + cl = cmd_find_client(ctx, args_get(args, 't')); + if (cl == NULL) + return (-1); + oo = &cl->options; + } } else { table = session_options_table; if (args_has(self->args, 'g')) diff --git a/trunk/cmd.c b/trunk/cmd.c index 2027f75..bc6a29f 100644 --- a/trunk/cmd.c +++ b/trunk/cmd.c @@ -92,11 +92,13 @@ const struct cmd_entry *cmd_table[] = { &cmd_server_info_entry, &cmd_set_buffer_entry, &cmd_set_environment_entry, + &cmd_set_client_option_entry, &cmd_set_option_entry, &cmd_set_window_option_entry, &cmd_show_buffer_entry, &cmd_show_environment_entry, &cmd_show_messages_entry, + &cmd_show_client_options_entry, &cmd_show_options_entry, &cmd_show_window_options_entry, &cmd_source_file_entry, diff --git a/trunk/compat/getopt.c b/trunk/compat/getopt.c index f6ecb58..b7b8582 100644 --- a/trunk/compat/getopt.c +++ b/trunk/compat/getopt.c @@ -108,7 +108,7 @@ BSDgetopt(nargc, nargv, ostr) __progname, BSDoptopt); return (BADCH); } - else /* white space */ + else /* white space */ BSDoptarg = nargv[BSDoptind]; place = EMSG; ++BSDoptind; diff --git a/trunk/examples/tmux.vim b/trunk/examples/tmux.vim index d21c377..490baf0 100644 --- a/trunk/examples/tmux.vim +++ b/trunk/examples/tmux.vim @@ -43,6 +43,7 @@ syn keyword tmuxCmds show-environment choose-client displayp display-panes syn keyword tmuxCmds run[-shell] lockc lock-client locks lock-session lsp syn keyword tmuxCmds list-panes pipep pipe-pane showmsgs show-messages capturep syn keyword tmuxCmds capture-pane joinp join-pane choose-buffer +syn keyword tmuxCmds setc set-client-option syn keyword tmuxOptsSet prefix status status-fg status-bg bell-action syn keyword tmuxOptsSet default-command history-limit status-left status-right @@ -63,6 +64,8 @@ syn keyword tmuxOptsSet pane-border-bg pane-border-fg syn keyword tmuxOptsSet display-panes-active-colour alternate-screen syn keyword tmuxOptsSet detach-on-destroy +syn keyword tmuxOptsSetc word-separators + syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg syn keyword tmuxOptsSetw mode-keys clock-mode-colour clock-mode-style @@ -95,6 +98,7 @@ hi def link tmuxKey Special hi def link tmuxNumber Number hi def link tmuxOptions Identifier hi def link tmuxOptsSet Function +hi def link tmuxOptsSetc Function hi def link tmuxOptsSetw Function hi def link tmuxString String hi def link tmuxTodo Todo diff --git a/trunk/options-table.c b/trunk/options-table.c index 0832117..8636261 100644 --- a/trunk/options-table.c +++ b/trunk/options-table.c @@ -85,6 +85,16 @@ const struct options_table_entry server_options_table[] = { { .name = NULL } }; +/* Client options. */ +const struct options_table_entry client_options_table[] = { + { .name = "word-separators", + .type = OPTIONS_TABLE_STRING, + .default_str = " -_@" + }, + + { .name = NULL } +}; + /* Session options. */ const struct options_table_entry session_options_table[] = { { .name = "base-index", diff --git a/trunk/server-client.c b/trunk/server-client.c index 6ed53b8..089c99e 100644 --- a/trunk/server-client.c +++ b/trunk/server-client.c @@ -91,6 +91,8 @@ server_client_create(int fd) c->last_mouse.b = MOUSE_UP; c->last_mouse.x = c->last_mouse.y = -1; + options_init(&c->options, &global_c_options); + evtimer_set(&c->repeat_timer, server_client_repeat_timer, c); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { diff --git a/trunk/tmux.1 b/trunk/tmux.1 index f56cf8d..7687ceb 100644 --- a/trunk/tmux.1 +++ b/trunk/tmux.1 @@ -1677,9 +1677,10 @@ or for normal mode without. The appearance and behaviour of .Nm may be modified by changing the value of various options. -There are three types of option: +There are four types of option: .Em server options , -.Em session options +.Em session options, +.Em client options and .Em window options . .Pp @@ -1708,6 +1709,17 @@ The available server and session options are listed under the .Ic set-option command. .Pp +Similarly, a set of client options is attached to each client, and there is +a set of global client options from which any unset options are inherited. +Client options are altered with the +.Ic set-client-option +command and can be listed with the +.Ic show-client-options +command. +All client options are documented with the +.Ic set-client-option +command. +.Pp Similarly, a set of window options is attached to each window, and there is a set of global window options from which any unset options are inherited. Window options are altered with the @@ -1722,8 +1734,8 @@ command. Commands which set options are as follows: .Bl -tag -width Ds .It Xo Ic set-option -.Op Fl agsuw -.Op Fl t Ar target-session | Ar target-window +.Op Fl acgsuw +.Op Fl t Ar target-session | Ar target-client | Ar target-window .Ar option Ar value .Xc .D1 (alias: Ic set ) @@ -1734,11 +1746,13 @@ Set a window option with command), a server option with .Fl s , +a client option with +.Fl c , otherwise a session option. .Pp If .Fl g -is specified, the global session or window option is set. +is specified, the global session, client or window option is set. With .Fl a , and if the option expects a string, @@ -1750,6 +1764,8 @@ flag unsets an option, so a session inherits the option from the global options. It is not possible to unset a global option. .Pp +Available client options are listed under +.Ic set-client-option . Available window options are listed under .Ic set-window-option . .Pp @@ -2278,6 +2294,32 @@ If .Ic monitor-silence is enabled, prints a message after the interval has expired on a given window. .El +.It Xo Ic set-client-option +.Op Fl agu +.Op Fl t Ar target-client +.Ar option Ar value +.Xc +.D1 (alias: Ic setc ) +Set a client option. +The +.Fl a , +.Fl g +and +.Fl u +flags work similarly to the +.Ic set-option +command. +.Pp +Supported client options are: +.Pp +.Bl -tag -width Ds -compact +.It Ic word-separators Ar string +Sets the client's conception of what characters are considered word +separators, for the purposes of the next and previous word commands in +edit mode. +The default is +.Ql \ -_@ . +.El .It Xo Ic set-window-option .Op Fl agu .Op Fl t Ar target-window diff --git a/trunk/tmux.c b/trunk/tmux.c index bf9ee03..48e6166 100644 --- a/trunk/tmux.c +++ b/trunk/tmux.c @@ -35,6 +35,7 @@ extern char *malloc_options; struct options global_options; /* server options */ struct options global_s_options; /* session options */ +struct options global_c_options; /* client options */ struct options global_w_options; /* window options */ struct environ global_environ; @@ -316,6 +317,9 @@ main(int argc, char **argv) options_table_populate_tree(session_options_table, &global_s_options); options_set_string(&global_s_options, "default-shell", "%s", getshell()); + options_init(&global_c_options, NULL); + options_table_populate_tree(client_options_table, &global_c_options); + options_init(&global_w_options, NULL); options_table_populate_tree(window_options_table, &global_w_options); diff --git a/trunk/tmux.h b/trunk/tmux.h index 74add28..65dc56f 100644 --- a/trunk/tmux.h +++ b/trunk/tmux.h @@ -1188,6 +1188,8 @@ struct client { struct mouse_event last_mouse; + struct options options; + int references; }; ARRAY_DECL(clients, struct client *); @@ -1325,6 +1327,7 @@ ARRAY_DECL(causelist, char *); /* tmux.c */ extern struct options global_options; extern struct options global_s_options; +extern struct options global_c_options; extern struct options global_w_options; extern struct environ global_environ; extern struct event_base *ev_base; @@ -1403,6 +1406,7 @@ void *options_get_data(struct options *, const char *); /* options-table.c */ extern const struct options_table_entry server_options_table[]; +extern const struct options_table_entry client_options_table[]; extern const struct options_table_entry session_options_table[]; extern const struct options_table_entry window_options_table[]; void options_table_populate_tree( @@ -1616,11 +1620,13 @@ extern const struct cmd_entry cmd_send_prefix_entry; extern const struct cmd_entry cmd_server_info_entry; extern const struct cmd_entry cmd_set_buffer_entry; extern const struct cmd_entry cmd_set_environment_entry; +extern const struct cmd_entry cmd_set_client_option_entry; extern const struct cmd_entry cmd_set_option_entry; extern const struct cmd_entry cmd_set_window_option_entry; extern const struct cmd_entry cmd_show_buffer_entry; extern const struct cmd_entry cmd_show_environment_entry; extern const struct cmd_entry cmd_show_messages_entry; +extern const struct cmd_entry cmd_show_client_options_entry; extern const struct cmd_entry cmd_show_options_entry; extern const struct cmd_entry cmd_show_window_options_entry; extern const struct cmd_entry cmd_source_file_entry; -- 1.7.6.4
pgpFZV1lw4wKw.pgp
Description: PGP signature
------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Ciosco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users