Andreas Krennmair:
authorak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 9 Jan 2005 15:27:45 +0000 (15:27 +0000)
committerak1 <ak1@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 9 Jan 2005 15:27:45 +0000 (15:27 +0000)
integrated xterm title patch from SGI

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@9 e385b8ad-14ed-0310-8656-cc95a2468c6d

ChangeLog.mutt-ng
curs_main.c
globals.h
init.h
mutt.h

index 43d02a3..caab6d5 100644 (file)
@@ -11,5 +11,6 @@ Changes specific to mutt-ng:
     * cd.purge_message patch
     * vvv.quote patch
     * vvv.nntp patch
+    * xterm title patch from SGI (http://freeware.sgi.com/source/mutt/)
   * fixed missing decoding of partially wrong RFC2047 headers (handling was too strict)
   * fixed wrong display of ISO-8859-1 names by removing parts of the multibyte-character handling
index 97640d6..25b20e0 100644 (file)
@@ -109,6 +109,22 @@ static const char *No_visible = N_("No visible messages.");
 extern const char *ReleaseDate;
 extern size_t UngetCount;
 
+static void set_xterm_title_bar(char *title)
+{
+  fputs("\033]2;", stdout);
+  fputs(title, stdout);
+  fputs("\007", stdout);
+  fflush(stdout);
+}
+
+static void set_xterm_icon_name(char *name)
+{
+  fputs("\033]1;", stdout);
+  fputs(name, stdout);
+  fputs("\007", stdout);
+  fflush(stdout);
+}
+
 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;
@@ -590,6 +606,13 @@ int mutt_index_menu (void)
         mutt_paddstr (COLS, buf);
         SETCOLOR (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;
index 303d1c6..60bb90e 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -130,6 +130,8 @@ WHERE char *Tochars;
 WHERE char *TrashPath;
 WHERE char *Username;
 WHERE char *Visual;
+WHERE char *XtermTitle;
+WHERE char *XtermIcon;
 
 WHERE char *LastFolder;
 
diff --git a/init.h b/init.h
index 2c1c28d..6146758 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2920,6 +2920,27 @@ struct option_t MuttVars[] = {
   ** Controls whether mutt writes out the Bcc header when preparing
   ** messages to be sent.  Exim users may wish to use this.
   */
+  {"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''.
+  */
 #ifdef USE_NNTP
   { "x_comment_to",   DT_BOOL, R_NONE, OPTXCOMMENTTO, 0 },
   /*
diff --git a/mutt.h b/mutt.h
index 1a86497..6a6b036 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -447,6 +447,7 @@ enum
   OPTWRAPSEARCH,
   OPTWRITEBCC,         /* write out a bcc header? */
   OPTXMAILER,
+  OPTXTERMSETTITLES,
 
   /* PGP options */