xterm_title: pass string, no format
[ncmpc.git] / src / screen_list.c
blob5a9f0d7a96517c93699108442785176be9fe6256
1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2017 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "screen_list.h"
21 #include "screen_interface.h"
22 #include "screen.h"
23 #include "screen_help.h"
24 #include "screen_queue.h"
25 #include "screen_file.h"
26 #include "screen_artist.h"
27 #include "screen_search.h"
28 #include "screen_song.h"
29 #include "screen_keydef.h"
30 #include "screen_lyrics.h"
31 #include "screen_outputs.h"
32 #include "screen_chat.h"
34 #include <string.h>
36 static const struct
38 const char *name;
39 const struct screen_functions *functions;
40 } screens[] = {
41 { "playlist", &screen_queue },
42 { "browse", &screen_browse },
43 #ifdef ENABLE_ARTIST_SCREEN
44 { "artist", &screen_artist },
45 #endif
46 #ifdef ENABLE_HELP_SCREEN
47 { "help", &screen_help },
48 #endif
49 #ifdef ENABLE_SEARCH_SCREEN
50 { "search", &screen_search },
51 #endif
52 #ifdef ENABLE_SONG_SCREEN
53 { "song", &screen_song },
54 #endif
55 #ifdef ENABLE_KEYDEF_SCREEN
56 { "keydef", &screen_keydef },
57 #endif
58 #ifdef ENABLE_LYRICS_SCREEN
59 { "lyrics", &screen_lyrics },
60 #endif
61 #ifdef ENABLE_OUTPUTS_SCREEN
62 { "outputs", &screen_outputs },
63 #endif
64 #ifdef ENABLE_CHAT_SCREEN
65 { "chat", &screen_chat },
66 #endif
69 void
70 screen_list_init(WINDOW *w, unsigned cols, unsigned rows)
72 for (unsigned i = 0; i < G_N_ELEMENTS(screens); ++i) {
73 const struct screen_functions *sf = screens[i].functions;
75 if (sf->init)
76 sf->init(w, cols, rows);
80 void
81 screen_list_exit(void)
83 for (unsigned i = 0; i < G_N_ELEMENTS(screens); ++i) {
84 const struct screen_functions *sf = screens[i].functions;
86 if (sf->exit)
87 sf->exit();
91 void
92 screen_list_resize(unsigned cols, unsigned rows)
94 for (unsigned i = 0; i < G_N_ELEMENTS(screens); ++i) {
95 const struct screen_functions *sf = screens[i].functions;
97 if (sf->resize)
98 sf->resize(cols, rows);
102 const char *
103 screen_get_name(const struct screen_functions *sf)
105 for (unsigned i = 0; i < G_N_ELEMENTS(screens); ++i)
106 if (screens[i].functions == sf)
107 return screens[i].name;
109 return NULL;
112 const struct screen_functions *
113 screen_lookup_name(const char *name)
115 for (unsigned i = 0; i < G_N_ELEMENTS(screens); ++i)
116 if (strcmp(name, screens[i].name) == 0)
117 return screens[i].functions;
119 return NULL;