From: John Darrington Date: Tue, 25 Sep 2007 23:59:40 +0000 (+0000) Subject: Fix GUI output viewer to use the "auto" feature of the driver width X-Git-Tag: v0.6.0~245 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=646890cac8de355277617ea100898c7d858a92d2;p=pspp-builds.git Fix GUI output viewer to use the "auto" feature of the driver width and length. Closes patch #6210. --- diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index c63f744b..eab0f7af 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,11 @@ +2007-09-26 John Darrington + + * output-viewer.c output-viewer.h psppire.c: (closes patch #6210) + Changed width and length parameters of output driver to + "auto". Changed default width and length to be something + acceptable to the ascii driver. (reload_viewer) Dynamically + allocate the line buffer so that it matches the width of the output. + 2007-09-24 Ben Pfaff * message-dialog.c (popup_message): Refer to files that contain diff --git a/src/ui/gui/output-viewer.c b/src/ui/gui/output-viewer.c index 62dc85f1..d3b78f14 100644 --- a/src/ui/gui/output-viewer.c +++ b/src/ui/gui/output-viewer.c @@ -46,8 +46,8 @@ cancel_urgency (GtkWindow *window, gpointer data) static struct output_viewer *the_output_viewer = NULL; -int viewer_length = -1; -int viewer_width = -1; +int viewer_length = 16; +int viewer_width = 59; /* Callback for the "delete" action (clicking the x on the top right hand corner of the window) */ @@ -196,7 +196,7 @@ void reload_viewer (struct output_viewer *ov) { GtkTextIter end_iter; - char line[OUTPUT_LINE_WIDTH]; + static char *line = NULL; GtkTextMark *mark ; gboolean chars_inserted = FALSE; @@ -211,12 +211,14 @@ reload_viewer (struct output_viewer *ov) } } + line = xrealloc (line, sizeof (char) * (viewer_width + 1)); + gtk_text_buffer_get_end_iter (ov->buffer, &end_iter); mark = gtk_text_buffer_create_mark (ov->buffer, NULL, &end_iter, TRUE); /* Read in the next lot of text */ - while (fgets (line, OUTPUT_LINE_WIDTH, ov->fp) != NULL) + while (fgets (line, viewer_width + 1, ov->fp) != NULL) { chars_inserted = TRUE; gtk_text_buffer_insert (ov->buffer, &end_iter, line, -1); diff --git a/src/ui/gui/output-viewer.h b/src/ui/gui/output-viewer.h index 2036b66f..b5c9ffce 100644 --- a/src/ui/gui/output-viewer.h +++ b/src/ui/gui/output-viewer.h @@ -35,10 +35,5 @@ void reload_the_viewer (void); #define OUTPUT_FILE_NAME "psppire.txt" -/* Make sure these two agree !! */ -#define OUTPUT_LINE_WIDTH 80 -#define OUTPUT_LINE_WIDTH_str "80" - - #endif diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index b874d393..eaf9ca95 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -111,8 +111,8 @@ initialize (void) outp_configure_driver_line ( ss_cstr ("gui:ascii:screen:squeeze=on headers=off top-margin=0 " - "bottom-margin=0 paginate=off length=50 " - "width=" OUTPUT_LINE_WIDTH_str " emphasis=none " + "bottom-margin=0 paginate=off length=auto width=auto " + "emphasis=none " "output-file=\"" OUTPUT_FILE_NAME "\" append=yes")); unlink (OUTPUT_FILE_NAME);