Hi, I also implemented word motion actions for editing at the command prompt. These patches are (or at least should be; a git merge is clean) independent of the pane_index format patches I posted earlier.
In order to do this, I added options for clients (currently just word-separators) and the associated commands and documentation for them. This is done in the first patch. The second patch contains updates for commands and options added since the last time it was updated. More of an "since I was there" kind of thing rather than relevant to the feature. The third patch adds the actions and bindings for vi and emacs (which is untested and may be incomplete; I just copied from the emacs copy key table). The next four patches implement the actions: delete-word previous-word next-word-end next-word The final patch removes the TODO item. I've tested it here with success. I don't do much at tmux's command prompt, but I tried to stress test it. --Ben
From 2f978366a1e71ee6236647d77b46b2745c9aeaad 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 | 28 ++++++++++++++++++++++-- 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, 124 insertions(+), 11 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..36e0c33 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; @@ -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')) 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
From 856b6bbcbcd052b0caddcf598aba366c1dccc8f6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 01:45:28 -0400 Subject: [PATCH 2/8] Update commands and options for vim syntax The vim syntax file has fallen behind and there are new commands and options since it has been updated last. --- trunk/examples/tmux.vim | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/trunk/examples/tmux.vim b/trunk/examples/tmux.vim index 490baf0..f4f7518 100644 --- a/trunk/examples/tmux.vim +++ b/trunk/examples/tmux.vim @@ -63,6 +63,8 @@ syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg 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 tmuxOptsSet destroy-unattached exit-unattached set-clipboard +syn keyword tmuxOptsSet bell-on-alert mouse-select-window mouse-utf8 syn keyword tmuxOptsSetc word-separators @@ -77,6 +79,7 @@ syn keyword tmuxOptsSetw window-status-current-fg mode-mouse synchronize-panes syn keyword tmuxOptsSetw window-status-format window-status-current-format syn keyword tmuxOptsSetw word-separators window-status-alert-alert syn keyword tmuxOptsSetw window-status-alert-bg window-status-alert-fg +syn keyword tmuxOptsSetw pane-base-index other-pane-height other-pane-width syn keyword tmuxTodo FIXME NOTE TODO XXX contained -- 1.7.6.4
From f569d84f90a59bcce2e1d647c1eff90845134cb2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 01:47:23 -0400 Subject: [PATCH 3/8] Add word-wise edit commands and bindings This also adds bindings for vi and emacs key tables. I don't use emacs, but I copied the commands from its copy bindings. Not sure if there's a NEXTWORD binding for emacs, but if there is, the copy key table is missing it as well. --- trunk/mode-key.c | 23 +++++++++++++++++------ trunk/tmux.h | 4 ++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/trunk/mode-key.c b/trunk/mode-key.c index 246426d..e45f1c6 100644 --- a/trunk/mode-key.c +++ b/trunk/mode-key.c @@ -49,11 +49,15 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = { { MODEKEYEDIT_DELETE, "delete" }, { MODEKEYEDIT_DELETELINE, "delete-line" }, { MODEKEYEDIT_DELETETOENDOFLINE, "delete-end-of-line" }, + { MODEKEYEDIT_DELETEWORD, "delete-word" }, { MODEKEYEDIT_ENDOFLINE, "end-of-line" }, { MODEKEYEDIT_ENTER, "enter" }, { MODEKEYEDIT_HISTORYDOWN, "history-down" }, { MODEKEYEDIT_HISTORYUP, "history-up" }, + { MODEKEYEDIT_NEXTWORD, "next-word" }, + { MODEKEYEDIT_NEXTWORDEND, "next-word-end" }, { MODEKEYEDIT_PASTE, "paste" }, + { MODEKEYEDIT_PREVIOUSWORD, "previous-word" }, { MODEKEYEDIT_STARTOFLINE, "start-of-line" }, { MODEKEYEDIT_SWITCHMODE, "switch-mode" }, { MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" }, @@ -127,7 +131,8 @@ const struct mode_key_entry mode_key_vi_edit[] = { { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL }, { '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE }, { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE }, - { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, + { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, + { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, { '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE }, { '\r', 0, MODEKEYEDIT_ENTER }, { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE }, @@ -145,13 +150,16 @@ const struct mode_key_entry mode_key_vi_edit[] = { { '\r', 1, MODEKEYEDIT_ENTER }, { '^', 1, MODEKEYEDIT_STARTOFLINE }, { 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND }, + { 'b', 1, MODEKEYEDIT_PREVIOUSWORD }, { 'd', 1, MODEKEYEDIT_DELETELINE }, + { 'e', 1, MODEKEYEDIT_NEXTWORDEND }, { 'h', 1, MODEKEYEDIT_CURSORLEFT }, { 'i', 1, MODEKEYEDIT_SWITCHMODE }, { 'j', 1, MODEKEYEDIT_HISTORYDOWN }, { 'k', 1, MODEKEYEDIT_HISTORYUP }, { 'l', 1, MODEKEYEDIT_CURSORRIGHT }, { 'p', 1, MODEKEYEDIT_PASTE }, + { 'w', 1, MODEKEYEDIT_NEXTWORD }, { KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE }, { KEYC_DC, 1, MODEKEYEDIT_DELETE }, { KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN }, @@ -259,18 +267,21 @@ const struct mode_key_entry mode_key_emacs_edit[] = { { '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT }, { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL }, { '\004' /* C-d */, 0, MODEKEYEDIT_DELETE }, - { '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE }, + { '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE }, { '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT }, - { '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE }, - { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE }, - { '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE }, + { '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE }, + { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE }, + { '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE }, { '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN }, { '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP }, { '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS }, - { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, + { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, + { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, { '\031' /* C-y */, 0, MODEKEYEDIT_PASTE }, { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL }, { '\r', 0, MODEKEYEDIT_ENTER }, + { 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD }, + { 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND }, { 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE }, { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE }, { KEYC_DC, 0, MODEKEYEDIT_DELETE }, diff --git a/trunk/tmux.h b/trunk/tmux.h index 65dc56f..4cb060c 100644 --- a/trunk/tmux.h +++ b/trunk/tmux.h @@ -437,11 +437,15 @@ enum mode_key_cmd { MODEKEYEDIT_DELETE, MODEKEYEDIT_DELETELINE, MODEKEYEDIT_DELETETOENDOFLINE, + MODEKEYEDIT_DELETEWORD, MODEKEYEDIT_ENDOFLINE, MODEKEYEDIT_ENTER, MODEKEYEDIT_HISTORYDOWN, MODEKEYEDIT_HISTORYUP, + MODEKEYEDIT_NEXTWORD, + MODEKEYEDIT_NEXTWORDEND, MODEKEYEDIT_PASTE, + MODEKEYEDIT_PREVIOUSWORD, MODEKEYEDIT_STARTOFLINE, MODEKEYEDIT_SWITCHMODE, MODEKEYEDIT_SWITCHMODEAPPEND, -- 1.7.6.4
From d6b76a7fa587f94eff4d3207089c20f84bafd08d Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 02:17:49 -0400 Subject: [PATCH 4/8] Implement delete-word editing action --- trunk/status.c | 33 ++++++++++++++++++++++++++++++--- 1 files changed, 30 insertions(+), 3 deletions(-) diff --git a/trunk/status.c b/trunk/status.c index 1baab92..6f6b528 100644 --- a/trunk/status.c +++ b/trunk/status.c @@ -963,9 +963,10 @@ status_prompt_redraw(struct client *c) void status_prompt_key(struct client *c, int key) { + const char *word_separators; struct paste_buffer *pb; - char *s, *first, *last, word[64], swapc; - const char *histstr; + char *s, *first, *last, word[64], swapc; + const char *histstr; u_char ch; size_t size, n, off, idx; @@ -1077,11 +1078,37 @@ status_prompt_key(struct client *c, int key) c->flags |= CLIENT_STATUS; } break; + case MODEKEYEDIT_DELETEWORD: + word_separators = + options_get_string(&c->options, "word-separators"); + idx = c->prompt_index; + /* Find a non-separator. */ + while (idx != 0) { + idx--; + if (!strchr(word_separators, c->prompt_buffer[idx])) + break; + } + /* Find the separator at the beginning of the word. */ + while (idx != 0) { + idx--; + if (strchr(word_separators, c->prompt_buffer[idx])) { + /* Go back to the word. */ + idx++; + break; + } + } + memmove(c->prompt_buffer + idx, + c->prompt_buffer + c->prompt_index, + size + 1 - c->prompt_index); + memset(c->prompt_buffer + size - (c->prompt_index - idx), '\0', c->prompt_index - idx); + c->prompt_index = idx; + c->flags |= CLIENT_STATUS; + break; case MODEKEYEDIT_HISTORYUP: histstr = status_prompt_up_history(&c->prompt_hindex); if (histstr == NULL) break; - xfree(c->prompt_buffer); + xfree(c->prompt_buffer); c->prompt_buffer = xstrdup(histstr); c->prompt_index = strlen(c->prompt_buffer); c->flags |= CLIENT_STATUS; -- 1.7.6.4
From 16b5ad4a7db708aef6e5f5557a93daa04bd31b75 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 02:24:18 -0400 Subject: [PATCH 5/8] Implement the previous-word edit action --- trunk/status.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/trunk/status.c b/trunk/status.c index 6f6b528..6818316 100644 --- a/trunk/status.c +++ b/trunk/status.c @@ -1104,6 +1104,26 @@ status_prompt_key(struct client *c, int key) c->prompt_index = idx; c->flags |= CLIENT_STATUS; break; + case MODEKEYEDIT_PREVIOUSWORD: + word_separators = + options_get_string(&c->options, "word-separators"); + /* Find a non-separator. */ + while (c->prompt_index != 0) { + c->prompt_index--; + if (!strchr(word_separators, c->prompt_buffer[c->prompt_index])) + break; + } + /* Find the separator at the beginning of the word. */ + while (c->prompt_index != 0) { + c->prompt_index--; + if (strchr(word_separators, c->prompt_buffer[c->prompt_index])) { + /* Go back to the word. */ + c->prompt_index++; + break; + } + } + c->flags |= CLIENT_STATUS; + break; case MODEKEYEDIT_HISTORYUP: histstr = status_prompt_up_history(&c->prompt_hindex); if (histstr == NULL) -- 1.7.6.4
From f06be3e6b00ff077c98065726b72a14e163b5d69 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 02:24:44 -0400 Subject: [PATCH 6/8] Implement the next-word-end edit action --- trunk/status.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/trunk/status.c b/trunk/status.c index 6818316..5059af9 100644 --- a/trunk/status.c +++ b/trunk/status.c @@ -1104,6 +1104,26 @@ status_prompt_key(struct client *c, int key) c->prompt_index = idx; c->flags |= CLIENT_STATUS; break; + case MODEKEYEDIT_NEXTWORDEND: + word_separators = + options_get_string(&c->options, "word-separators"); + /* Find a word. */ + while (c->prompt_index != size) { + c->prompt_index++; + if (!strchr(word_separators, c->prompt_buffer[c->prompt_index])) + break; + } + /* Find the separator at the end of the word. */ + while (c->prompt_index != size) { + c->prompt_index++; + if (strchr(word_separators, c->prompt_buffer[c->prompt_index])) { + /* Go back to the word. */ + c->prompt_index--; + break; + } + } + c->flags |= CLIENT_STATUS; + break; case MODEKEYEDIT_PREVIOUSWORD: word_separators = options_get_string(&c->options, "word-separators"); -- 1.7.6.4
From df8ac4efe532034245400102a1b3a57bdc1edaaf Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 02:24:56 -0400 Subject: [PATCH 7/8] Implement the next-word edit action --- trunk/status.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/trunk/status.c b/trunk/status.c index 5059af9..4ba59c6 100644 --- a/trunk/status.c +++ b/trunk/status.c @@ -1104,6 +1104,23 @@ status_prompt_key(struct client *c, int key) c->prompt_index = idx; c->flags |= CLIENT_STATUS; break; + case MODEKEYEDIT_NEXTWORD: + word_separators = + options_get_string(&c->options, "word-separators"); + /* Find a separator. */ + while (c->prompt_index != size) { + c->prompt_index++; + if (strchr(word_separators, c->prompt_buffer[c->prompt_index])) + break; + } + /* Find the word right after the separation. */ + while (c->prompt_index != size) { + c->prompt_index++; + if (!strchr(word_separators, c->prompt_buffer[c->prompt_index])) + break; + } + c->flags |= CLIENT_STATUS; + break; case MODEKEYEDIT_NEXTWORDEND: word_separators = options_get_string(&c->options, "word-separators"); -- 1.7.6.4
From b23be52df1343711a121eb1c5a8d5b2e1eeda0c1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Thu, 20 Oct 2011 02:25:18 -0400 Subject: [PATCH 8/8] Cross word motions off the TODO list --- trunk/TODO | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/trunk/TODO b/trunk/TODO index 3709490..459bdc3 100644 --- a/trunk/TODO +++ b/trunk/TODO @@ -6,7 +6,6 @@ - flags to centre screen in window - activity/bell should be per-window not per-link? what if it is cur win in session not being watched? -- next prev word etc in command prompt - use a better termcap internally instead of screen, perhaps xterm - should be able to move to a hidden pane and it would be moved into view. pane number in status line/top-right would be cool for this -- 1.7.6.4
pgpVGfi3VLoW0.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