diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index f2c36f8a4..66530453f 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -2568,8 +2568,8 @@ gui_window_set_title (const char *title) { char *new_title, *envterm, *envshell, *shell, *shellname; - envterm = getenv ("TERM"); - if (!envterm) + /* check if term has status line support */ + if (!tgetflag ("hs")) return; new_title = (title && title[0]) ? @@ -2577,57 +2577,8 @@ gui_window_set_title (const char *title) 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) - || (strncmp (envterm, "alacritty", 9) == 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) - || (strncmp (envterm, "tmux", 4) == 0)) - { - if (title && title[0]) - { - printf ("\033k%s\033\\", new_title); - } - else - { - envshell = getenv ("SHELL"); - if (envshell) - { - shell = strdup (envshell); - if (shell) - { - shellname = basename (shell); - printf ("\033k%s\033\\", (shellname) ? shellname : shell); - free (shell); - } - else - { - printf ("\033k%s\033\\", envterm); - } - } - else - { - printf ("\033k%s\033\\", envterm); - } - } - /* trying to set the title of a backgrounded xterm like terminal */ - printf ("\33]0;%s\7", new_title); - } + printf ("%s%s%s", tgetstr ("ts"), new_title, tgetstr ("fs")); + fflush (stdout); free (new_title); diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 1e7286d05..09fc4a1d3 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -28,10 +28,13 @@ #define NCURSES_WIDECHAR 1 #ifdef HAVE_NCURSESW_CURSES_H #include +#include #elif HAVE_NCURSES_H #include +#include #else #include +#include #endif /* HAVE_NCURSESW_CURSES_H */ #endif /* WEECHAT_HEADLESS */