diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-09 17:07:02 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-09 17:07:02 +0100 |
commit | 90774b73d8d08e7aa2139250f333cd5cf88fecb2 (patch) | |
tree | d1d550c9ea483e65a83089889b6487cd4a07027a /src/gui/curses | |
parent | 18ff3064cf1f889ce050c2e18b5f827e4dd3de7f (diff) | |
download | weechat-90774b73d8d08e7aa2139250f333cd5cf88fecb2.zip |
core: rename option weechat.look.set_title to weechat.look.window_title (evaluated string)
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 12 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 112 |
2 files changed, 59 insertions, 65 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 45563b054..b7358914c 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -210,8 +210,11 @@ gui_main_init () { gui_current_window = gui_windows; - if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_set_title (version_get_name_version ()); + if (CONFIG_STRING(config_look_window_title) + && CONFIG_STRING(config_look_window_title)[0]) + { + gui_window_set_title (CONFIG_STRING(config_look_window_title)); + } } /* @@ -538,8 +541,11 @@ gui_main_end (int clean_exit) gui_history_global_free (); /* reset title */ - if (CONFIG_BOOLEAN(config_look_set_title)) + if (CONFIG_STRING(config_look_window_title) + && CONFIG_STRING(config_look_window_title)[0]) + { gui_window_set_title (NULL); + } /* end color */ gui_color_end (); diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index d4c23157a..9007e19d8 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -35,6 +35,7 @@ #include "../../core/weechat.h" #include "../../core/wee-config.h" +#include "../../core/wee-eval.h" #include "../../core/wee-hook.h" #include "../../core/wee-log.h" #include "../../core/wee-string.h" @@ -2344,90 +2345,77 @@ gui_window_refresh_screen (int full_refresh) /* * Sets terminal title. + * + * Note: the content of "title" (if not NULL) is evaluated, so variables like + * "${info:version}" can be used inside. */ void gui_window_set_title (const char *title) { - char *shell, *shellname; - char *envterm = getenv ("TERM"); - char *envshell = getenv ("SHELL"); + char *new_title, *envterm, *envshell, *shell, *shellname; - if (envterm) + envterm = getenv ("TERM"); + if (!envterm) + return; + + new_title = (title && title[0]) ? + eval_expression (title, NULL, NULL, NULL) : strdup ("Terminal"); + if (!new_title) + return; + + if (strcmp (envterm, "sun-cmd") == 0) + { + printf ("\033]l%s\033\\", new_title); + } + else if (strcmp (envterm, "hpterm") == 0) + { + printf ("\033&f0k%dD%s", (int)(strlen (new_title) + 1), new_title); + } + /* the following terminals support the xterm escape codes */ + else if ((strncmp (envterm, "xterm", 5) == 0) + || (strncmp (envterm, "rxvt", 4) == 0) + || (strcmp (envterm, "Eterm") == 0) + || (strcmp (envterm, "aixterm") == 0) + || (strcmp (envterm, "iris-ansi") == 0) + || (strcmp (envterm, "dtterm") == 0)) + { + printf ("\33]0;%s\7", new_title); + } + else if (strncmp (envterm, "screen", 6) == 0) { if (title && title[0]) { - if (strcmp (envterm, "sun-cmd") == 0) - { - printf ("\033]l%s\033\\", title); - } - else if (strcmp (envterm, "hpterm") == 0) - { - printf ("\033&f0k%dD%s", (int)(strlen(title) + 1), title); - } - /* the following terminals support the xterm escape codes */ - else if ((strncmp (envterm, "xterm", 5) == 0) - || (strncmp (envterm, "rxvt", 4) == 0) - || (strcmp (envterm, "Eterm") == 0) - || (strcmp (envterm, "aixterm") == 0) - || (strcmp (envterm, "iris-ansi") == 0) - || (strcmp (envterm, "dtterm") == 0)) - { - printf ("\33]0;%s\7", title); - } - else if (strncmp (envterm, "screen", 6) == 0) - { - printf ("\033k%s\033\\", title); - /* trying to set the title of a backgrounded xterm like terminal */ - printf ("\33]0;%s\7", title); - } + printf ("\033k%s\033\\", title); } else { - if (strcmp (envterm, "sun-cmd") == 0) + envshell = getenv ("SHELL"); + if (envshell) { - printf ("\033]l%s\033\\", "Terminal"); - } - else if (strcmp (envterm, "hpterm") == 0) - { - printf ("\033&f0k%dD%s", (int)strlen("Terminal"), "Terminal"); - } - /* the following terminals support the xterm escape codes */ - else if ((strncmp (envterm, "xterm", 5) == 0) - || (strncmp (envterm, "rxvt", 4) == 0) - || (strcmp (envterm, "Eterm") == 0) - || (strcmp( envterm, "aixterm") == 0) - || (strcmp( envterm, "iris-ansi") == 0) - || (strcmp( envterm, "dtterm") == 0)) - { - printf ("\33]0;%s\7", "Terminal"); - } - else if (strncmp (envterm, "screen", 6) == 0) - { - if (envshell) + shell = strdup (envshell); + if (shell) { - shell = strdup (envshell); - if (shell) - { - shellname = basename (shell); - printf ("\033k%s\033\\", (shellname) ? shellname : shell); - free (shell); - } - else - { - printf ("\033k%s\033\\", envterm); - } + shellname = basename (shell); + printf ("\033k%s\033\\", (shellname) ? shellname : shell); + free (shell); } else { printf ("\033k%s\033\\", envterm); } - /* tryning to reset the title of a backgrounded xterm like terminal */ - printf ("\33]0;%s\7", "Terminal"); + } + else + { + printf ("\033k%s\033\\", envterm); } } - fflush (stdout); + /* trying to set the title of a backgrounded xterm like terminal */ + printf ("\33]0;%s\7", new_title); } + fflush (stdout); + + free (new_title); } /* |