976c75c9012dc0bce8b1fdfce39f0767f0da2715
1 #ifndef SCREEN_H
2 #define SCREEN_H
4 #include "config.h"
5 #include "mpdclient.h"
6 #include "command.h"
8 #include <ncurses.h>
9 #include <glib.h>
11 #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY)
12 #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE)
13 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
15 #define MAX_SONGNAME_LENGTH 512
17 struct window {
18 WINDOW *w;
19 unsigned rows, cols;
20 };
22 typedef struct screen {
23 struct window top_window;
24 struct window main_window;
25 struct window progress_window;
26 struct window status_window;
28 /* GTime is equivalent to time_t */
29 GTime start_timestamp;
30 GTime status_timestamp;
32 command_t last_cmd;
34 unsigned cols, rows;
36 char *buf;
37 size_t buf_size;
39 char *findbuf;
40 GList *find_history;
41 } screen_t;
43 extern const struct screen_functions screen_playlist;
44 extern const struct screen_functions screen_browse;
45 #ifdef ENABLE_ARTIST_SCREEN
46 extern const struct screen_functions screen_artist;
47 #endif
48 extern const struct screen_functions screen_help;
49 #ifdef ENABLE_SEARCH_SCREEN
50 extern const struct screen_functions screen_search;
51 #endif
52 #ifdef ENABLE_KEYDEF_SCREEN
53 extern const struct screen_functions screen_keydef;
54 #endif
55 #ifdef ENABLE_LYRICS_SCREEN
56 extern const struct screen_functions screen_lyrics;
57 #endif
59 typedef struct screen_functions {
60 void (*init)(WINDOW *w, int cols, int rows);
61 void (*exit)(void);
62 void (*open)(struct screen *screen, mpdclient_t *c);
63 void (*close)(void);
64 void (*resize)(int cols, int rows);
65 void (*paint)(void);
66 void (*update)(mpdclient_t *c);
67 int (*cmd)(struct screen *scr, mpdclient_t *c, command_t cmd);
68 const char *(*get_title)(char *s, size_t size);
69 } screen_functions_t;
71 void screen_init(mpdclient_t *c);
72 void screen_exit(void);
73 void screen_resize(struct mpdclient *c);
74 void screen_status_message(const char *msg);
75 void screen_status_printf(const char *format, ...);
76 char *screen_error(void);
77 void screen_paint(mpdclient_t *c);
78 void screen_update(mpdclient_t *c);
79 void screen_idle(mpdclient_t *c);
80 void screen_cmd(mpdclient_t *c, command_t cmd);
81 gint screen_get_id(const char *name);
83 void
84 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
86 gboolean
87 screen_is_visible(const struct screen_functions *sf);
89 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
92 #ifdef ENABLE_LYRICS_SCREEN
93 void
94 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song);
95 #endif
97 #endif