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)
13 Index: mutt/curs_main.c
14 ===================================================================
15 --- mutt.orig/curs_main.c 2009-06-25 12:35:37.000000000 +0200
16 +++ mutt/curs_main.c 2009-06-25 12:35:44.000000000 +0200
19 extern size_t UngetCount;
21 +#define ASCII_CTRL_G 0x07
22 +#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b
24 +void set_xterm_title_bar(char *title)
26 + fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G);
29 +void set_xterm_icon_name(char *name)
31 + fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
34 void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
36 format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX;
38 SETCOLOR (MT_COLOR_NORMAL);
39 BKGDSET (MT_COLOR_NORMAL);
40 menu->redraw &= ~REDRAW_STATUS;
41 + if (option(OPTXTERMSETTITLES))
43 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle));
44 + set_xterm_title_bar(buf);
45 + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
46 + set_xterm_icon_name(buf);
52 ===================================================================
53 --- mutt.orig/globals.h 2009-06-25 12:35:37.000000000 +0200
54 +++ mutt/globals.h 2009-06-25 12:35:44.000000000 +0200
59 +WHERE char *XtermTitle;
60 +WHERE char *XtermIcon;
62 WHERE char *CurrentFolder;
63 WHERE char *LastFolder;
65 ===================================================================
66 --- mutt.orig/init.c 2009-06-25 12:35:42.000000000 +0200
67 +++ mutt/init.c 2009-06-25 12:35:44.000000000 +0200
68 @@ -1892,6 +1892,26 @@
69 toggle_option (MuttVars[idx].data);
71 set_option (MuttVars[idx].data);
73 + /* sanity check for xterm */
74 + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0)
75 + && option (OPTXTERMSETTITLES))
77 + char *ep = getenv ("TERM");
78 + /* Make sure that the terminal can take the control codes */
79 + if (ep == NULL) unset_option (MuttVars[idx].data);
80 + else if (mutt_strncasecmp (ep, "xterm", 5) &&
81 + mutt_strncasecmp (ep, "color-xterm", 11) &&
82 + mutt_strncasecmp (ep, "eterm", 5) &&
83 + mutt_strncasecmp (ep, "kterm", 5) &&
84 + mutt_strncasecmp (ep, "nxterm", 6) &&
85 + mutt_strncasecmp (ep, "putty", 5) &&
86 + mutt_strncasecmp (ep, "screen", 6) &&
87 + mutt_strncasecmp (ep, "cygwin", 6) &&
88 + mutt_strncasecmp (ep, "rxvt", 4) )
89 + unset_option (MuttVars[idx]. data);
93 else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
94 DTYPE (MuttVars[idx].type) == DT_PATH ||
96 ===================================================================
97 --- mutt.orig/init.h 2009-06-25 12:35:42.000000000 +0200
98 +++ mutt/init.h 2009-06-25 12:35:44.000000000 +0200
99 @@ -3337,6 +3337,27 @@
100 ** Also see the $$read_inc, $$net_inc and $$time_inc variables and the
101 ** ``$tuning'' section of the manual for performance considerations.
103 + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"},
106 + ** Controls the format of the icon title, as long as xterm_set_titles
107 + ** is enabled. This string is identical in formatting to the one used by
108 + ** ``$$status_format''.
110 + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0},
111 + /* The default must be off to force in the validity checking. */
114 + ** Controls whether mutt sets the xterm title bar and icon name
115 + ** (as long as you are in an appropriate terminal).
117 + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"},
120 + ** Controls the format of the title bar of the xterm provided that
121 + ** xterm_set_titles has been set. This string is identical in formatting
122 + ** to the one used by ``$$status_format''.
128 ===================================================================
129 --- mutt.orig/mutt.h 2009-06-25 12:35:37.000000000 +0200
130 +++ mutt/mutt.h 2009-06-25 12:35:44.000000000 +0200
133 OPTWRITEBCC, /* write out a bcc header? */
140 ===================================================================
141 --- mutt.orig/pager.c 2009-06-25 12:35:37.000000000 +0200
142 +++ mutt/pager.c 2009-06-25 12:35:44.000000000 +0200
143 @@ -1784,6 +1784,13 @@
145 BKGDSET (MT_COLOR_NORMAL);
146 SETCOLOR (MT_COLOR_NORMAL);
147 + if (option(OPTXTERMSETTITLES))
149 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle));
150 + set_xterm_title_bar(buffer);
151 + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
152 + set_xterm_icon_name(buffer);
156 if ((redraw & REDRAW_INDEX) && index)
158 ===================================================================
159 --- mutt.orig/status.c 2009-06-25 12:35:37.000000000 +0200
160 +++ mutt/status.c 2009-06-25 12:35:44.000000000 +0200
167 if (menu->top + menu->pagelen >= menu->max)
168 cp = menu->top ? "end" : "all";
170 Index: mutt/mutt_menu.h
171 ===================================================================
172 --- mutt.orig/mutt_menu.h 2009-06-25 12:35:37.000000000 +0200
173 +++ mutt/mutt_menu.h 2009-06-25 12:35:44.000000000 +0200
175 void menu_current_bottom (MUTTMENU *);
176 void menu_check_recenter (MUTTMENU *);
177 void menu_status_line (char *, size_t, MUTTMENU *, const char *);
178 +void set_xterm_title_bar (char *title);
179 +void set_xterm_icon_name (char *name);
181 MUTTMENU *mutt_new_menu (int);
182 void mutt_menuDestroy (MUTTMENU **);