Code

404d0a8d565ce49fed7142d4a56a35fac0d7f26f
[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_KEYDEF_SCREEN
60 extern const struct screen_functions screen_keydef;
61 #endif
62 #ifdef ENABLE_LYRICS_SCREEN
63 extern const struct screen_functions screen_lyrics;
64 #endif
66 typedef struct screen_functions {
67         void (*init)(WINDOW *w, int cols, int rows);
68         void (*exit)(void);
69         void (*open)(mpdclient_t *c);
70         void (*close)(void);
71         void (*resize)(int cols, int rows);
72         void (*paint)(void);
73         void (*update)(mpdclient_t *c);
74         int (*cmd)(mpdclient_t *c, command_t cmd);
75         const char *(*get_title)(char *s, size_t size);
76 } screen_functions_t;
78 void screen_init(mpdclient_t *c);
79 void screen_exit(void);
80 void screen_resize(struct mpdclient *c);
81 void screen_status_message(const char *msg);
82 void screen_status_printf(const char *format, ...);
83 char *screen_error(void);
84 void screen_paint(mpdclient_t *c);
85 void screen_update(mpdclient_t *c);
86 void screen_idle(mpdclient_t *c);
87 void screen_cmd(mpdclient_t *c, command_t cmd);
88 gint screen_get_id(const char *name);
90 void
91 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
93 gboolean
94 screen_is_visible(const struct screen_functions *sf);
96 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
99 #ifdef ENABLE_LYRICS_SCREEN
100 void
101 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song);
102 #endif
104 #endif