[PATCH] Add $status_hook for xterm title updates
- To: Mutt Developers <mutt-dev@xxxxxxxx>
- Subject: [PATCH] Add $status_hook for xterm title updates
- From: Brendan Cully <brendan@xxxxxxxxxx>
- Date: Fri, 02 Mar 2007 20:25:05 -0800
- Dkim-signature: a=rsa-sha1; c=relaxed; d=kublai.com; h=received:received:received:content-type:mime-version:content-transfer-encoding:subject:x-mercurial-node:message-id:date:to:from:x-delivery-agent; q=dns; s=dk; bh=r44fQRH57s1eMMGBjAbPaBf9Dy8=; b=CWZ8WsRMxjXTi7jx6MGbvPxplliYn2/mk3OAsf8J0jcxDV73c7PeUfI8cPsdhS7c21SW+HFjY9InMXPyt0FQZ1eMEizceKm0meitXM7yAI1q8oyLZmy3wssDxl4evtYxNypMPNU/uP59KaI99yVfCmjwLfhNGvZfOvWsEDWDcZw=
- List-unsubscribe: <mailto:mutt-dev-request@mutt.org?Subject="Unsubscribe Mutt Dev"?body=unsubscribe>
- Sender: owner-mutt-dev@xxxxxxxx
# 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;
+}