From 58422cba1e9c74200f05429c785b58a329ef7384 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Mar 2017 16:59:50 +0100 Subject: [PATCH] screen_utils: move set_xterm_title() to xterm_title.c --- Makefile.am | 1 + src/main.c | 2 +- src/screen_utils.c | 22 ---------------------- src/screen_utils.h | 4 ---- src/xterm_title.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/xterm_title.h | 26 ++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 src/xterm_title.c create mode 100644 src/xterm_title.h diff --git a/Makefile.am b/Makefile.am index 32e18e3..5329315 100644 --- a/Makefile.am +++ b/Makefile.am @@ -90,6 +90,7 @@ endif if NCMPC_MINI else src_ncmpc_SOURCES += \ + src/xterm_title.c src/xterm_title.h \ src/hscroll.c src/hscroll.h \ src/match.c src/match.h \ src/conf.c src/conf.h diff --git a/src/main.c b/src/main.c index 0729610..d4c5168 100644 --- a/src/main.c +++ b/src/main.c @@ -26,8 +26,8 @@ #include "command.h" #include "ncu.h" #include "screen.h" -#include "screen_utils.h" #include "screen_status.h" +#include "xterm_title.h" #include "strfsong.h" #include "i18n.h" #include "player_command.h" diff --git a/src/screen_utils.c b/src/screen_utils.c index ff16613..28d5e4b 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -155,25 +155,3 @@ screen_display_completion_list(GList *list) wrefresh(w); colors_use(w, COLOR_LIST); } - -#ifndef NCMPC_MINI -void -set_xterm_title(const char *format, ...) -{ - /* the current xterm title exists under the WM_NAME property */ - /* and can be retrieved with xprop -id $WINDOWID */ - - if (options.enable_xterm_title) { - if (g_getenv("WINDOWID")) { - va_list ap; - va_start(ap,format); - char *msg = g_strdup_vprintf(format,ap); - va_end(ap); - printf("\033]0;%s\033\\", msg); - fflush(stdout); - g_free(msg); - } else - options.enable_xterm_title = FALSE; - } -} -#endif diff --git a/src/screen_utils.h b/src/screen_utils.h index 746a7ae..2f0568e 100644 --- a/src/screen_utils.h +++ b/src/screen_utils.h @@ -49,8 +49,4 @@ char *screen_readln(const char *prompt, const char *value, void screen_display_completion_list(GList *list); -#ifndef NCMPC_MINI -void set_xterm_title(const char *format, ...); -#endif - #endif diff --git a/src/xterm_title.c b/src/xterm_title.c new file mode 100644 index 0000000..fe03cfd --- /dev/null +++ b/src/xterm_title.c @@ -0,0 +1,45 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2017 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "xterm_title.h" +#include "options.h" + +#include + +#include + +void +set_xterm_title(const char *format, ...) +{ + /* the current xterm title exists under the WM_NAME property */ + /* and can be retrieved with xprop -id $WINDOWID */ + + if (options.enable_xterm_title) { + if (g_getenv("WINDOWID")) { + va_list ap; + va_start(ap,format); + char *msg = g_strdup_vprintf(format,ap); + va_end(ap); + printf("\033]0;%s\033\\", msg); + fflush(stdout); + g_free(msg); + } else + options.enable_xterm_title = FALSE; + } +} diff --git a/src/xterm_title.h b/src/xterm_title.h new file mode 100644 index 0000000..28addd5 --- /dev/null +++ b/src/xterm_title.h @@ -0,0 +1,26 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2017 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef XTERM_TITLE_H +#define XTERM_TITLE_H + +void +set_xterm_title(const char *format, ...); + +#endif -- 2.30.2