Skip to content

Instantly share code, notes, and snippets.

@ivoronin
Created November 10, 2012 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivoronin/4052215 to your computer and use it in GitHub Desktop.
Save ivoronin/4052215 to your computer and use it in GitHub Desktop.
# vi: ft=diff
Screen titles patch
Index: mutt-1.5.21/curs_main.c
===================================================================
--- mutt-1.5.21.orig/curs_main.c 2012-04-11 19:41:49.898788540 +0400
+++ mutt-1.5.21/curs_main.c 2012-04-11 19:44:32.826795297 +0400
@@ -123,6 +123,11 @@
fprintf(stderr, "%c]1;%s%c", ASCII_CTRL_OPEN_SQUARE_BRAKET, name, ASCII_CTRL_G);
}
+void set_screen_title_bar(char *title)
+{
+ fprintf(stderr, "%ck%s%c\\", ASCII_CTRL_OPEN_SQUARE_BRAKET, title, ASCII_CTRL_OPEN_SQUARE_BRAKET);
+}
+
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;
@@ -582,6 +587,11 @@
menu_status_line (buf, sizeof (buf), menu, NONULL (XtermIcon));
set_xterm_icon_name(buf);
}
+ if (option(OPTSCREENSETTITLES))
+ {
+ menu_status_line (buf, sizeof (buf), menu, NONULL (ScreenTitle));
+ set_screen_title_bar(buf);
+ }
}
menu->redraw = 0;
Index: mutt-1.5.21/globals.h
===================================================================
--- mutt-1.5.21.orig/globals.h 2012-04-11 19:41:49.898788540 +0400
+++ mutt-1.5.21/globals.h 2012-04-11 19:41:50.030788546 +0400
@@ -143,6 +143,7 @@
WHERE char *Visual;
WHERE char *XtermTitle;
WHERE char *XtermIcon;
+WHERE char *ScreenTitle;
WHERE char *CurrentFolder;
WHERE char *LastFolder;
Index: mutt-1.5.21/init.c
===================================================================
--- mutt-1.5.21.orig/init.c 2012-04-11 19:34:43.514770864 +0400
+++ mutt-1.5.21/init.c 2012-04-11 19:41:50.034788546 +0400
@@ -1893,6 +1893,16 @@
unset_option (MuttVars[idx]. data);
}
+ /* sanity check for screen */
+ if ((mutt_strcmp (MuttVars[idx].option, "screen_set_titles") == 0)
+ && option (OPTSCREENSETTITLES))
+ {
+ 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, "screen", 6))
+ unset_option (MuttVars[idx]. data);
+ }
}
else if (myvar || DTYPE (MuttVars[idx].type) == DT_STR ||
DTYPE (MuttVars[idx].type) == DT_PATH ||
Index: mutt-1.5.21/init.h
===================================================================
--- mutt-1.5.21.orig/init.h 2012-04-11 19:41:49.946788543 +0400
+++ mutt-1.5.21/init.h 2012-04-11 19:41:50.034788546 +0400
@@ -3385,6 +3385,20 @@
** xterm_set_titles has been set. This string is identical in formatting
** to the one used by ``$$status_format''.
*/
+ {"screen_set_titles", DT_BOOL, R_BOTH, OPTSCREENSETTITLES, 0},
+ /* The default must be off to force in the validity checking. */
+ /*
+ ** .pp
+ ** Controls whether mutt sets the screen title bar
+ ** (as long as you are in an appropriate terminal).
+ */
+ {"screen_title", DT_STR, R_BOTH, UL &ScreenTitle, UL "Mutt (%n)"},
+ /*
+ ** .pp
+ ** Controls the format of the title bar of the screen provided that
+ ** screen_set_titles has been set. This string is identical in formatting
+ ** to the one used by ``$$status_format''.
+ */
/*--*/
{ NULL, 0, 0, 0, 0 }
};
Index: mutt-1.5.21/mutt.h
===================================================================
--- mutt-1.5.21.orig/mutt.h 2012-04-11 19:41:49.950788543 +0400
+++ mutt-1.5.21/mutt.h 2012-04-11 19:41:50.034788546 +0400
@@ -448,6 +448,7 @@
OPTWRITEBCC, /* write out a bcc header? */
OPTXMAILER,
OPTXTERMSETTITLES,
+ OPTSCREENSETTITLES,
OPTCRYPTUSEGPGME,
OPTCRYPTUSEPKA,
Index: mutt-1.5.21/mutt_menu.h
===================================================================
--- mutt-1.5.21.orig/mutt_menu.h 2012-04-11 19:34:43.634770869 +0400
+++ mutt-1.5.21/mutt_menu.h 2012-04-11 19:41:50.034788546 +0400
@@ -105,6 +105,7 @@
void menu_status_line (char *, size_t, MUTTMENU *, const char *);
void set_xterm_title_bar (char *title);
void set_xterm_icon_name (char *name);
+void set_screen_title_bar (char *title);
MUTTMENU *mutt_new_menu (int);
void mutt_menuDestroy (MUTTMENU **);
Index: mutt-1.5.21/pager.c
===================================================================
--- mutt-1.5.21.orig/pager.c 2012-04-11 19:41:49.906788541 +0400
+++ mutt-1.5.21/pager.c 2012-04-11 19:41:50.038788546 +0400
@@ -1819,6 +1829,11 @@
menu_status_line (buffer, sizeof (buffer), index, NONULL (XtermIcon));
set_xterm_icon_name(buffer);
}
+ if (option(OPTSCREENSETTITLES))
+ {
+ menu_status_line (buffer, sizeof (buffer), index, NONULL (ScreenTitle));
+ set_screen_title_bar(buffer);
+ }
}
if ((redraw & REDRAW_INDEX) && index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment