diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-14 19:00:23 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-14 19:00:23 +0200 |
commit | eb4d1cf9e78e9b330c684e4a55de27525c4fddd0 (patch) | |
tree | 4f4ec684074b53a2cfa52c3a865d875902344670 /src/core | |
parent | a2cb702b6660ab9acde7bd57e9b6eae6b574245f (diff) | |
download | weechat-eb4d1cf9e78e9b330c684e4a55de27525c4fddd0.zip |
core: display a warning on startup if $TERM is not screen(-256color) under screen/tmux
The same warning is displayed with command "/debug term".
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 1 | ||||
-rw-r--r-- | src/core/weechat.c | 45 | ||||
-rw-r--r-- | src/core/weechat.h | 1 |
3 files changed, 47 insertions, 0 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 2e80ff648..b9fdf4ac3 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -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; } diff --git a/src/core/weechat.c b/src/core/weechat.c index 50c8834cd..cd474711f 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -386,6 +386,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); diff --git a/src/core/weechat.h b/src/core/weechat.h index bea355892..8eee8079a 100644 --- a/src/core/weechat.h +++ b/src/core/weechat.h @@ -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 */ |