Revision: 2641
          http://tmux.svn.sourceforge.net/tmux/?rev=2641&view=rev
Author:   tcunha
Date:     2011-11-25 13:34:20 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
Sync OpenBSD patchset 982:

Add word movement and editing command for command prompt editing, from
Ben Boeckel.

Modified Paths:
--------------
    trunk/mode-key.c
    trunk/status.c
    trunk/tmux.h

Modified: trunk/mode-key.c
===================================================================
--- trunk/mode-key.c    2011-11-25 13:33:04 UTC (rev 2640)
+++ trunk/mode-key.c    2011-11-25 13:34:20 UTC (rev 2641)
@@ -49,11 +49,15 @@
        { 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 @@
        { '\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 @@
        { '\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 @@
        { '\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 },

Modified: trunk/status.c
===================================================================
--- trunk/status.c      2011-11-25 13:33:04 UTC (rev 2640)
+++ trunk/status.c      2011-11-25 13:34:20 UTC (rev 2641)
@@ -973,9 +973,12 @@
 void
 status_prompt_key(struct client *c, int key)
 {
+       struct session          *sess = c->session;
+       struct options          *oo = &sess->options;
        struct paste_buffer     *pb;
-       char                    *s, *first, *last, word[64], swapc;
-       const char              *histstr;
+       char                    *s, *first, *last, word[64], swapc;
+       const char              *histstr;
+       const char              *wsep;
        u_char                   ch;
        size_t                   size, n, off, idx;
 
@@ -1092,11 +1095,103 @@
                        c->flags |= CLIENT_STATUS;
                }
                break;
+       case MODEKEYEDIT_DELETEWORD:
+               wsep = options_get_string(oo, "word-separators");
+               idx = c->prompt_index;
+
+               /* Find a non-separator. */
+               while (idx != 0) {
+                       idx--;
+                       if (!strchr(wsep, c->prompt_buffer[idx]))
+                               break;
+               }
+
+               /* Find the separator at the beginning of the word. */
+               while (idx != 0) {
+                       idx--;
+                       if (strchr(wsep, 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_NEXTWORD:
+               wsep = options_get_string(oo, "word-separators");
+
+               /* Find a separator. */
+               while (c->prompt_index != size) {
+                       c->prompt_index++;
+                       if (strchr(wsep, c->prompt_buffer[c->prompt_index]))
+                               break;
+               }
+
+               /* Find the word right after the separation. */
+               while (c->prompt_index != size) {
+                       c->prompt_index++;
+                       if (!strchr(wsep, c->prompt_buffer[c->prompt_index]))
+                               break;
+               }
+
+               c->flags |= CLIENT_STATUS;
+               break;
+       case MODEKEYEDIT_NEXTWORDEND:
+               wsep = options_get_string(oo, "word-separators");
+
+               /* Find a word. */
+               while (c->prompt_index != size) {
+                       c->prompt_index++;
+                       if (!strchr(wsep, 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(wsep, c->prompt_buffer[c->prompt_index])) {
+                               /* Go back to the word. */
+                               c->prompt_index--;
+                               break;
+                       }
+               }
+
+               c->flags |= CLIENT_STATUS;
+               break;
+       case MODEKEYEDIT_PREVIOUSWORD:
+               wsep = options_get_string(oo, "word-separators");
+
+               /* Find a non-separator. */
+               while (c->prompt_index != 0) {
+                       c->prompt_index--;
+                       if (!strchr(wsep, 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(wsep, 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)
                        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;

Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h        2011-11-25 13:33:04 UTC (rev 2640)
+++ trunk/tmux.h        2011-11-25 13:34:20 UTC (rev 2641)
@@ -438,11 +438,15 @@
        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,

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to