<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Add $status_hook for xterm title updates



# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxxx>
# Date 1172895865 28800
# Node ID c36482e98b8130395c5697c21d060690b57d58e4
# Parent  256c86830a368e944b0305258e20b670eb0aea75
Add $status_hook for xterm title updates.

If $status_hook is set, the command it points to will be called and
given the expanded $status_format on stdin.

diff -r 256c86830a36 -r c36482e98b81 curs_main.c
--- a/curs_main.c       Fri Mar 02 11:09:12 2007 -0800
+++ b/curs_main.c       Fri Mar 02 20:24:25 2007 -0800
@@ -568,6 +568,7 @@ int mutt_index_menu (void)
        SETCOLOR (MT_COLOR_NORMAL);
         BKGDSET (MT_COLOR_NORMAL);
        menu->redraw &= ~REDRAW_STATUS;
+       status_hook (buf);
       }
 
       menu->redraw = 0;
diff -r 256c86830a36 -r c36482e98b81 globals.h
--- a/globals.h Fri Mar 02 11:09:12 2007 -0800
+++ b/globals.h Fri Mar 02 20:24:25 2007 -0800
@@ -140,6 +140,7 @@ WHERE char *SslCACertFile INITVAL (NULL)
 #endif
 WHERE char *StChars;
 WHERE char *Status;
+WHERE char *StatusHook;
 WHERE char *Tempdir;
 WHERE char *Tochars;
 WHERE char *Username;
diff -r 256c86830a36 -r c36482e98b81 init.h
--- a/init.h    Fri Mar 02 11:09:12 2007 -0800
+++ b/init.h    Fri Mar 02 20:24:25 2007 -0800
@@ -2807,6 +2807,13 @@ struct option_t MuttVars[] = {
   ** If you prefix the sequence character with a colon (:) character, mutt
   ** will replace any dots in the expansion by underscores. This might be 
helpful 
   ** with IMAP folders that don't like dots in folder names.
+  */
+  { "status_hook", DT_PATH, R_NONE, UL &StatusHook, UL 0 },
+  /*
+  ** .pp
+  ** If this variable is set, mutt will call the program it points to
+  ** with the status string as its standard input. This can be used to
+  ** set the xterm title bar, for example.
   */
   { "status_on_top",   DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0 },
   /*
diff -r 256c86830a36 -r c36482e98b81 mutt_menu.h
--- a/mutt_menu.h       Fri Mar 02 11:09:12 2007 -0800
+++ b/mutt_menu.h       Fri Mar 02 20:24:25 2007 -0800
@@ -104,6 +104,8 @@ void menu_check_recenter (MUTTMENU *);
 void menu_check_recenter (MUTTMENU *);
 void menu_status_line (char *, size_t, MUTTMENU *, const char *);
 
+int status_hook (const char *);
+
 MUTTMENU *mutt_new_menu (void);
 void mutt_menuDestroy (MUTTMENU **);
 int mutt_menuLoop (MUTTMENU *);
diff -r 256c86830a36 -r c36482e98b81 pager.c
--- a/pager.c   Fri Mar 02 11:09:12 2007 -0800
+++ b/pager.c   Fri Mar 02 20:24:25 2007 -0800
@@ -1782,6 +1782,8 @@ mutt_pager (const char *banner, const ch
       mutt_paddstr (COLS, buffer);
       SETCOLOR (MT_COLOR_NORMAL);
       BKGDSET (MT_COLOR_NORMAL);
+
+      status_hook (buffer);
     }
 
     redraw = 0;
diff -r 256c86830a36 -r c36482e98b81 status.c
--- a/status.c  Fri Mar 02 11:09:12 2007 -0800
+++ b/status.c  Fri Mar 02 20:24:25 2007 -0800
@@ -297,3 +297,22 @@ void menu_status_line (char *buf, size_t
 {
   mutt_FormatString (buf, buflen, p, status_format_str, (unsigned long) menu, 
0);
 }
+
+int status_hook (const char *buf)
+{
+  FILE* out;
+  pid_t pid;
+  int rc = -1;
+
+  if (StatusHook && *StatusHook)
+  {
+    if ((pid = mutt_create_filter (StatusHook, &out, NULL, NULL)) > 0)
+    {
+      fwrite (buf, 1, mutt_strlen (buf), out);
+      fclose (out);
+      rc = mutt_wait_filter (pid);
+    }
+  }
+
+  return rc;
+}