1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

core: display a warning on startup if $TERM is not screen(-256color) under screen/tmux

The same warning is displayed with command "/debug term".
This commit is contained in:
Sébastien Helleu
2014-07-14 19:00:23 +02:00
parent a2cb702b66
commit eb4d1cf9e7
16 changed files with 207 additions and 82 deletions
+1
View File
@@ -1774,6 +1774,7 @@ COMMAND_CALLBACK(debug)
if (string_strcasecmp (argv[1], "term") == 0)
{
gui_window_term_display_infos ();
weechat_term_check ();
return WEECHAT_RC_OK;
}
+45
View File
@@ -385,6 +385,50 @@ weechat_welcome_message ()
}
}
/*
* Displays warnings about $TERM if it is detected as wrong.
*
* If $TERM is different from "screen" or "screen-256color" and that $STY is
* set (GNU screen) or $TMUX is set (tmux), then a warning is displayed.
*/
void
weechat_term_check ()
{
char *term, *sty, *tmux;
int is_term_ok, is_screen, is_tmux;
term = getenv ("TERM");
sty = getenv ("STY");
tmux = getenv ("TMUX");
is_term_ok = (term && ((strcmp (term, "screen") == 0)
|| (strcmp (term, "screen-256color") == 0)));
is_screen = (sty && sty[0]);
is_tmux = (tmux && tmux[0]);
if ((is_screen || is_tmux) && !is_term_ok)
{
gui_chat_printf (
NULL,
/* TRANSLATORS: the "under %s" can be "under screen" or "under tmux" */
_("%sWarning: WeeChat is running under %s and $TERM is \"%s\", "
"which can cause display bugs; $TERM should be set to "
"\"screen-256color\" or \"screen\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
(is_screen) ? "screen" : "tmux",
(term) ? term : "");
gui_chat_printf (
NULL,
_("%sYou should add this line in the file %s: %s"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
(is_screen) ? "~/.screenrc" : "~/.tmux.conf",
(is_screen) ?
"term screen-256color" :
"set -g default-terminal \"screen-256color\"");
}
}
/*
* Shutdowns WeeChat.
*/
@@ -466,6 +510,7 @@ main (int argc, char *argv[])
}
weechat_welcome_message (); /* display WeeChat welcome message */
gui_chat_print_lines_waiting_buffer (NULL); /* display lines waiting */
weechat_term_check (); /* warnings about $TERM (if wrong) */
command_startup (0); /* command executed before plugins */
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
argc, argv);
+1
View File
@@ -106,6 +106,7 @@ extern int weechat_no_gnutls;
extern int weechat_no_gcrypt;
extern char *weechat_startup_commands;
extern void weechat_term_check ();
extern void weechat_shutdown (int return_code, int crash);
#endif /* WEECHAT_H */