Code

screen_utils: move set_xterm_title() to xterm_title.c
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 15:59:50 +0000 (16:59 +0100)
committerMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 15:59:50 +0000 (16:59 +0100)
Makefile.am
src/main.c
src/screen_utils.c
src/screen_utils.h
src/xterm_title.c [new file with mode: 0644]
src/xterm_title.h [new file with mode: 0644]

index 32e18e37a9969890dd43b413905fee1aa26d1544..53293154c48225ce9e401a2bdbe9c64c7d7d8249 100644 (file)
@@ -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
index 0729610a54ad7336e0347efb12154e9187d764d3..d4c5168a251694d539964e9ff70adf82bc6fd545 100644 (file)
@@ -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"
index ff16613e42952b5ba1a4e393054d3c3b03a111a4..28d5e4b2fd4319384bf117178213f40f030485fa 100644 (file)
@@ -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
index 746a7ae9a86a926d33d509d5410ecbc59d68ba90..2f0568ede047487ea647085148a46934a67a7d02 100644 (file)
@@ -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 (file)
index 0000000..fe03cfd
--- /dev/null
@@ -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 <glib.h>
+
+#include <stdio.h>
+
+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 (file)
index 0000000..28addd5
--- /dev/null
@@ -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