+2007-09-19 John Darrington <john@darrington.wattle.id.au>
+
+ * settings.c settings.h: Changed viewport's length and width to be
+ owned by the user interface which uses the data library. This allows
+ better abstraction, and makes dynamically adjustable dimensions easier.
+
2007-09-18 Ben Pfaff <blp@gnu.org>
* procedure.c (proc_extract_active_file_data): New function.
#include "gettext.h"
#define _(msgid) gettext (msgid)
-static int viewlength = 24;
-static int viewwidth = 79;
+static int *viewlength = NULL;
+static int *viewwidth = NULL;
static bool long_view = false;
static bool safer_mode = false;
static int syntax = ENHANCED;
-static void init_viewport (void);
-static void get_termcap_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 ();
}
int
get_viewlength (void)
{
- return viewlength;
+ return *viewlength;
}
/* Sets the view length. */
void
set_viewlength (int viewlength_)
{
- viewlength = viewlength_;
+ *viewlength = viewlength_;
}
/* Set view width to a very long value, and prevent it from ever
force_long_view (void)
{
long_view = true;
- viewwidth = 9999;
}
/* Screen width. */
int
get_viewwidth(void)
{
- return viewwidth;
+ if (long_view)
+ return 9999;
+
+ return *viewwidth;
}
/* Sets the screen width. */
void
set_viewwidth (int viewwidth_)
{
- viewwidth = viewwidth_;
+ *viewwidth = viewwidth_;
}
static void
-init_viewport (void)
+init_viewport (int *width, int *length)
{
+ viewwidth = width;
+ viewlength = length;
+
if (long_view)
return;
- viewwidth = viewlength = -1;
-
- get_termcap_viewport ();
-
- 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;
}
/* Whether PSPP can erase and overwrite files. */
{
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 */
#include <stdbool.h>
#include <stddef.h>
-void settings_init (void);
+void settings_init (int *, int *);
void settings_done (void);
void force_long_view (void);
+2007-09-19 John Darrington <john@darrington.wattle.id.au>
+
+ * message-dialog.c: Changed the ouput message title to be
+ appropriate for the severity of the message.
+
+ * output-viewer.c output-viewer.h : Added a callback for the resize
+ signal of the output viewer, and set the viewport length and
+ width accordingly.
+
+ * psppire.c: Update to new init_settings interface.
+
2007-09-27 John Darrington <john@darrington.wattle.id.au>
Addressing bug #20821:
{
case MSG_ERROR:
message_type = GTK_MESSAGE_ERROR;
+ switch (m->category)
+ {
+ case MSG_SYNTAX:
+ msg = _("Script Error");
+ break;
+
+ case MSG_DATA:
+ msg = _("Data File Error");
+ break;
+
+ case MSG_GENERAL:
+ default:
+ msg = _("PSPP Error");
+ break;
+ };
break;
case MSG_WARNING:
message_type = GTK_MESSAGE_WARNING;
+ switch (m->category)
+ {
+ case MSG_SYNTAX:
+ msg = _("Script Warning");
break;
- case MSG_NOTE:
+
+ case MSG_DATA:
+ msg = _("Data File Warning");
+ break;
+
+ case MSG_GENERAL:
default:
- message_type = GTK_MESSAGE_INFO;
+ msg = _("PSPP Warning");
break;
};
-
+ break;
+ case MSG_NOTE:
+ default:
+ message_type = GTK_MESSAGE_INFO;
switch (m->category)
{
case MSG_SYNTAX:
- msg = _("Script Error");
+ msg = _("Script Information");
break;
case MSG_DATA:
- msg = _("Data File Error");
+ msg = _("Data File Information");
break;
case MSG_GENERAL:
default:
- msg = _("PSPP Error");
+ msg = _("PSPP Information");
+ break;
+ };
break;
};
static struct output_viewer *the_output_viewer = NULL;
+int viewer_length = -1;
+int viewer_width = -1;
/* Callback for the "delete" action (clicking the x on the top right
hand corner of the window) */
}
+/* Sets width and length according to the new size
+ of the output window */
+static void
+on_textview_resize (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer user_data)
+{
+ PangoContext * context ;
+ PangoLayout *layout ;
+ PangoRectangle logical;
+ GtkStyle *style;
+ gint right_margin, left_margin;
+ GtkTextView *text_view = GTK_TEXT_VIEW (widget);
+
+ context = gtk_widget_create_pango_context (widget);
+ layout = pango_layout_new (context);
+
+ style = gtk_widget_get_style (widget);
+
+ pango_layout_set_font_description (layout, style->font_desc);
+
+ /* Find the width of one character. We can use any character, because
+ the textview has a monospaced font */
+ pango_layout_set_text (layout, "M", 1);
+
+ pango_layout_get_extents (layout, NULL, &logical);
+
+ left_margin = gtk_text_view_get_left_margin (text_view);
+ right_margin = gtk_text_view_get_right_margin (text_view);
+
+ viewer_length = allocation->height / PANGO_PIXELS (logical.height);
+ viewer_width = (allocation->width - right_margin - left_margin)
+ / PANGO_PIXELS (logical.width);
+
+ g_object_unref (G_OBJECT (layout));
+ g_object_unref (G_OBJECT (context));
+}
+
+
+
/*
Create a new output viewer
*/
pango_font_description_free (font_desc);
}
+ g_signal_connect (ov->textview, "size-allocate",
+ G_CALLBACK (on_textview_resize), NULL);
+
ov->fp = NULL;
g_signal_connect (get_widget_assert (xml,"help_about"),
#include "window-manager.h"
+extern int viewer_length ;
+extern int viewer_width ;
+
struct output_viewer * new_output_viewer (void);
void reload_viewer (struct output_viewer *);
fmt_init ();
fn_init ();
outp_init ();
- settings_init ();
+ settings_init (&viewer_width, &viewer_length);
fh_init ();
the_source_stream =
create_source_stream (
+2007-09-19 John Darrington <john@darrington.wattle.id.au>
+
+ * main.c: Moved get_termcap_viewport from src/data/settings.c
+ Added a handler for SIGWINCH to call this function. Adjusted
+ init_settings to suit new interface.
+
2007-09-22 Ben Pfaff <blp@gnu.org>
Bug #21128. Reviewed by John Darrington.
static struct lexer *the_lexer;
static struct source_stream *the_source_stream ;
+static int view_length = -1;
+static int view_width = -1;
+
+static void get_termcap_viewport (int);
+
/* Program entry point. */
int
signal (SIGSEGV, bug_handler);
signal (SIGFPE, bug_handler);
signal (SIGINT, interrupt_handler);
+ signal (SIGWINCH, get_termcap_viewport);
set_program_name (argv[0]);
);
prompt_init ();
readln_initialize ();
- settings_init ();
+ get_termcap_viewport (0);
+ settings_init (&view_width, &view_length);
random_init ();
the_dataset = create_dataset ();
}
exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
}
+
+\f
+
+#include "error.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+static void
+set_fallback_viewport (void)
+{
+ if (view_width < 0 && getenv ("COLUMNS") != NULL)
+ view_width = atoi (getenv ("COLUMNS"));
+
+ if (view_length < 0 && getenv ("LINES") != NULL)
+ view_length = atoi (getenv ("LINES"));
+
+ if (view_width < 0)
+ view_width = 79;
+
+ if (view_length < 0)
+ view_length = 24;
+}
+
+/* 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 (int sig UNUSED)
+{
+ char term_buffer [16384];
+
+ if (getenv ("TERM") == NULL)
+ goto fallback;
+
+ else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
+ {
+ error (0,0, _("could not access definition for terminal `%s'"),
+ getenv ("TERM"));
+ goto fallback;
+ }
+
+ if (tgetnum ("li") > 0)
+ view_length = tgetnum ("li");
+
+ if (tgetnum ("co") > 1)
+ view_width = tgetnum ("co") - 1;
+
+ fallback:
+ set_fallback_viewport ();
+}
+
+#else /* !HAVE_LIBNCURSES */
+
+static void
+get_termcap_viewport (int sig UNUSED)
+{
+ set_fallback_viewport ();
+}
+
+#endif /* !HAVE_LIBNCURSES */
+
+