X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen.h;h=b9486473c1531d032d310ac4335e1eae76c86ca5;hb=15eacd43a481a4fc67789a25d56bb5f1527bfc12;hp=d6f1620da3790b156ba35431faea5972e8247541;hpb=8fd244cc61c74522b93b59e75594902a01f936b5;p=ncmpc.git diff --git a/src/screen.h b/src/screen.h index d6f1620..b948647 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,114 +1,81 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + #ifndef SCREEN_H #define SCREEN_H -#include "list_window.h" -#include "mpdclient.h" +#include "config.h" +#include "command.h" +#include "window.h" +#include "title_bar.h" +#include "progress_bar.h" +#include "status_bar.h" -#include -#include +#include -#define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY) -#define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE) -#define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s))) +#include -#define MAX_SONGNAME_LENGTH 512 +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#else +#include +#endif -typedef struct { - WINDOW *w; - int rows, cols; - int cur_action_id; -} window_t; +struct mpdclient; +struct screen_functions; -typedef struct { - window_t top_window; - window_t main_window; - window_t progress_window; - window_t status_window; +struct screen { + struct title_bar title_bar; + struct window main_window; + struct progress_bar progress_bar; + struct status_bar status_bar; /* GTime is equivalent to time_t */ GTime start_timestamp; - GTime status_timestamp; - GTime input_timestamp; - GTime last_cmd; - int cols, rows; - - int mode; + unsigned cols, rows; char *buf; size_t buf_size; char *findbuf; GList *find_history; +}; - int painted; -} screen_t; - - -typedef void (*screen_init_fn_t)(WINDOW *w, int cols, int rows); -typedef void (*screen_exit_fn_t)(void); -typedef void (*screen_open_fn_t)(screen_t *screen, mpdclient_t *c); -typedef void (*screen_close_fn_t)(void); -typedef void (*screen_resize_fn_t)(int cols, int rows); -typedef void (*screen_paint_fn_t)(screen_t *screen, mpdclient_t *c); -typedef void (*screen_update_fn_t)(screen_t *screen, mpdclient_t *c); -typedef int (*screen_cmd_fn_t)(screen_t *scr, mpdclient_t *c, command_t cmd); -typedef const char *(*screen_title_fn_t)(char *s, size_t size); -typedef list_window_t *(*screen_get_lw_fn_t) (void); - -typedef struct { - screen_init_fn_t init; - screen_exit_fn_t exit; - screen_open_fn_t open; - screen_close_fn_t close; - screen_resize_fn_t resize; - screen_paint_fn_t paint; - screen_update_fn_t update; - screen_cmd_fn_t cmd; - screen_title_fn_t get_title; - screen_get_lw_fn_t get_lw; -} screen_functions_t; - -void -ncurses_init(void); - -int screen_init(mpdclient_t *c); -int screen_exit(void); -void screen_resize(void); -void screen_status_message(const char *msg); -void screen_status_printf(const char *format, ...); -char *screen_error(void); -void screen_paint(mpdclient_t *c); -void screen_update(mpdclient_t *c); -void screen_idle(mpdclient_t *c); -void screen_cmd(mpdclient_t *c, command_t cmd); -gint screen_get_id(const char *name); - - -gint get_cur_mode_id(void); -int screen_get_mouse_event(mpdclient_t *c, - list_window_t *lw, int lw_length, - unsigned long *bstate, int *row); +extern struct screen screen; -screen_functions_t * -get_screen_search(void); +void screen_init(struct mpdclient *c); +void screen_exit(void); +void screen_resize(struct mpdclient *c); +void screen_paint(struct mpdclient *c); +void screen_update(struct mpdclient *c); +void screen_cmd(struct mpdclient *c, command_t cmd); -screen_functions_t * -get_screen_browse(void); - -screen_functions_t * -get_screen_playlist(void); - -screen_functions_t * -get_screen_help(void); - -screen_functions_t * -get_screen_lyrics(void); +void +screen_switch(const struct screen_functions *sf, struct mpdclient *c); +void +screen_swap(struct mpdclient *c, const struct mpd_song *song); -screen_functions_t * -get_screen_keydef(void); +gboolean +screen_is_visible(const struct screen_functions *sf); -screen_functions_t * -get_screen_clock(void); +int +screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row); #endif