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
11 Index: mutt/curs_main.c
12 ===================================================================
13 --- mutt.orig/curs_main.c 2006-12-12 14:15:02.000000000 +0100
14 +++ mutt/curs_main.c 2007-02-20 16:53:27.211126488 +0100
15 @@ -110,6 +110,19 @@ static const char *No_visible = N_("No v
17 extern size_t UngetCount;
19 +#define ASCII_CTRL_G 0x07
20 +#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
22 +void set_xterm_title_bar(char *title)
24 + fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
27 +void set_xterm_icon_name(char *name)
29 + fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
32 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
34 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
35 @@ -568,6 +581,13 @@ int mutt_index_menu (void)
36 SETCOLOR (MT_COLOR_NORMAL);
37 BKGDSET (MT_COLOR_NORMAL);
38 menu->redraw &= ~REDRAW_STATUS;
39 + if (option(OPTXTERMSETTITLES))
41 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
42 + set_xterm_title_bar(buf);
43 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
44 + set_xterm_icon_name(buf);
50 ===================================================================
51 --- mutt.orig/globals.h 2007-01-04 15:23:49.000000000 +0100
52 +++ mutt/globals.h 2007-01-27 19:33:32.000000000 +0100
53 @@ -137,6 +137,8 @@ WHERE char *Tempdir;
57 +WHERE char *XtermTitle;
58 +WHERE char *XtermIcon;
60 WHERE char *CurrentFolder;
61 WHERE char *LastFolder;
63 ===================================================================
64 --- mutt.orig/init.c 2006-12-12 14:15:03.000000000 +0100
65 +++ mutt/init.c 2007-01-27 19:33:32.000000000 +0100
66 @@ -1747,6 +1747,26 @@ static int parse_set (BUFFER *tmp, BUFFE
67 toggle_option (MuttVars[idx].data);
69 set_option (MuttVars[idx].data);
71 + /* sanity check for xterm */
72 + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0)
73 + && option (OPTXTERMSETTITLES))
75 + char *ep = getenv ("TERM");
76 + /* Make sure that the terminal can take the control codes */
77 + if (ep == NULL) unset_option (MuttVars[idx].data);
78 + else if (mutt_strncasecmp (ep, "xterm", 5) &&
79 + mutt_strncasecmp (ep, "color-xterm", 11) &&
80 + mutt_strncasecmp (ep, "eterm", 5) &&
81 + mutt_strncasecmp (ep, "kterm", 5) &&
82 + mutt_strncasecmp (ep, "nxterm", 6) &&
83 + mutt_strncasecmp (ep, "putty", 5) &&
84 + mutt_strncasecmp (ep, "screen", 6) &&
85 + mutt_strncasecmp (ep, "cygwin", 6) &&
86 + mutt_strncasecmp (ep, "rxvt", 4) )
87 + unset_option (MuttVars[idx]. data);
91 else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
92 DTYPE (MuttVars[idx].type) == DT_PATH ||
94 ===================================================================
95 --- mutt.orig/init.h 2006-12-12 14:15:03.000000000 +0100
96 +++ mutt/init.h 2007-02-20 16:47:02.718578240 +0100
97 @@ -2941,6 +2941,27 @@ struct option_t MuttVars[] = {
98 ** Controls whether mutt writes out the Bcc header when preparing
99 ** messages to be sent. Exim users may wish to unset this.
101 + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"},
104 + ** Controls the format of the icon title, as long as xterm_set_titles
105 + ** is enabled. This string is identical in formatting to the one used by
106 + ** ``$$status_format''.
108 + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
109 + /* The default must be off to force in the validity checking. */
112 + ** Controls whether mutt sets the xterm title bar and icon name
113 + ** (as long as you are in an appropriate terminal).
115 + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
118 + ** Controls the format of the title bar of the xterm provided that
119 + ** xterm_set_titles has been set. This string is identical in formatting
120 + ** to the one used by ``$$status_format''.
126 ===================================================================
127 --- mutt.orig/mutt.h 2007-01-04 15:23:49.000000000 +0100
128 +++ mutt/mutt.h 2007-01-27 19:33:32.000000000 +0100
129 @@ -451,6 +451,7 @@ enum
131 OPTWRITEBCC, /* write out a bcc header? */
138 ===================================================================
139 --- mutt.orig/pager.c 2006-12-12 14:15:03.000000000 +0100
140 +++ mutt/pager.c 2007-01-27 19:33:32.000000000 +0100
145 +void set_xterm_title_bar(char *title);
146 +void set_xterm_icon_name(char *name);
150 @@ -1765,6 +1767,13 @@ mutt_pager (const char *banner, const ch
151 addstr (topline == 0 ? "all)" : "end)");
152 BKGDSET (MT_COLOR_NORMAL);
153 SETCOLOR (MT_COLOR_NORMAL);
154 + if (option(OPTXTERMSETTITLES))
156 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
157 + set_xterm_title_bar(buffer);
158 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
159 + set_xterm_icon_name(buffer);
163 if ((redraw & REDRAW_INDEX) && index)
165 ===================================================================
166 --- mutt.orig/status.c 2007-01-27 19:33:36.000000000 +0100
167 +++ mutt/status.c 2007-01-27 19:34:11.000000000 +0100
168 @@ -191,6 +191,8 @@ status_format_str (char *buf, size_t buf
174 if (menu->top + menu->pagelen >= menu->max)
175 cp = menu->top ? "end" : "all";
180 +patch-1.5.13.nt+ab.xtitles.4