aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-22 10:04:39 +0200
committerMax Kellermann <max@duempel.org>2008-09-22 10:04:39 +0200
commit07632841df4ff1d8fcfac33bd93e06ee43a4498e (patch)
treecadb859c1ae63041fbc774528974283a2b1635bf /src
parentd28a7d463b62412e2d075b834db20baf93dcaeba (diff)
downloadmpd-07632841df4ff1d8fcfac33bd93e06ee43a4498e.tar.gz
mpd-07632841df4ff1d8fcfac33bd93e06ee43a4498e.tar.xz
mpd-07632841df4ff1d8fcfac33bd93e06ee43a4498e.zip
screen: moved code to ncu.c
Moved basic libncurses initialization to ncu.c and ncu.h. Keep generic code out of screen.c.
Diffstat (limited to '')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/main.c4
-rw-r--r--src/ncu.c59
-rw-r--r--src/ncu.h31
-rw-r--r--src/screen.c33
-rw-r--r--src/screen.h3
6 files changed, 97 insertions, 35 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a16fef521..9a2d5c022 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,7 @@ ncmpc_headers = \
options.h\
conf.h\
command.h\
+ ncu.h \
screen.h\
screen_utils.h\
list_window.h\
@@ -51,6 +52,7 @@ ncmpc_SOURCES = \
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 5dac8b92b..a33643d10 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include "conf.h"
#include "command.h"
#include "lyrics.h"
+#include "ncu.h"
#include "screen.h"
#include "screen_utils.h"
#include "strfsong.h"
@@ -417,7 +418,7 @@ main(int argc, const char *argv[])
exit(EXIT_FAILURE);
}
- ncurses_init();
+ ncu_init();
lyrics_init();
@@ -452,4 +453,5 @@ main(int argc, const char *argv[])
g_io_channel_unref(keyboard_channel);
exit_and_cleanup();
+ ncu_deinit();
}
diff --git a/src/ncu.c b/src/ncu.c
new file mode 100644
index 000000000..ed3c2273b
--- /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
new file mode 100644
index 000000000..0a2ce5edf
--- /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 2999b598e..92ce29e48 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -429,8 +429,6 @@ screen_exit(void)
{
guint i;
- endwin();
-
if (mode_fn->close != NULL)
mode_fn->close();
@@ -531,30 +529,9 @@ screen_status_printf(const char *format, ...)
}
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"));
@@ -624,12 +601,6 @@ ncurses_init(void)
}
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 b9087e0ca..ca0dd2a0c 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -69,9 +69,6 @@ typedef struct screen_functions {
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);