Code

screen: removed screen.mode
[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         char *buf;
36         size_t buf_size;
38         char *findbuf;
39         GList *find_history;
41         int painted;
42 } screen_t;
45 typedef void (*screen_init_fn_t)(WINDOW *w, int cols, int rows);
46 typedef void (*screen_exit_fn_t)(void);
47 typedef void (*screen_open_fn_t)(struct screen *screen, mpdclient_t *c);
48 typedef void (*screen_close_fn_t)(void);
49 typedef void (*screen_resize_fn_t)(int cols, int rows);
50 typedef void (*screen_paint_fn_t)(mpdclient_t *c);
51 typedef void (*screen_update_fn_t)(mpdclient_t *c);
52 typedef int (*screen_cmd_fn_t)(struct screen *scr, mpdclient_t *c, command_t cmd);
53 typedef const char *(*screen_title_fn_t)(char *s, size_t size);
55 extern const struct screen_functions screen_playlist;
56 extern const struct screen_functions screen_browse;
57 #ifdef ENABLE_ARTIST_SCREEN
58 extern const struct screen_functions screen_artist;
59 #endif
60 extern const struct screen_functions screen_help;
61 #ifdef ENABLE_SEARCH_SCREEN
62 extern const struct screen_functions screen_search;
63 #endif
64 #ifdef ENABLE_KEYDEF_SCREEN
65 extern const struct screen_functions screen_keydef;
66 #endif
67 #ifdef ENABLE_LYRICS_SCREEN
68 extern const struct screen_functions screen_lyrics;
69 #endif
71 typedef struct screen_functions {
72         screen_init_fn_t   init;
73         screen_exit_fn_t   exit;
74         screen_open_fn_t   open;
75         screen_close_fn_t  close;
76         screen_resize_fn_t resize;
77         screen_paint_fn_t  paint;
78         screen_update_fn_t update;
79         screen_cmd_fn_t    cmd;
80         screen_title_fn_t  get_title;
81 } screen_functions_t;
83 void screen_init(mpdclient_t *c);
84 void screen_exit(void);
85 void screen_resize(void);
86 void screen_status_message(const char *msg);
87 void screen_status_printf(const char *format, ...);
88 char *screen_error(void);
89 void screen_paint(mpdclient_t *c);
90 void screen_update(mpdclient_t *c);
91 void screen_idle(mpdclient_t *c);
92 void screen_cmd(mpdclient_t *c, command_t cmd);
93 gint screen_get_id(const char *name);
95 gboolean
96 screen_is_visible(const struct screen_functions *sf);
98 int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row);
100 #endif