Code

screen: export function screen_switch()
[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;
45 extern const struct screen_functions screen_playlist;
46 extern const struct screen_functions screen_browse;
47 #ifdef ENABLE_ARTIST_SCREEN
48 extern const struct screen_functions screen_artist;
49 #endif
50 extern const struct screen_functions screen_help;
51 #ifdef ENABLE_SEARCH_SCREEN
52 extern const struct screen_functions screen_search;
53 #endif
54 #ifdef ENABLE_KEYDEF_SCREEN
55 extern const struct screen_functions screen_keydef;
56 #endif
57 #ifdef ENABLE_LYRICS_SCREEN
58 extern const struct screen_functions screen_lyrics;
59 #endif
61 typedef struct screen_functions {
62         void (*init)(WINDOW *w, int cols, int rows);
63         void (*exit)(void);
64         void (*open)(struct screen *screen, mpdclient_t *c);
65         void (*close)(void);
66         void (*resize)(int cols, int rows);
67         void (*paint)(mpdclient_t *c);
68         void (*update)(mpdclient_t *c);
69         int (*cmd)(struct screen *scr, mpdclient_t *c, command_t cmd);
70         const char *(*get_title)(char *s, size_t size);
71 } screen_functions_t;
73 void screen_init(mpdclient_t *c);
74 void screen_exit(void);
75 void screen_resize(void);
76 void screen_status_message(const char *msg);
77 void screen_status_printf(const char *format, ...);
78 char *screen_error(void);
79 void screen_paint(mpdclient_t *c);
80 void screen_update(mpdclient_t *c);
81 void screen_idle(mpdclient_t *c);
82 void screen_cmd(mpdclient_t *c, command_t cmd);
83 gint screen_get_id(const char *name);
85 void
86 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
88 gboolean
89 screen_is_visible(const struct screen_functions *sf);
91 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
93 #endif