Code

Flush stdout to change xterm title.
authornoname <noname@inventati.org>
Fri, 25 Apr 2014 14:48:38 +0000 (18:48 +0400)
committerMax Kellermann <max@duempel.org>
Tue, 13 May 2014 07:21:43 +0000 (09:21 +0200)
If stdout is not flushed, printf may not terminate control string
properly.  This way xterm title changes only sometimes.

Also use standard (ECMA-048) control string terminator ^[\ instead of \a.

src/screen_utils.c

index 1c1f14b189c2cd71ac8252b7ab1aecd2adfe418a..4bb18750fcdb0d92c5e638afc8d0378f422a5fa4 100644 (file)
@@ -170,7 +170,8 @@ set_xterm_title(const char *format, ...)
                        va_start(ap,format);
                        char *msg = g_strdup_vprintf(format,ap);
                        va_end(ap);
-                       printf("%c]0;%s%c", '\033', msg, '\007');
+                       printf("\033]0;%s\033\\", msg);
+                       fflush(stdout);
                        g_free(msg);
                } else
                        options.enable_xterm_title = FALSE;