From: Max Kellermann Date: Tue, 29 Sep 2009 22:02:47 +0000 (+0200) Subject: screen: moved struct window to window.h X-Git-Tag: release-0.16~289 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;ds=sidebyside;h=8f159b41b1db6dfcebcd4cfe735e0bcdb2d5da40;p=ncmpc.git screen: moved struct window to window.h --- diff --git a/Makefile.am b/Makefile.am index 995d01f..e90fb2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,6 +21,7 @@ ncmpc_headers = \ src/command.h \ src/ncu.h \ src/player_command.h \ + src/window.h \ src/screen.h \ src/screen_list.h \ src/screen_play.h \ diff --git a/src/screen.c b/src/screen.c index 13dd117..a8b2ce5 100644 --- a/src/screen.c +++ b/src/screen.c @@ -559,41 +559,24 @@ screen_init(struct mpdclient *c) screen.start_timestamp = time(NULL); /* create top window */ - screen.top_window.rows = 2; - screen.top_window.cols = screen.cols; - screen.top_window.w = newwin(screen.top_window.rows, - screen.top_window.cols, - 0, 0); + window_init(&screen.top_window, 2, screen.cols, 0, 0); leaveok(screen.top_window.w, TRUE); keypad(screen.top_window.w, TRUE); /* create main window */ - screen.main_window.rows = screen.rows-4; - screen.main_window.cols = screen.cols; - screen.main_window.w = newwin(screen.main_window.rows, - screen.main_window.cols, - 2, - 0); + window_init(&screen.main_window, screen.rows - 4, screen.cols, 2, 0); // leaveok(screen.main_window.w, TRUE); temporary disabled keypad(screen.main_window.w, TRUE); /* create progress window */ - screen.progress_window.rows = 1; - screen.progress_window.cols = screen.cols; - screen.progress_window.w = newwin(screen.progress_window.rows, - screen.progress_window.cols, - screen.rows-2, - 0); + window_init(&screen.progress_window, 1, screen.cols, + screen.rows - 2, 0); leaveok(screen.progress_window.w, TRUE); /* create status window */ - screen.status_window.rows = 1; - screen.status_window.cols = screen.cols; - screen.status_window.w = newwin(screen.status_window.rows, - screen.status_window.cols, - screen.rows-1, - 0); + window_init(&screen.status_window, 1, screen.cols, + screen.rows - 1, 0); leaveok(screen.status_window.w, FALSE); keypad(screen.status_window.w, TRUE); diff --git a/src/screen.h b/src/screen.h index 32d57b0..ebf3674 100644 --- a/src/screen.h +++ b/src/screen.h @@ -22,6 +22,7 @@ #include "config.h" #include "command.h" +#include "window.h" #include @@ -41,11 +42,6 @@ struct mpdclient; -struct window { - WINDOW *w; - unsigned rows, cols; -}; - struct screen { struct window top_window; struct window main_window; diff --git a/src/window.h b/src/window.h new file mode 100644 index 0000000..e2edeb2 --- /dev/null +++ b/src/window.h @@ -0,0 +1,43 @@ +/* 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 NCMPC_WINDOW_H +#define NCMPC_WINDOW_H + +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#else +#include +#endif + +struct window { + WINDOW *w; + unsigned rows, cols; +}; + +static inline void +window_init(struct window *window, unsigned height, unsigned width, + int y, int x) +{ + window->w = newwin(height, width, y, x); + window->cols = width; + window->rows = height; +} + +#endif