1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2009 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.
18 */
20 #ifndef SCREEN_H
21 #define SCREEN_H
23 #include "config.h"
24 #include "command.h"
26 #include <mpd/client.h>
28 #include <glib.h>
30 #ifdef HAVE_NCURSESW_NCURSES_H
31 #include <ncursesw/ncurses.h>
32 #else
33 #include <ncurses.h>
34 #endif
36 #define IS_PLAYING(s) (s==MPD_STATE_PLAY)
37 #define IS_PAUSED(s) (s==MPD_STATE_PAUSE)
38 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
40 #define MAX_SONGNAME_LENGTH 512
42 struct mpdclient;
44 struct window {
45 WINDOW *w;
46 unsigned rows, cols;
47 };
49 struct screen {
50 struct window top_window;
51 struct window main_window;
52 struct window progress_window;
53 struct window status_window;
55 /* GTime is equivalent to time_t */
56 GTime start_timestamp;
57 GTime status_timestamp;
59 unsigned cols, rows;
61 char *buf;
62 size_t buf_size;
64 char *findbuf;
65 GList *find_history;
66 };
68 extern struct screen screen;
70 extern const struct screen_functions screen_playlist;
71 extern const struct screen_functions screen_browse;
72 #ifdef ENABLE_ARTIST_SCREEN
73 extern const struct screen_functions screen_artist;
74 #endif
75 extern const struct screen_functions screen_help;
76 #ifdef ENABLE_SEARCH_SCREEN
77 extern const struct screen_functions screen_search;
78 #endif
79 #ifdef ENABLE_SONG_SCREEN
80 extern const struct screen_functions screen_song;
81 #endif
82 #ifdef ENABLE_KEYDEF_SCREEN
83 extern const struct screen_functions screen_keydef;
84 #endif
85 #ifdef ENABLE_LYRICS_SCREEN
86 extern const struct screen_functions screen_lyrics;
87 #endif
88 #ifdef ENABLE_OUTPUTS_SCREEN
89 extern const struct screen_functions screen_outputs;
90 #endif
93 typedef struct screen_functions {
94 void (*init)(WINDOW *w, int cols, int rows);
95 void (*exit)(void);
96 void (*open)(struct mpdclient *c);
97 void (*close)(void);
98 void (*resize)(int cols, int rows);
99 void (*paint)(void);
100 void (*update)(struct mpdclient *c);
101 bool (*cmd)(struct mpdclient *c, command_t cmd);
102 const char *(*get_title)(char *s, size_t size);
103 } screen_functions_t;
105 void screen_init(struct mpdclient *c);
106 void screen_exit(void);
107 void screen_resize(struct mpdclient *c);
108 void screen_status_message(const char *msg);
109 void screen_status_printf(const char *format, ...);
110 char *screen_error(void);
111 void screen_paint(struct mpdclient *c);
112 void screen_update(struct mpdclient *c);
113 void screen_cmd(struct mpdclient *c, command_t cmd);
114 gint screen_get_id(const char *name);
116 void
117 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
118 void
119 screen_swap(struct mpdclient *c, const struct mpd_song *song);
121 gboolean
122 screen_is_visible(const struct screen_functions *sf);
124 int
125 screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row);
127 bool
128 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
130 #ifdef ENABLE_SONG_SCREEN
131 void
132 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
133 #endif
135 #ifdef ENABLE_LYRICS_SCREEN
136 void
137 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
138 #endif
140 #endif