Made case_{reader,writer}_class structures const.
[pspp-builds.git] / src / data / settings.c
index 3e95b6b5bfd3bf64eec1dd8d17471c9d29ea0d84..4d0ef3eb03ddbaad947c38255aa68c393c6280bf 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   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
 #include "xalloc.h"
 #include <libpspp/i18n.h>
 
-static int viewlength = 24;
-static int viewwidth = 79;
-static bool long_view = false;
+#include "error.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+static int *viewlength = NULL;
+static int *viewwidth = NULL;
 
 static bool safer_mode = false;
 
-static bool echo = false;
+static bool do_echo = false;
 static bool include = true;
 
 static int epoch = -1;
@@ -69,12 +73,12 @@ static int *algorithm = &global_algorithm;
 
 static int syntax = ENHANCED;
 
-static void init_viewport (void);
+static void init_viewport (int *, int *);
 
 void
-settings_init (void)
+settings_init (int *width, int *length)
 {
-  init_viewport ();
+  init_viewport (width, length);
   i18n_init ();
 }
 
@@ -88,81 +92,35 @@ settings_done (void)
 int
 get_viewlength (void)
 {
-  return viewlength;
+  return *viewlength;
 }
 
 /* Sets the view length. */
 void
 set_viewlength (int viewlength_)
 {
-  viewlength = viewlength_;
-}
-
-/* Set view width to a very long value, and prevent it from ever
-   changing. */
-void
-force_long_view (void)
-{
-  long_view = true;
-  viewwidth = 9999;
+  *viewlength = viewlength_;
 }
 
 /* Screen width. */
 int
 get_viewwidth(void)
 {
-  return viewwidth;
+  return *viewwidth;
 }
 
 /* Sets the screen width. */
 void
 set_viewwidth (int viewwidth_)
 {
-  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;
+  *viewwidth = viewwidth_;
 }
-#endif /* HAVE_LIBTERMCAP */
 
 static void
-init_viewport (void)
+init_viewport (int  *width, int *length)
 {
-  if (long_view)
-    return;
-
-  viewwidth = viewlength = -1;
-
-#if HAVE_LIBTERMCAP
-  get_termcap_viewport ();
-#endif /* HAVE_LIBTERMCAP */
-
-  if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
-    viewwidth = atoi (getenv ("COLUMNS"));
-  if (viewlength < 0 && getenv ("LINES") != NULL)
-    viewlength = atoi (getenv ("LINES"));
-
-  if (viewwidth < 0)
-    viewwidth = 79;
-  if (viewlength < 0)
-    viewlength = 24;
+  viewwidth = width;
+  viewlength = length;
 }
 
 /* Whether PSPP can erase and overwrite files. */
@@ -183,14 +141,14 @@ set_safer_mode (void)
 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. */