Code

screen: include config.h in screen.h
[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 <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;
42         int painted;
43 } screen_t;
46 typedef void (*screen_init_fn_t)(WINDOW *w, int cols, int rows);
47 typedef void (*screen_exit_fn_t)(void);
48 typedef void (*screen_open_fn_t)(struct screen *screen, mpdclient_t *c);
49 typedef void (*screen_close_fn_t)(void);
50 typedef void (*screen_resize_fn_t)(int cols, int rows);
51 typedef void (*screen_paint_fn_t)(mpdclient_t *c);
52 typedef void (*screen_update_fn_t)(mpdclient_t *c);
53 typedef int (*screen_cmd_fn_t)(struct screen *scr, mpdclient_t *c, command_t cmd);
54 typedef const char *(*screen_title_fn_t)(char *s, size_t size);
56 extern const struct screen_functions screen_playlist;
57 extern const struct screen_functions screen_browse;
58 #ifdef ENABLE_ARTIST_SCREEN
59 extern const struct screen_functions screen_artist;
60 #endif
61 extern const struct screen_functions screen_help;
62 #ifdef ENABLE_SEARCH_SCREEN
63 extern const struct screen_functions screen_search;
64 #endif
65 #ifdef ENABLE_KEYDEF_SCREEN
66 extern const struct screen_functions screen_keydef;
67 #endif
68 #ifdef ENABLE_LYRICS_SCREEN
69 extern const struct screen_functions screen_lyrics;
70 #endif
72 typedef struct screen_functions {
73         screen_init_fn_t   init;
74         screen_exit_fn_t   exit;
75         screen_open_fn_t   open;
76         screen_close_fn_t  close;
77         screen_resize_fn_t resize;
78         screen_paint_fn_t  paint;
79         screen_update_fn_t update;
80         screen_cmd_fn_t    cmd;
81         screen_title_fn_t  get_title;
82 } screen_functions_t;
84 void screen_init(mpdclient_t *c);
85 void screen_exit(void);
86 void screen_resize(void);
87 void screen_status_message(const char *msg);
88 void screen_status_printf(const char *format, ...);
89 char *screen_error(void);
90 void screen_paint(mpdclient_t *c);
91 void screen_update(mpdclient_t *c);
92 void screen_idle(mpdclient_t *c);
93 void screen_cmd(mpdclient_t *c, command_t cmd);
94 gint screen_get_id(const char *name);
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 #endif