]> granicus.if.org Git - mutt/commitdiff
Add a transpose-character function to the editor. From Aaron Schrab.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 11:16:20 +0000 (11:16 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 11:16:20 +0000 (11:16 +0000)
OPS
doc/manual.sgml.tail
enter.c
functions.h

diff --git a/OPS b/OPS
index dd42241c5137611d23f9d7f91aa9ea3012ec0896..6099864b72057de6e3d0c472dc82d4885387bb9f 100644 (file)
--- a/OPS
+++ b/OPS
@@ -70,6 +70,7 @@ OP_EDITOR_KILL_EOL "delete chars from cursor to end of line"
 OP_EDITOR_KILL_LINE "delete all chars on the line"
 OP_EDITOR_KILL_WORD "delete the word in front of the cursor"
 OP_EDITOR_QUOTE_CHAR "quote the next typed key"
+OP_EDITOR_TRANSPOSE_CHARS "transpose character under cursor with previous"
 OP_ENTER_COMMAND "enter a muttrc command"
 OP_ENTER_MASK "enter a file mask"
 OP_EXIT "exit this menu"
index 28e4a5175f554bad41ae17c3c6d1b4d475c56c1b..ff5d1d4b43c1d669c7c2afcd51fc863dfa8afa8a 100644 (file)
@@ -311,6 +311,7 @@ kill-eol                  ^K   delete chars from cursor to end of line
 kill-line                 ^U   delete all chars on the line
 kill-word                 ^W   delete the word in front of the cursor
 quote-char                ^V   quote the next typed key
+transpose-chars    not bound   transpose character under cursor with previous
 </verb>
 
 <sect>Miscellany
diff --git a/enter.c b/enter.c
index 46786199ddedd3fa4da1bb8bc0b2ef5fe4797cde..c8b00f3365d397b899ce8eb6ec9d73418b37c5bb 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -484,6 +484,27 @@ int _mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x,
            goto self_insert;
          }
 
+       case OP_EDITOR_TRANSPOSE_CHARS:
+         j = buf[curpos];
+         if(curpos == 0) 
+         {
+           buf[curpos] = buf[1];
+           buf[1] = j;
+         }
+         else if (curpos == lastchar) 
+         {
+           j = buf[curpos-1];
+           buf[curpos-1] = buf[curpos-2];
+           buf[curpos-2] = j;
+         }
+         else 
+         {
+           buf[curpos] = buf[curpos-1];
+           buf[curpos-1] = j;
+         }
+         redraw = M_REDRAW_LINE;
+         break;
+
        default:
          BEEP ();
       }
index bcf77579aae68be1dda9758f6f14320375c8a447..28b84f3f76f0b979c687fc085ebec35ae61a6878 100644 (file)
@@ -365,6 +365,7 @@ struct binding_t OpEditor[] = {
   { "buffy-cycle",     OP_EDITOR_BUFFY_CYCLE,          " " },
   { "history-up",      OP_EDITOR_HISTORY_UP,           NULL },
   { "history-down",    OP_EDITOR_HISTORY_DOWN,         NULL },
+  { "transpose-chars", OP_EDITOR_TRANSPOSE_CHARS,      NULL },
   { NULL,              0,                              NULL }
 };