Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > 00439071878a5f05ae6865091f62cce0 > files > 11

mutt-1.5.21-3.2.mga1.src.rpm

diff -Naurp mutt-1.5.18/curs_main.c mutt-1.5.18.oden/curs_main.c
--- mutt-1.5.18/curs_main.c	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/curs_main.c	2008-12-15 16:13:31.000000000 +0100
@@ -117,6 +117,19 @@ static const char *No_visible = N_("No v
 
 extern size_t UngetCount;
 
+#define ASCII_CTRL_G                  0x07
+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
+ 
+static void set_xterm_title_bar(char *title)
+{
+fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
+}
+
+static void set_xterm_icon_name(char *name)
+{
+fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
+}
+
 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
 {
   format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
@@ -598,6 +611,13 @@ int mutt_index_menu (void)
 	SETCOLOR (MT_COLOR_NORMAL);
         BKGDSET (MT_COLOR_NORMAL);
 	menu->redraw &= ~REDRAW_STATUS;
+        if (option(OPTXTERMSETTITLES))
+        {
+          menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
+          set_xterm_title_bar(buf);
+          menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
+          set_xterm_icon_name(buf);
+        }
       }
 
       menu->redraw = 0;
diff -Naurp mutt-1.5.18/globals.h mutt-1.5.18.oden/globals.h
--- mutt-1.5.18/globals.h	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/globals.h	2008-12-15 16:13:31.000000000 +0100
@@ -154,6 +154,8 @@ WHERE char *Tempdir;
 WHERE char *Tochars;
 WHERE char *Username;
 WHERE char *Visual;
+WHERE char *XtermTitle;
+WHERE char *XtermIcon;
 
 WHERE char *CurrentFolder;
 WHERE char *LastFolder;
diff -Naurp mutt-1.5.18/init.c mutt-1.5.18.oden/init.c
--- mutt-1.5.18/init.c	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/init.c	2008-12-15 16:13:31.000000000 +0100
@@ -1811,6 +1811,17 @@ static int parse_set (BUFFER *tmp, BUFFE
 	toggle_option (MuttVars[idx].data);
       else
 	set_option (MuttVars[idx].data);
+
+      /* sanity check for xterm */
+      if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) && option
+ (OPTXTERMSETTITLES))
+      {
+        char *ep = getenv ("TERM");
+        /* Make sure that the terminal can take the control codes */
+        if (ep == NULL) unset_option (MuttVars[idx].data);
+        else if (mutt_strcasecmp (ep, "xterm") != 0) unset_option (MuttVars[idx].
+data);
+      }
     }
     else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
 	     DTYPE (MuttVars[idx].type) == DT_PATH ||
diff -Naurp mutt-1.5.18/init.h mutt-1.5.18.oden/init.h
--- mutt-1.5.18/init.h	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/init.h	2008-12-15 16:13:31.000000000 +0100
@@ -3286,6 +3286,27 @@ struct option_t MuttVars[] = {
   ** name of original article author) to article that followuped to newsgroup.
   */
 #endif
+  {"xterm_icon",       DT_STR,   R_BOTH, UL &XtermIcon,  UL "M%?n?AIL&ail?"},
+  /*
+  ** .pp
+  ** Controls the format of the icon title, as long as xterm_set_titles
+  ** is enabled. This string is identical in formatting to the one used by
+  ** ``$$status_format''.
+  */
+  {"xterm_set_titles", DT_BOOL,  R_BOTH, OPTXTERMSETTITLES, 0},
+  /*
+  ** .pp
+  ** Controls whether mutt sets the xterm title bar and icon name
+  ** (as long as you're in an appropriate terminal). The default must
+  ** be off to force in the validity checking.
+  */
+  {"xterm_title",      DT_STR,   R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
+  /*
+  ** .pp
+  ** Controls the format of the title bar of the xterm provided that
+  ** xterm_set_titles has been set. This string is identical in formatting
+  ** to the one used by ``$$status_format''.
+  */
   /*--*/
   { NULL }
 };
diff -Naurp mutt-1.5.18/mutt.h mutt-1.5.18.oden/mutt.h
--- mutt-1.5.18/mutt.h	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/mutt.h	2008-12-15 16:13:31.000000000 +0100
@@ -477,6 +477,7 @@ enum
   OPTWRAPSEARCH,
   OPTWRITEBCC,		/* write out a bcc header? */
   OPTXMAILER,
+  OPTXTERMSETTITLES,
 
   OPTCRYPTUSEGPGME,
   OPTCRYPTUSEPKA,
diff -Naurp mutt-1.5.18/pager.c mutt-1.5.18.oden/pager.c
--- mutt-1.5.18/pager.c	2008-12-15 16:13:47.000000000 +0100
+++ mutt-1.5.18.oden/pager.c	2008-12-15 16:13:31.000000000 +0100
@@ -90,6 +90,19 @@ static HEADER *OldHdr = NULL;
 			break; \
 		}
 
+#define ASCII_CTRL_G                  0x07
+#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
+
+static void set_xterm_title_bar(char *title)
+{
+  fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
+}
+
+static void set_xterm_icon_name(char *name)
+{
+  fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
+}
+
 struct q_class_t
 {
   int length;
@@ -1790,6 +1803,13 @@ mutt_pager (const char *banner, const ch
       mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ?  buffer : banner);
       BKGDSET (MT_COLOR_NORMAL);
       SETCOLOR (MT_COLOR_NORMAL);
+      if (option(OPTXTERMSETTITLES))
+      {
+	menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
+	set_xterm_title_bar(buffer);
+	menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
+	set_xterm_icon_name(buffer);
+      }
     }
 
     if ((redraw & REDRAW_INDEX) && index)