Code

7a8b0edb3dba2dba06e13e128dc1b689a7156062
[ncmpc.git] / src / screen.h
1 #ifndef SCREEN_H
2 #define SCREEN_H
4 #include "mpdclient.h"
5 #include "command.h"
7 #include <ncurses.h>
8 #include <glib.h>
10 #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY)
11 #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE)
12 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
14 #define MAX_SONGNAME_LENGTH   512
16 struct window {
17         WINDOW *w;
18         unsigned rows, cols;
19 };
21 typedef struct screen {
22         struct window top_window;
23         struct window main_window;
24         struct window progress_window;
25         struct window status_window;
27         /* GTime is equivalent to time_t */
28         GTime start_timestamp;
29         GTime status_timestamp;
31         command_t last_cmd;
33         unsigned cols, rows;
35         int mode;
37         char *buf;
38         size_t buf_size;
40         char *findbuf;
41         GList *find_history;
43         int painted;
44 } screen_t;
47 typedef void (*screen_init_fn_t)(WINDOW *w, int cols, int rows);
48 typedef void (*screen_exit_fn_t)(void);
49 typedef void (*screen_open_fn_t)(struct screen *screen, mpdclient_t *c);
50 typedef void (*screen_close_fn_t)(void);
51 typedef void (*screen_resize_fn_t)(int cols, int rows);
52 typedef void (*screen_paint_fn_t)(mpdclient_t *c);
53 typedef void (*screen_update_fn_t)(mpdclient_t *c);
54 typedef int (*screen_cmd_fn_t)(struct screen *scr, mpdclient_t *c, command_t cmd);
55 typedef const char *(*screen_title_fn_t)(char *s, size_t size);
57 extern const struct screen_functions screen_playlist;
58 extern const struct screen_functions screen_browse;
59 #ifdef ENABLE_ARTIST_SCREEN
60 extern const struct screen_functions screen_artist;
61 #endif
62 extern const struct screen_functions screen_help;
63 #ifdef ENABLE_SEARCH_SCREEN
64 extern const struct screen_functions screen_search;
65 #endif
66 #ifdef ENABLE_KEYDEF_SCREEN
67 extern const struct screen_functions screen_keydef;
68 #endif
69 #ifdef ENABLE_LYRICS_SCREEN
70 extern const struct screen_functions screen_lyrics;
71 #endif
73 typedef struct screen_functions {
74         screen_init_fn_t   init;
75         screen_exit_fn_t   exit;
76         screen_open_fn_t   open;
77         screen_close_fn_t  close;
78         screen_resize_fn_t resize;
79         screen_paint_fn_t  paint;
80         screen_update_fn_t update;
81         screen_cmd_fn_t    cmd;
82         screen_title_fn_t  get_title;
83 } screen_functions_t;
85 void screen_init(mpdclient_t *c);
86 void screen_exit(void);
87 void screen_resize(void);
88 void screen_status_message(const char *msg);
89 void screen_status_printf(const char *format, ...);
90 char *screen_error(void);
91 void screen_paint(mpdclient_t *c);
92 void screen_update(mpdclient_t *c);
93 void screen_idle(mpdclient_t *c);
94 void screen_cmd(mpdclient_t *c, command_t cmd);
95 gint screen_get_id(const char *name);
98 gint get_cur_mode_id(void);
99 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
101 #endif