]> granicus.if.org Git - mutt/commitdiff
Introduce tag-prefix-cond and end-cond. This makes simple
authorNicolas Rachinsky <nr@rachinsky.de>
Fri, 4 Jul 2003 17:07:22 +0000 (17:07 +0000)
committerNicolas Rachinsky <nr@rachinsky.de>
Fri, 4 Jul 2003 17:07:22 +0000 (17:07 +0000)
conditional execution of parts of macros possible.

OPS
curs_lib.c
curs_main.c
functions.h
menu.c

diff --git a/OPS b/OPS
index ddb2022da53772fa713b7d0e470dc94b01f3f9ca..f090fb2c715f568b75887df139a66fb826563eeb 100644 (file)
--- a/OPS
+++ b/OPS
@@ -1,4 +1,5 @@
 OP_NULL "null operation"
+OP_END_COND "end of conditional execution (noop)"
 OP_ATTACH_VIEW_MAILCAP "force viewing of attachment using mailcap"
 OP_ATTACH_VIEW_TEXT "view attachment as text"
 OP_ATTACH_COLLAPSE "Toggle display of subparts"
@@ -156,6 +157,7 @@ OP_SORT "sort messages"
 OP_SORT_REVERSE "sort messages in reverse order"
 OP_TAG "tag the current entry"
 OP_TAG_PREFIX "apply next function to tagged messages"
+OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages"
 OP_TAG_SUBTHREAD "tag the current subthread"
 OP_TAG_THREAD "tag the current thread"
 OP_TOGGLE_NEW "toggle a message's 'new' flag"
index 0bb9f3b35ac2abfe9c5fac5ba01ae51390922cfe..ba120bd4d099a97ad2ef3b0e70d2ea88dcca03a2 100644 (file)
@@ -39,7 +39,7 @@
  * is impossible to unget function keys in SLang, so roll our own input
  * buffering routines.
  */
-static size_t UngetCount = 0;
+size_t UngetCount = 0;
 static size_t UngetBufLen = 0;
 static event_t *KeyEvent;
 
index 2bc3b5936f8ddbb0f9772e0a4797483a3b004312..cf6188957b25ebae93851e6dcdfc8ee161864270 100644 (file)
@@ -101,6 +101,7 @@ static const char *No_visible = N_("No visible messages.");
 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
 
 extern const char *ReleaseDate;
+extern size_t UngetCount;
 
 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
 {
@@ -632,6 +633,40 @@ int mutt_index_menu (void)
       else if (option (OPTAUTOTAG) && Context && Context->tagged)
        tag = 1;
 
+      if (op == OP_TAG_PREFIX_COND)
+      {
+       if (!Context)
+       {
+         mutt_error _("No mailbox is open.");
+         continue;
+       }
+
+       if (!Context->tagged)
+       {
+         event_t tmp;
+         while(UngetCount>0)
+         {
+           tmp=mutt_getch();
+           if(tmp.op==OP_END_COND)break;
+         }
+         mutt_message  _("Nothing to do.");
+         continue;
+       }
+       tag = 1;
+
+       /* give visual indication that the next command is a tag- command */
+       mvaddstr (LINES - 1, 0, "tag-");
+       clrtoeol ();
+
+       /* get the real command */
+       if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX)
+       {
+         /* abort tag sequence */
+         CLEARLINE (LINES-1);
+         continue;
+       }
+      }
+
       mutt_clear_error ();
     }
     else
@@ -2026,6 +2061,9 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
        menu->redraw = REDRAW_FULL;
        break;
 
+      case OP_END_COND:
+       break;
+
       case OP_WHAT_KEY:
        mutt_what_key();
        break;
index 94791f216b86ec45e1d0943cb5b996f2e54bdbde..a302112613946bbf0fed73948ef8e35061065405 100644 (file)
@@ -51,6 +51,8 @@ struct binding_t OpGeneric[] = {
   { "half-down",       OP_HALF_DOWN,           "]" },
   { "help",            OP_HELP,                "?" },
   { "tag-prefix",      OP_TAG_PREFIX,          ";" },
+  { "tag-prefix-cond", OP_TAG_PREFIX_COND,     NULL },
+  { "end-cond",                OP_END_COND,            NULL },
   { "shell-escape",    OP_SHELL_ESCAPE,        "!" },
   { "select-entry",    OP_GENERIC_SELECT_ENTRY,M_ENTER_S },
   { "search",          OP_SEARCH,              "/" },
diff --git a/menu.c b/menu.c
index d9212b8a72bbda65327b54b8c1f6841adfd5f0eb..97636362db7556f18318b9662ba2e6fab83840a3 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -30,6 +30,8 @@
 
 extern int Charset_is_utf8; /* FIXME: bad modularisation */
 
+extern size_t UngetCount;
+
 static void print_enriched_string (int attr, unsigned char *s, int do_color)
 {
   wchar_t wc;
@@ -870,6 +872,28 @@ int mutt_menuLoop (MUTTMENU *menu)
        i = -1;
       }
     }
+    if (i == OP_TAG_PREFIX_COND)
+    {
+      if (menu->tagged)
+      {
+       mvaddstr (LINES - 1, 0, "Tag-");
+       clrtoeol ();
+       i = km_dokey (menu->menu);
+       menu->tagprefix = 1;
+       CLEARLINE (LINES - 1);
+      }
+      else 
+      {
+       event_t tmp;
+       while(UngetCount>0)
+       {
+         tmp=mutt_getch();
+         if(tmp.op==OP_END_COND)break;
+       }
+       mutt_message _("Nothing to do.");
+       i = -1;
+      }
+    }
     else if (menu->tagged && option (OPTAUTOTAG))
       menu->tagprefix = 1;
     else
@@ -1032,6 +1056,9 @@ int mutt_menuLoop (MUTTMENU *menu)
        km_error_key (menu->menu);
        break;
 
+      case OP_END_COND:
+       break;
+
       default:
        return (i);
     }