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
10 ===================================================================
11 --- mutt.orig/PATCHES 2007-01-27 19:33:32.932962104 +0100
12 +++ mutt/PATCHES 2007-01-27 19:33:32.932962104 +0100
14 +patch-1.5.13.nt+ab.xtitles.4
15 Index: mutt/curs_main.c
16 ===================================================================
17 --- mutt.orig/curs_main.c 2006-12-12 14:15:02.000000000 +0100
18 +++ mutt/curs_main.c 2007-01-27 19:33:32.933961952 +0100
19 @@ -110,6 +110,19 @@ static const char *No_visible = N_("No v
21 extern size_t UngetCount;
23 +#define ASCII_CTRL_G 0x07
24 +#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
26 +void set_xterm_title_bar(char *title)
28 + fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
31 +void set_xterm_icon_name(char *name)
33 + fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
36 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
38 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
39 @@ -568,6 +581,13 @@ int mutt_index_menu (void)
40 SETCOLOR (MT_COLOR_NORMAL);
41 BKGDSET (MT_COLOR_NORMAL);
42 menu->redraw &= ~REDRAW_STATUS;
43 + if (option(OPTXTERMSETTITLES))
45 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
46 + set_xterm_title_bar(buf);
47 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
48 + set_xterm_icon_name(buf);
54 ===================================================================
55 --- mutt.orig/globals.h 2007-01-04 15:23:49.000000000 +0100
56 +++ mutt/globals.h 2007-01-27 19:33:32.933961952 +0100
57 @@ -137,6 +137,8 @@ WHERE char *Tempdir;
61 +WHERE char *XtermTitle;
62 +WHERE char *XtermIcon;
64 WHERE char *CurrentFolder;
65 WHERE char *LastFolder;
67 ===================================================================
68 --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100
69 +++ mutt/init.c 2007-01-27 19:33:32.934961800 +0100
70 @@ -1747,6 +1747,26 @@ static int parse_set (BUFFER *tmp, BUFFE
71 toggle_option (MuttVars[idx].data);
73 set_option (MuttVars[idx].data);
75 + /* sanity check for xterm */
76 + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0)
77 + && option (OPTXTERMSETTITLES))
79 + char *ep = getenv ("TERM");
80 + /* Make sure that the terminal can take the control codes */
81 + if (ep == NULL) unset_option (MuttVars[idx].data);
82 + else if (mutt_strncasecmp (ep, "xterm", 5) &&
83 + mutt_strncasecmp (ep, "color-xterm", 11) &&
84 + mutt_strncasecmp (ep, "eterm", 5) &&
85 + mutt_strncasecmp (ep, "kterm", 5) &&
86 + mutt_strncasecmp (ep, "nxterm", 6) &&
87 + mutt_strncasecmp (ep, "putty", 5) &&
88 + mutt_strncasecmp (ep, "screen", 6) &&
89 + mutt_strncasecmp (ep, "cygwin", 6) &&
90 + mutt_strncasecmp (ep, "rxvt", 4) )
91 + unset_option (MuttVars[idx]. data);
95 else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
96 DTYPE (MuttVars[idx].type) == DT_PATH ||
98 ===================================================================
99 --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100
100 +++ mutt/init.h 2007-01-27 19:33:32.936961496 +0100
101 @@ -2941,6 +2941,27 @@ struct option_t MuttVars[] = {
102 ** Controls whether mutt writes out the Bcc header when preparing
103 ** messages to be sent. Exim users may wish to unset this.
105 + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"},
108 + ** Controls the format of the icon title, as long as xterm_set_titles
109 + ** is enabled. This string is identical in formatting to the one used by
110 + ** ``$$status_format''.
112 + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
115 + ** Controls whether mutt sets the xterm title bar and icon name
116 + ** (as long as you're in an appropriate terminal). The default must
117 + ** be off to force in the validity checking.
119 + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
122 + ** Controls the format of the title bar of the xterm provided that
123 + ** xterm_set_titles has been set. This string is identical in formatting
124 + ** to the one used by ``$$status_format''.
130 ===================================================================
131 --- mutt.orig/mutt.h 2007-01-04 15:23:49.000000000 +0100
132 +++ mutt/mutt.h 2007-01-27 19:33:32.936961496 +0100
133 @@ -451,6 +451,7 @@ enum
135 OPTWRITEBCC, /* write out a bcc header? */
142 ===================================================================
143 --- mutt.orig/pager.c 2006-12-12 14:15:03.000000000 +0100
144 +++ mutt/pager.c 2007-01-27 19:33:32.937961344 +0100
149 +void set_xterm_title_bar(char *title);
150 +void set_xterm_icon_name(char *name);
154 @@ -1765,6 +1767,13 @@ mutt_pager (const char *banner, const ch
155 addstr (topline == 0 ? "all)" : "end)");
156 BKGDSET (MT_COLOR_NORMAL);
157 SETCOLOR (MT_COLOR_NORMAL);
158 + if (option(OPTXTERMSETTITLES))
160 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
161 + set_xterm_title_bar(buffer);
162 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
163 + set_xterm_icon_name(buffer);
167 if ((redraw & REDRAW_INDEX) && index)
169 ===================================================================
170 --- mutt.orig/status.c 2007-01-27 19:33:36.429430560 +0100
171 +++ mutt/status.c 2007-01-27 19:34:11.072164064 +0100
172 @@ -191,6 +191,8 @@ status_format_str (char *buf, size_t buf
178 if (menu->top + menu->pagelen >= menu->max)
179 cp = menu->top ? "end" : "all";