>From 020826fffac38a5adf9af39d045c40da9541f99b Mon Sep 17 00:00:00 2001 From: Brand Huntsman Date: Sat, 27 Jan 2018 02:17:35 -0700 Subject: [PATCH] set the terminal emulator's titlebar Signed-off-by: Brand Huntsman --- src/winio.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/winio.c b/src/winio.c index bbcd646d..f981fd15 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1995,6 +1995,16 @@ int buffer_number(openfilestruct *buffer) return count; } +/* Set the terminal emulator's titlebar. */ +void set_terminal_titlebar(size_t prefixlen, const char *prefix, char *path) +{ + printf("\033]0;nano: "); + if (prefixlen > 0) + printf("%s ", prefix); + printf("%s\007", path); + fflush(stdout); +} + /* If path is NULL, we're in normal editing mode, so display the current * version of nano, the current filename, and whether the current file * has been modified on the titlebar. If path isn't NULL, we're either @@ -2107,12 +2117,18 @@ void titlebar(const char *path) if (pathlen + pluglen + statelen <= COLS) { caption = display_string(path, 0, pathlen, FALSE); waddstr(topwin, caption); + if (!console) + set_terminal_titlebar(prefixlen, prefix, caption); free(caption); } else if (5 + statelen <= COLS) { waddstr(topwin, "..."); caption = display_string(path, 3 + pathlen - COLS + statelen, COLS - statelen, FALSE); waddstr(topwin, caption); + if (!console) { + caption = display_string(path, 0, pathlen, FALSE); + set_terminal_titlebar(prefixlen, prefix, caption); + } free(caption); } -- 2.13.6