ncmpc version 0.15
[ncmpc.git] / src / screen.h
blob343f9441ca65cb655fe57ca37ae5f437923edd4d
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.
20 #ifndef SCREEN_H
21 #define SCREEN_H
23 #include "config.h"
24 #include "mpdclient.h"
25 #include "command.h"
27 #include <glib.h>
29 #ifdef HAVE_NCURSESW_NCURSES_H
30 #include <ncursesw/ncurses.h>
31 #else
32 #include <ncurses.h>
33 #endif
35 #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY)
36 #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE)
37 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
39 #define MAX_SONGNAME_LENGTH 512
41 struct window {
42 WINDOW *w;
43 unsigned rows, cols;
46 struct screen {
47 struct window top_window;
48 struct window main_window;
49 struct window progress_window;
50 struct window status_window;
52 /* GTime is equivalent to time_t */
53 GTime start_timestamp;
54 GTime status_timestamp;
56 command_t last_cmd;
58 unsigned cols, rows;
60 char *buf;
61 size_t buf_size;
63 char *findbuf;
64 GList *find_history;
67 extern struct screen screen;
69 extern const struct screen_functions screen_playlist;
70 extern const struct screen_functions screen_browse;
71 #ifdef ENABLE_ARTIST_SCREEN
72 extern const struct screen_functions screen_artist;
73 #endif
74 extern const struct screen_functions screen_help;
75 #ifdef ENABLE_SEARCH_SCREEN
76 extern const struct screen_functions screen_search;
77 #endif
78 #ifdef ENABLE_SONG_SCREEN
79 extern const struct screen_functions screen_song;
80 #endif
81 #ifdef ENABLE_KEYDEF_SCREEN
82 extern const struct screen_functions screen_keydef;
83 #endif
84 #ifdef ENABLE_LYRICS_SCREEN
85 extern const struct screen_functions screen_lyrics;
86 #endif
87 #ifdef ENABLE_OUTPUTS_SCREEN
88 extern const struct screen_functions screen_outputs;
89 #endif
92 typedef struct screen_functions {
93 void (*init)(WINDOW *w, int cols, int rows);
94 void (*exit)(void);
95 void (*open)(mpdclient_t *c);
96 void (*close)(void);
97 void (*resize)(int cols, int rows);
98 void (*paint)(void);
99 void (*update)(mpdclient_t *c);
100 bool (*cmd)(mpdclient_t *c, command_t cmd);
101 const char *(*get_title)(char *s, size_t size);
102 } screen_functions_t;
104 void screen_init(mpdclient_t *c);
105 void screen_exit(void);
106 void screen_resize(struct mpdclient *c);
107 void screen_status_message(const char *msg);
108 void screen_status_printf(const char *format, ...);
109 char *screen_error(void);
110 void screen_paint(mpdclient_t *c);
111 void screen_update(mpdclient_t *c);
112 void screen_idle(mpdclient_t *c);
113 void screen_cmd(mpdclient_t *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 screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
126 bool
127 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
129 #ifdef ENABLE_SONG_SCREEN
130 void
131 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
132 #endif
134 #ifdef ENABLE_LYRICS_SCREEN
135 void
136 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
137 #endif
139 #endif