Code

screen_song: new screen which views song information
[ncmpc.git] / src / screen.h
1 #ifndef SCREEN_H
2 #define SCREEN_H
4 #include "config.h"
5 #include "mpdclient.h"
6 #include "command.h"
8 #include <glib.h>
10 #ifdef HAVE_NCURSESW_NCURSES_H
11 #include <ncursesw/ncurses.h>
12 #else
13 #include <ncurses.h>
14 #endif
16 #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY)
17 #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE)
18 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
20 #define MAX_SONGNAME_LENGTH   512
22 struct window {
23         WINDOW *w;
24         unsigned rows, cols;
25 };
27 struct screen {
28         struct window top_window;
29         struct window main_window;
30         struct window progress_window;
31         struct window status_window;
33         /* GTime is equivalent to time_t */
34         GTime start_timestamp;
35         GTime status_timestamp;
37         command_t last_cmd;
39         unsigned cols, rows;
41         char *buf;
42         size_t buf_size;
44         char *findbuf;
45         GList *find_history;
46 };
48 extern struct screen screen;
50 extern const struct screen_functions screen_playlist;
51 extern const struct screen_functions screen_browse;
52 #ifdef ENABLE_ARTIST_SCREEN
53 extern const struct screen_functions screen_artist;
54 #endif
55 extern const struct screen_functions screen_help;
56 #ifdef ENABLE_SEARCH_SCREEN
57 extern const struct screen_functions screen_search;
58 #endif
59 #ifdef ENABLE_SONG_SCREEN
60 extern const struct screen_functions screen_song;
61 #endif
62 #ifdef ENABLE_KEYDEF_SCREEN
63 extern const struct screen_functions screen_keydef;
64 #endif
65 #ifdef ENABLE_LYRICS_SCREEN
66 extern const struct screen_functions screen_lyrics;
67 #endif
69 typedef struct screen_functions {
70         void (*init)(WINDOW *w, int cols, int rows);
71         void (*exit)(void);
72         void (*open)(mpdclient_t *c);
73         void (*close)(void);
74         void (*resize)(int cols, int rows);
75         void (*paint)(void);
76         void (*update)(mpdclient_t *c);
77         bool (*cmd)(mpdclient_t *c, command_t cmd);
78         const char *(*get_title)(char *s, size_t size);
79 } screen_functions_t;
81 void screen_init(mpdclient_t *c);
82 void screen_exit(void);
83 void screen_resize(struct mpdclient *c);
84 void screen_status_message(const char *msg);
85 void screen_status_printf(const char *format, ...);
86 char *screen_error(void);
87 void screen_paint(mpdclient_t *c);
88 void screen_update(mpdclient_t *c);
89 void screen_idle(mpdclient_t *c);
90 void screen_cmd(mpdclient_t *c, command_t cmd);
91 gint screen_get_id(const char *name);
93 void
94 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
96 gboolean
97 screen_is_visible(const struct screen_functions *sf);
99 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
101 bool
102 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
104 #ifdef ENABLE_SONG_SCREEN
105 void
106 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
107 #endif
109 #ifdef ENABLE_LYRICS_SCREEN
110 void
111 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song);
112 #endif
114 #endif