-/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
- 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 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 3 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.
+ 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. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "settings.h"
#include "xalloc.h"
#include <libpspp/i18n.h>
+#include "error.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
static int viewlength = 24;
static int viewwidth = 79;
static bool long_view = false;
static bool safer_mode = false;
-static bool echo = false;
+static bool do_echo = false;
static bool include = true;
static int epoch = -1;
static int syntax = ENHANCED;
static void init_viewport (void);
+static void get_termcap_viewport (void);
void
settings_init (void)
viewwidth = viewwidth_;
}
-#if HAVE_LIBTERMCAP
-static void
-get_termcap_viewport (void)
-{
- char term_buffer[16384];
- if (getenv ("TERM") == NULL)
- return;
- else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
- {
- msg (IE, _("Could not access definition for terminal `%s'."), termtype);
- return;
- }
-
- if (tgetnum ("li") > 0)
- viewlength = tgetnum ("li");
-
- if (tgetnum ("co") > 1)
- viewwidth = tgetnum ("co") - 1;
-}
-#endif /* HAVE_LIBTERMCAP */
-
static void
init_viewport (void)
{
viewwidth = viewlength = -1;
-#if HAVE_LIBTERMCAP
get_termcap_viewport ();
-#endif /* HAVE_LIBTERMCAP */
if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
viewwidth = atoi (getenv ("COLUMNS"));
bool
get_echo (void)
{
- return echo;
+ return do_echo;
}
/* Set echo. */
void
set_echo (bool echo_)
{
- echo = echo_;
+ do_echo = echo_;
}
/* If echo is on, whether commands from include files are echoed. */
{
syntax = mode;
}
+\f
+/* Code that interfaces to ncurses. This must be at the very end
+ of this file because curses.h redefines "bool" on some systems
+ (e.g. OpenBSD), causing declaration mismatches with functions
+ that have parameters or return values of type "bool". */
+#if HAVE_LIBNCURSES
+#include <curses.h>
+#include <term.h>
+
+static void
+get_termcap_viewport (void)
+{
+ char term_buffer[16384];
+ if (getenv ("TERM") == NULL)
+ return;
+ else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
+ {
+ error (0,0, _("could not access definition for terminal `%s'"),
+ getenv ("TERM"));
+ return;
+ }
+
+ if (tgetnum ("li") > 0)
+ viewlength = tgetnum ("li");
+
+ if (tgetnum ("co") > 1)
+ viewwidth = tgetnum ("co") - 1;
+}
+#else /* !HAVE_LIBNCURSES */
+static void
+get_termcap_viewport (void)
+{
+ /* Nothing to do. */
+}
+#endif /* !HAVE_LIBNCURSES */