diff -uNr mutt-1.5.23.nntp/curs_main.c mutt-1.5.23.nntp.xterm/curs_main.c --- mutt-1.5.23.nntp/curs_main.c 2014-12-03 02:09:36.111330033 +0200 +++ mutt-1.5.23.nntp.xterm/curs_main.c 2014-12-03 02:10:11.933685529 +0200 @@ -115,6 +115,19 @@ extern size_t UngetCount; +#define ASCII_CTRL_G 0x07 +#define ASCII_CTRL_OPEN_SQUARE_BRAKET 0x1b + +void set_xterm_title_bar(char *title) +{ + fprintf(stderr ,"%c]2;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_G); +} + +void set_xterm_icon_name(char *name) +{ + fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G); +} + void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) { format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; @@ -584,6 +597,13 @@ mutt_paddstr (COLS, buf); NORMAL_COLOR; menu->redraw &= ~REDRAW_STATUS; + if (option(OPTXTERMSETTITLES)) + { + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermTitle)); + set_xterm_title_bar(buf); + menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon)); + set_xterm_icon_name(buf); + } } menu->redraw = 0; diff -uNr mutt-1.5.23.nntp/globals.h mutt-1.5.23.nntp.xterm/globals.h --- mutt-1.5.23.nntp/globals.h 2014-12-03 02:09:36.112330043 +0200 +++ mutt-1.5.23.nntp.xterm/globals.h 2014-12-03 02:10:11.933685529 +0200 @@ -152,6 +152,8 @@ WHERE char *Tochars; WHERE char *Username; WHERE char *Visual; +WHERE char *XtermTitle; +WHERE char *XtermIcon; WHERE char *CurrentFolder; WHERE char *LastFolder; diff -uNr mutt-1.5.23.nntp/init.c mutt-1.5.23.nntp.xterm/init.c --- mutt-1.5.23.nntp/init.c 2014-12-03 02:09:36.113330053 +0200 +++ mutt-1.5.23.nntp.xterm/init.c 2014-12-03 02:10:11.933685529 +0200 @@ -1818,6 +1818,26 @@ toggle_option (MuttVars[idx].data); else set_option (MuttVars[idx].data); + + /* sanity check for xterm */ + if ((mutt_strcmp (MuttVars[idx].option, "xterm_set_titles") == 0) + && option (OPTXTERMSETTITLES)) + { + char *ep = getenv ("TERM"); + /* Make sure that the terminal can take the control codes */ + if (ep == NULL) unset_option (MuttVars[idx].data); + else if (mutt_strncasecmp (ep, "xterm", 5) && + mutt_strncasecmp (ep, "color-xterm", 11) && + mutt_strncasecmp (ep, "eterm", 5) && + mutt_strncasecmp (ep, "kterm", 5) && + mutt_strncasecmp (ep, "nxterm", 6) && + mutt_strncasecmp (ep, "putty", 5) && + mutt_strncasecmp (ep, "screen", 6) && + mutt_strncasecmp (ep, "cygwin", 6) && + mutt_strncasecmp (ep, "rxvt", 4) ) + unset_option (MuttVars[idx]. data); + + } } else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR || DTYPE (MuttVars[idx].type) == DT_PATH || diff -uNr mutt-1.5.23.nntp/init.h mutt-1.5.23.nntp.xterm/init.h --- mutt-1.5.23.nntp/init.h 2014-12-03 02:09:36.113330053 +0200 +++ mutt-1.5.23.nntp.xterm/init.h 2014-12-03 02:12:06.273819281 +0200 @@ -3629,6 +3629,27 @@ ** name of original article author) to article that followuped to newsgroup. */ #endif + {"xterm_icon", DT_STR, R_BOTH, UL &XtermIcon, UL "M%?n?AIL&ail?"}, + /* + ** .pp + ** Controls the format of the icon title, as long as xterm_set_titles + ** is enabled. This string is identical in formatting to the one used by + ** ``$$status_format''. + */ + {"xterm_set_titles", DT_BOOL, R_BOTH, OPTXTERMSETTITLES, 0}, + /* The default must be off to force in the validity checking. */ + /* + ** .pp + ** Controls whether mutt sets the xterm title bar and icon name + ** (as long as you are in an appropriate terminal). + */ + {"xterm_title", DT_STR, R_BOTH, UL &XtermTitle, UL "Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?"}, + /* + ** .pp + ** Controls the format of the title bar of the xterm provided that + ** xterm_set_titles has been set. This string is identical in formatting + ** to the one used by ``$$status_format''. + */ /*--*/ { NULL, 0, 0, 0, 0 } }; diff -uNr mutt-1.5.23.nntp/mutt.h mutt-1.5.23.nntp.xterm/mutt.h --- mutt-1.5.23.nntp/mutt.h 2014-12-03 02:09:36.114330063 +0200 +++ mutt-1.5.23.nntp.xterm/mutt.h 2014-12-03 02:10:11.934685539 +0200 @@ -463,6 +463,7 @@ OPTWRAPSEARCH, OPTWRITEBCC, /* write out a bcc header? */ OPTXMAILER, + OPTXTERMSETTITLES, OPTCRYPTUSEGPGME, OPTCRYPTUSEPKA, diff -uNr mutt-1.5.23.nntp/mutt_menu.h mutt-1.5.23.nntp.xterm/mutt_menu.h --- mutt-1.5.23.nntp/mutt_menu.h 2014-03-12 18:06:17.000000000 +0200 +++ mutt-1.5.23.nntp.xterm/mutt_menu.h 2014-12-03 02:10:11.934685539 +0200 @@ -103,6 +103,8 @@ void menu_current_bottom (MUTTMENU *); void menu_check_recenter (MUTTMENU *); void menu_status_line (char *, size_t, MUTTMENU *, const char *); +void set_xterm_title_bar (char *title); +void set_xterm_icon_name (char *name); MUTTMENU *mutt_new_menu (int); void mutt_menuDestroy (MUTTMENU **); diff -uNr mutt-1.5.23.nntp/pager.c mutt-1.5.23.nntp.xterm/pager.c --- mutt-1.5.23.nntp/pager.c 2014-12-03 02:09:36.116330083 +0200 +++ mutt-1.5.23.nntp.xterm/pager.c 2014-12-03 02:10:11.934685539 +0200 @@ -1835,6 +1835,13 @@ mutt_paddstr (COLS, bn); } NORMAL_COLOR; + if (option(OPTXTERMSETTITLES)) + { + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermTitle)); + set_xterm_title_bar(buffer); + menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon)); + set_xterm_icon_name(buffer); + } } if ((redraw & REDRAW_INDEX) && index) diff -uNr mutt-1.5.23.nntp/status.c mutt-1.5.23.nntp.xterm/status.c --- mutt-1.5.23.nntp/status.c 2014-03-12 18:06:17.000000000 +0200 +++ mutt-1.5.23.nntp.xterm/status.c 2014-12-03 02:10:11.934685539 +0200 @@ -195,6 +195,8 @@ break; case 'P': + if (!menu) + break; if (menu->top + menu->pagelen >= menu->max) cp = menu->top ? "end" : "all"; else