summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d28a7d4)
raw | patch | inline | side by side (parent: d28a7d4)
author | Max Kellermann <max@duempel.org> | |
Mon, 22 Sep 2008 08:04:39 +0000 (10:04 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 22 Sep 2008 08:04:39 +0000 (10:04 +0200) |
Moved basic libncurses initialization to ncu.c and ncu.h. Keep
generic code out of screen.c.
generic code out of screen.c.
src/Makefile.am | patch | blob | history | |
src/main.c | patch | blob | history | |
src/ncu.c | [new file with mode: 0644] | patch | blob |
src/ncu.h | [new file with mode: 0644] | patch | blob |
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index a16fef52171ece3f1d1a9609616819519d637563..9a2d5c02263330f6a8c585669cffd1ba7af2a8d7 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
options.h\
conf.h\
command.h\
+ ncu.h \
screen.h\
screen_utils.h\
list_window.h\
options.c\
conf.c\
command.c\
+ ncu.c \
screen.c\
screen_utils.c\
screen_play.c\
diff --git a/src/main.c b/src/main.c
index 5dac8b92bb043d8ce5b84ad917d39b49086d825c..a33643d10e46b0cf44eed16bfdbde186e5183c00 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "conf.h"
#include "command.h"
#include "lyrics.h"
+#include "ncu.h"
#include "screen.h"
#include "screen_utils.h"
#include "strfsong.h"
exit(EXIT_FAILURE);
}
- ncurses_init();
+ ncu_init();
lyrics_init();
g_io_channel_unref(keyboard_channel);
exit_and_cleanup();
+ ncu_deinit();
}
diff --git a/src/ncu.c b/src/ncu.c
--- /dev/null
+++ b/src/ncu.c
@@ -0,0 +1,59 @@
+/* ncmpc
+ * (c) 2004 by Kalle Wallin <kaw@linux.se>
+ * Copyright (C) 2008 Max Kellermann <max@duempel.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "ncu.h"
+#include "colors.h"
+
+void
+ncu_init(void)
+{
+ /* initialize the curses library */
+ initscr();
+
+ /* initialize color support */
+ colors_start();
+
+ /* tell curses not to do NL->CR/NL on output */
+ nonl();
+
+ /* use raw mode (ignore interrupt,quit,suspend, and flow control ) */
+#ifdef ENABLE_RAW_MODE
+ // raw();
+#endif
+
+ /* don't echo input */
+ noecho();
+
+ /* set cursor invisible */
+ curs_set(0);
+
+ /* enable extra keys */
+ keypad(stdscr, TRUE);
+
+ /* initialize mouse support */
+#ifdef HAVE_GETMOUSE
+ if (options.enable_mouse)
+ mousemask(ALL_MOUSE_EVENTS, NULL);
+#endif
+}
+
+void
+ncu_deinit(void)
+{
+ endwin();
+}
diff --git a/src/ncu.h b/src/ncu.h
--- /dev/null
+++ b/src/ncu.h
@@ -0,0 +1,31 @@
+/* ncmpc
+ * Copyright (C) 2008 Max Kellermann <max@duempel.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Basic libnucrses initialization.
+ */
+
+#ifndef NCU_H
+#define NCU_H
+
+void
+ncu_init(void);
+
+void
+ncu_deinit(void);
+
+#endif
diff --git a/src/screen.c b/src/screen.c
index 2999b598ed0e3ae2403b4125c98161932b88ae25..92ce29e484a786dd91f5c5087522c7bfd3292014 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
{
guint i;
- endwin();
-
if (mode_fn->close != NULL)
mode_fn->close();
}
void
-ncurses_init(void)
+screen_init(mpdclient_t *c)
{
-
- /* initialize the curses library */
- initscr();
- /* initialize color support */
- colors_start();
- /* tell curses not to do NL->CR/NL on output */
- nonl();
- /* use raw mode (ignore interrupt,quit,suspend, and flow control ) */
-#ifdef ENABLE_RAW_MODE
- // raw();
-#endif
- /* don't echo input */
- noecho();
- /* set cursor invisible */
- curs_set(0);
- /* enable extra keys */
- keypad(stdscr, TRUE);
- /* initialize mouse support */
-#ifdef HAVE_GETMOUSE
- if (options.enable_mouse)
- mousemask(ALL_MOUSE_EVENTS, NULL);
-#endif
+ guint i;
if (COLS < SCREEN_MIN_COLS || LINES < SCREEN_MIN_ROWS) {
fprintf(stderr, _("Error: Screen to small!\n"));
}
refresh();
-}
-
-void
-screen_init(mpdclient_t *c)
-{
- guint i;
/* initialize screens */
for (i = 0; i < NUM_SCREENS; ++i) {
diff --git a/src/screen.h b/src/screen.h
index b9087e0ca3091248cd1eec7136b0e4cb533b1be5..ca0dd2a0cdccfefe6e5c941de20a1cb33d9c337e 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
screen_title_fn_t get_title;
} screen_functions_t;
-void
-ncurses_init(void);
-
void screen_init(mpdclient_t *c);
void screen_exit(void);
void screen_resize(void);