]> granicus.if.org Git - mutt/commitdiff
Add capitalize-word, upcase-word, downcase-word functions to the
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 27 Oct 2000 10:35:04 +0000 (10:35 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 27 Oct 2000 10:35:04 +0000 (10:35 +0000)
editor.  Bindings follow the Emacs conventions (i.e., M-c, M-u, M-d).

OPS
enter.c
functions.h

diff --git a/OPS b/OPS
index 046ef6086721917ec5ec42479944f062aca52ac7..b4d39a5b3bb69018a1a6ee8457c3c2d319c86912 100644 (file)
--- a/OPS
+++ b/OPS
@@ -73,6 +73,9 @@ 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_EDITOR_CAPITALIZE_WORD "capitalize the word"
+OP_EDITOR_DOWNCASE_WORD "convert the word to lower case"
+OP_EDITOR_UPCASE_WORD "convert the word to upper case"
 OP_ENTER_COMMAND "enter a muttrc command"
 OP_ENTER_MASK "enter a file mask"
 OP_EXIT "exit this menu"
diff --git a/enter.c b/enter.c
index a9307223aaa88eb8286585ad29bed2fbf664b276..6795ddc7263a75e5915cc507275875c195f3276d 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -331,6 +331,60 @@ int _mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x,
          }
          break;
 
+       case OP_EDITOR_CAPITALIZE_WORD:
+         if (curpos == lastchar)
+         {
+           BEEP ();
+           break;
+         }
+         while (curpos < lastchar && ISSPACE (buf[curpos]))
+           curpos++;
+         if (curpos < lastchar)
+         {
+           buf[curpos] = toupper (buf[curpos]);
+           curpos++;
+         }
+         if (curpos == lastchar || ISSPACE (buf[curpos]))
+         {       
+           if (!pass)
+           {
+             if (curpos >= begin + width)
+               begin = curpos - width / 2;
+             else
+               move (y, x + curpos - begin);
+             redraw = M_REDRAW_LINE;
+           }
+           break;
+         }
+         
+         /* fall through */
+       case OP_EDITOR_UPCASE_WORD:
+       case OP_EDITOR_DOWNCASE_WORD:
+         if (curpos == lastchar)
+         {
+           BEEP();
+           break;
+         }
+         while (curpos < lastchar && ISSPACE (buf[curpos]))
+           curpos++;
+         while (curpos < lastchar && !ISSPACE(buf[curpos]))
+         {
+           if (ch == OP_EDITOR_UPCASE_WORD)
+             buf[curpos] = toupper (buf[curpos]);
+           else /* DOWNCASE_WORD, CAPITALIZE_WORD */
+             buf[curpos] = tolower (buf[curpos]);
+           curpos++;
+         }
+         if (!pass)
+         {
+           if (curpos >= begin + width)
+             begin = curpos - width / 2;
+           else
+             move (y, x + curpos - begin);
+           redraw = M_REDRAW_LINE;
+         }
+         break;
+       
        case OP_EDITOR_DELETE_CHAR:
          if (curpos != lastchar)
          {
index 04993ae5a3c36829566fe90d7fdd9c6bcd83416c..3d57238b752413bcff7ec26b8827871ae8a36736 100644 (file)
@@ -351,6 +351,9 @@ struct binding_t OpEditor[] = {
   { "bol",             OP_EDITOR_BOL,                  "\001" },
   { "backward-char",   OP_EDITOR_BACKWARD_CHAR,        "\002" },
   { "backward-word",   OP_EDITOR_BACKWARD_WORD,        "\033b"},
+  { "capitalize-word", OP_EDITOR_CAPITALIZE_WORD,      "\033c"},
+  { "downcase-word",   OP_EDITOR_DOWNCASE_WORD,        "\033l"},
+  { "upcase-word",     OP_EDITOR_UPCASE_WORD,          "\033u"},
   { "delete-char",     OP_EDITOR_DELETE_CHAR,          "\004" },
   { "eol",             OP_EDITOR_EOL,                  "\005" },
   { "forward-char",    OP_EDITOR_FORWARD_CHAR,         "\006" },