2 This is the xterm title patch as found on the mutt mailing lists.
5 - 2007-01-27 myon: using %P caused a segfault, updated status.c to catch
7 - 2007-02-20 myon: make the note about the xterm_set_titles defaults a
12 ===================================================================
13 --- mutt/PATCHES.orig 2007-02-20 16:46:09.943601256 +0100
14 +++ mutt/PATCHES 2007-02-20 16:46:09.943601256 +0100
16 +patch-1.5.13.nt+ab.xtitles.4
17 Index: mutt/curs_main.c
18 ===================================================================
19 --- mutt.orig/curs_main.c 2006-12-12 14:15:02.000000000 +0100
20 +++ mutt/curs_main.c 2007-02-20 16:53:27.211126488 +0100
21 @@ -110,6 +110,19 @@ static const char *No_visible = N_("No v
23 extern size_t UngetCount;
25 +#define ASCII_CTRL_G 0x07
26 +#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
28 +void set_xterm_title_bar(char *title)
30 + fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
33 +void set_xterm_icon_name(char *name)
35 + fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
38 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
40 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
41 @@ -568,6 +581,13 @@ int mutt_index_menu (void)
42 SETCOLOR (MT_COLOR_NORMAL);
43 BKGDSET (MT_COLOR_NORMAL);
44 menu->redraw &= ~REDRAW_STATUS;
45 + if (option(OPTXTERMSETTITLES))
47 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
48 + set_xterm_title_bar(buf);
49 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
50 + set_xterm_icon_name(buf);
56 ===================================================================
57 --- mutt.orig/globals.h 2007-01-04 15:23:49.000000000 +0100
58 +++ mutt/globals.h 2007-01-27 19:33:32.000000000 +0100
59 @@ -137,6 +137,8 @@ WHERE char *Tempdir;
63 +WHERE char *XtermTitle;
64 +WHERE char *XtermIcon;
66 WHERE char *CurrentFolder;
67 WHERE char *LastFolder;
69 ===================================================================
70 --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100
71 +++ mutt/init.c 2007-01-27 19:33:32.000000000 +0100
72 @@ -1747,6 +1747,26 @@ static int parse_set (BUFFER *tmp, BUFFE
73 toggle_option (MuttVars[idx].data);
75 set_option (MuttVars[idx].data);
77 + /* sanity check for xterm */
78 + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0)
79 + && option (OPTXTERMSETTITLES))
81 + char *ep = getenv ("TERM");
82 + /* Make sure that the terminal can take the control codes */
83 + if (ep == NULL) unset_option (MuttVars[idx].data);
84 + else if (mutt_strncasecmp (ep, "xterm", 5) &&
85 + mutt_strncasecmp (ep, "color-xterm", 11) &&
86 + mutt_strncasecmp (ep, "eterm", 5) &&
87 + mutt_strncasecmp (ep, "kterm", 5) &&
88 + mutt_strncasecmp (ep, "nxterm", 6) &&
89 + mutt_strncasecmp (ep, "putty", 5) &&
90 + mutt_strncasecmp (ep, "screen", 6) &&
91 + mutt_strncasecmp (ep, "cygwin", 6) &&
92 + mutt_strncasecmp (ep, "rxvt", 4) )
93 + unset_option (MuttVars[idx]. data);
97 else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
98 DTYPE (MuttVars[idx].type) == DT_PATH ||
100 ===================================================================
101 --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100
102 +++ mutt/init.h 2007-02-20 16:47:02.718578240 +0100
103 @@ -2941,6 +2941,27 @@ struct option_t MuttVars[] = {
104 ** Controls whether mutt writes out the Bcc header when preparing
105 ** messages to be sent. Exim users may wish to unset this.
107 + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"},
110 + ** Controls the format of the icon title, as long as xterm_set_titles
111 + ** is enabled. This string is identical in formatting to the one used by
112 + ** ``$$status_format''.
114 + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
115 + /* The default must be off to force in the validity checking. */
118 + ** Controls whether mutt sets the xterm title bar and icon name
119 + ** (as long as you are in an appropriate terminal).
121 + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
124 + ** Controls the format of the title bar of the xterm provided that
125 + ** xterm_set_titles has been set. This string is identical in formatting
126 + ** to the one used by ``$$status_format''.
132 ===================================================================
133 --- mutt.orig/mutt.h 2007-01-04 15:23:49.000000000 +0100
134 +++ mutt/mutt.h 2007-01-27 19:33:32.000000000 +0100
135 @@ -451,6 +451,7 @@ enum
137 OPTWRITEBCC, /* write out a bcc header? */
144 ===================================================================
145 --- mutt.orig/pager.c 2006-12-12 14:15:03.000000000 +0100
146 +++ mutt/pager.c 2007-01-27 19:33:32.000000000 +0100
151 +void set_xterm_title_bar(char *title);
152 +void set_xterm_icon_name(char *name);
156 @@ -1765,6 +1767,13 @@ mutt_pager (const char *banner, const ch
157 addstr (topline == 0 ? "all)" : "end)");
158 BKGDSET (MT_COLOR_NORMAL);
159 SETCOLOR (MT_COLOR_NORMAL);
160 + if (option(OPTXTERMSETTITLES))
162 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
163 + set_xterm_title_bar(buffer);
164 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
165 + set_xterm_icon_name(buffer);
169 if ((redraw & REDRAW_INDEX) && index)
171 ===================================================================
172 --- mutt.orig/status.c 2007-01-27 19:33:36.000000000 +0100
173 +++ mutt/status.c 2007-01-27 19:34:11.000000000 +0100
174 @@ -191,6 +191,8 @@ status_format_str (char *buf, size_t buf
180 if (menu->top + menu->pagelen >= menu->max)
181 cp = menu->top ? "end" : "all";