X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fdata%2Fsettings.c;h=4d0ef3eb03ddbaad947c38255aa68c393c6280bf;hb=2da08e801be698df268f35ac6e21cc8a345ba1fb;hp=b14fb618f3a235addab2a140270dae0a7149f0aa;hpb=458d169f64134f4e0a9d9b72398666a01761fcf8;p=pspp-builds.git diff --git a/src/data/settings.c b/src/data/settings.c index b14fb618..4d0ef3eb 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -26,17 +26,11 @@ #include "error.h" -#ifdef HAVE_LIBNCURSES -#include -#include -#endif - #include "gettext.h" #define _(msgid) gettext (msgid) -static int viewlength = 24; -static int viewwidth = 79; -static bool long_view = false; +static int *viewlength = NULL; +static int *viewwidth = NULL; static bool safer_mode = false; @@ -79,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 (); } @@ -98,82 +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_; + *viewwidth = viewwidth_; } -#if HAVE_LIBNCURSES static void -get_termcap_viewport (void) +init_viewport (int *width, int *length) { - 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; -} -#endif /* HAVE_LIBNCURSES */ - -static void -init_viewport (void) -{ - if (long_view) - return; - - viewwidth = viewlength = -1; - -#if HAVE_LIBNCURSES - get_termcap_viewport (); -#endif /* HAVE_LIBNCURSES */ - - 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. */