Code

Use the terminal in raw mode - ignore terminal control characters
[ncmpc.git] / src / screen.h
1 #ifndef SCREEN_H
2 #define SCREEN_H
3 #include <ncurses.h>
4 #include "list_window.h"
6 /* minumum window size */
7 #define SCREEN_MIN_COLS 14
8 #define SCREEN_MIN_ROWS  5
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)))
15 typedef enum
16 {
17   SCREEN_PLAY_WINDOW = 0,
18   SCREEN_FILE_WINDOW,
19   SCREEN_HELP_WINDOW,
20   SCREEN_KEYDEF_WINDOW,
21   SCREEN_CLOCK_WINDOW,
22   SCREEN_SEARCH_WINDOW
24 } screen_mode_t;
26 typedef struct
27 {
28   WINDOW *w;
29   int rows, cols;
31 } window_t;
35 typedef struct
36 {
37   window_t top_window;
38   window_t main_window;
39   window_t progress_window;
40   window_t status_window;
42   GList *screen_list;
44   time_t start_timestamp;
45   time_t status_timestamp;
46   time_t input_timestamp;
47   command_t last_cmd;
49   int cols, rows;
51   screen_mode_t mode;
53   char *buf;
54   size_t buf_size;
56   char *findbuf;
57   GList *find_history;
59   int painted;
61 } screen_t;
64 typedef void (*screen_init_fn_t)   (WINDOW *w, int cols, int rows);
65 typedef void (*screen_exit_fn_t)   (void);
66 typedef void (*screen_open_fn_t)   (screen_t *screen, mpd_client_t *c);
67 typedef void (*screen_close_fn_t)  (void);
68 typedef void (*screen_resize_fn_t)   (int cols, int rows);
69 typedef void (*screen_paint_fn_t)  (screen_t *screen, mpd_client_t *c);
70 typedef void (*screen_update_fn_t) (screen_t *screen, mpd_client_t *c);
71 typedef int (*screen_cmd_fn_t) (screen_t *scr, mpd_client_t *c, command_t cmd);
72 typedef char * (*screen_title_fn_t) (char *s, size_t size);
73 typedef list_window_t * (*screen_get_lw_fn_t) (void);
75 typedef struct
76 {
77   screen_init_fn_t   init;
78   screen_exit_fn_t   exit;
79   screen_open_fn_t   open;
80   screen_close_fn_t  close;
81   screen_resize_fn_t resize;
82   screen_paint_fn_t  paint;
83   screen_update_fn_t update;
84   screen_cmd_fn_t    cmd;
85   screen_title_fn_t  get_title;
86   screen_get_lw_fn_t get_lw;
88 } screen_functions_t;
91 int screen_init(void);
92 int screen_exit(void);
93 void screen_resize(void);
94 void screen_status_message(char *msg);
95 void screen_status_printf(char *format, ...);
96 char *screen_error(void);
97 void screen_paint(mpd_client_t *c);
98 void screen_update(mpd_client_t *c);
99 void screen_idle(mpd_client_t *c);
100 void screen_cmd(mpd_client_t *c, command_t cmd);
102 #endif