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
9 - 2008-08-02 myon: move set_xterm_* prototypes into the proper header file
10 (cleaner code, no functional change, evades conflict with sidebar patch)
15 @@ -112,6 +112,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 @@ -574,6 +587,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);
51 @@ -145,6 +145,8 @@ WHERE char *Tempdir;
55 +WHERE char *XtermTitle;
56 +WHERE char *XtermIcon;
58 WHERE char *CurrentFolder;
59 WHERE char *LastFolder;
62 @@ -1870,6 +1870,26 @@ static int parse_set (BUFFER *tmp, BUFFE
63 toggle_option (MuttVars[idx].data);
65 set_option (MuttVars[idx].data);
67 + /* sanity check for xterm */
68 + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0)
69 + && option (OPTXTERMSETTITLES))
71 + char *ep = getenv ("TERM");
72 + /* Make sure that the terminal can take the control codes */
73 + if (ep == NULL) unset_option (MuttVars[idx].data);
74 + else if (mutt_strncasecmp (ep, "xterm", 5) &&
75 + mutt_strncasecmp (ep, "color-xterm", 11) &&
76 + mutt_strncasecmp (ep, "eterm", 5) &&
77 + mutt_strncasecmp (ep, "kterm", 5) &&
78 + mutt_strncasecmp (ep, "nxterm", 6) &&
79 + mutt_strncasecmp (ep, "putty", 5) &&
80 + mutt_strncasecmp (ep, "screen", 6) &&
81 + mutt_strncasecmp (ep, "cygwin", 6) &&
82 + mutt_strncasecmp (ep, "rxvt", 4) )
83 + unset_option (MuttVars[idx]. data);
87 else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
88 DTYPE (MuttVars[idx].type) == DT_PATH ||
91 @@ -3104,6 +3104,27 @@ struct option_t MuttVars[] = {
92 ** option does nothing: mutt will never write out the BCC header
95 + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"},
98 + ** Controls the format of the icon title, as long as xterm_set_titles
99 + ** is enabled. This string is identical in formatting to the one used by
100 + ** ``$$status_format''.
102 + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
103 + /* The default must be off to force in the validity checking. */
106 + ** Controls whether mutt sets the xterm title bar and icon name
107 + ** (as long as you are in an appropriate terminal).
109 + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
112 + ** Controls the format of the title bar of the xterm provided that
113 + ** xterm_set_titles has been set. This string is identical in formatting
114 + ** to the one used by ``$$status_format''.
121 @@ -458,6 +458,7 @@ enum
123 OPTWRITEBCC, /* write out a bcc header? */
131 @@ -1767,6 +1767,13 @@ mutt_pager (const char *banner, const ch
132 mutt_paddstr (COLS, IsHeader (extra) || IsMsgAttach (extra) ? buffer : banner);
133 BKGDSET (MT_COLOR_NORMAL);
134 SETCOLOR (MT_COLOR_NORMAL);
135 + if (option(OPTXTERMSETTITLES))
137 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
138 + set_xterm_title_bar(buffer);
139 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
140 + set_xterm_icon_name(buffer);
144 if ((redraw & REDRAW_INDEX) && index)
147 @@ -195,6 +195,8 @@ status_format_str (char *buf, size_t buf
153 if (menu->top + menu->pagelen >= menu->max)
154 cp = menu->top ? "end" : "all";
158 @@ -103,6 +103,8 @@ void menu_current_middle (MUTTMENU *);
159 void menu_current_bottom (MUTTMENU *);
160 void menu_check_recenter (MUTTMENU *);
161 void menu_status_line (char *, size_t, MUTTMENU *, const char *);
162 +void set_xterm_title_bar (char *title);
163 +void set_xterm_icon_name (char *name);
165 MUTTMENU *mutt_new_menu (void);
166 void mutt_menuDestroy (MUTTMENU **);
170 +patch-1.5.13.nt+ab.xtitles.4