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 command_t last_cmd;
61 unsigned cols, rows;
63 char *buf;
64 size_t buf_size;
66 char *findbuf;
67 GList *find_history;
68 };
70 extern struct screen screen;
72 extern const struct screen_functions screen_playlist;
73 extern const struct screen_functions screen_browse;
74 #ifdef ENABLE_ARTIST_SCREEN
75 extern const struct screen_functions screen_artist;
76 #endif
77 extern const struct screen_functions screen_help;
78 #ifdef ENABLE_SEARCH_SCREEN
79 extern const struct screen_functions screen_search;
80 #endif
81 #ifdef ENABLE_SONG_SCREEN
82 extern const struct screen_functions screen_song;
83 #endif
84 #ifdef ENABLE_KEYDEF_SCREEN
85 extern const struct screen_functions screen_keydef;
86 #endif
87 #ifdef ENABLE_LYRICS_SCREEN
88 extern const struct screen_functions screen_lyrics;
89 #endif
90 #ifdef ENABLE_OUTPUTS_SCREEN
91 extern const struct screen_functions screen_outputs;
92 #endif
95 typedef struct screen_functions {
96 void (*init)(WINDOW *w, int cols, int rows);
97 void (*exit)(void);
98 void (*open)(struct mpdclient *c);
99 void (*close)(void);
100 void (*resize)(int cols, int rows);
101 void (*paint)(void);
102 void (*update)(struct mpdclient *c);
103 bool (*cmd)(struct mpdclient *c, command_t cmd);
104 const char *(*get_title)(char *s, size_t size);
105 } screen_functions_t;
107 void screen_init(struct mpdclient *c);
108 void screen_exit(void);
109 void screen_resize(struct mpdclient *c);
110 void screen_status_message(const char *msg);
111 void screen_status_printf(const char *format, ...);
112 char *screen_error(void);
113 void screen_paint(struct mpdclient *c);
114 void screen_update(struct mpdclient *c);
115 void screen_idle(struct mpdclient *c);
116 void screen_cmd(struct mpdclient *c, command_t cmd);
117 gint screen_get_id(const char *name);
119 void
120 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
121 void
122 screen_swap(struct mpdclient *c, const struct mpd_song *song);
124 gboolean
125 screen_is_visible(const struct screen_functions *sf);
127 int
128 screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row);
130 bool
131 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
133 #ifdef ENABLE_SONG_SCREEN
134 void
135 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
136 #endif
138 #ifdef ENABLE_LYRICS_SCREEN
139 void
140 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
141 #endif
143 #endif