From: Ben Pfaff Date: Fri, 27 Jul 2007 22:59:32 +0000 (+0000) Subject: Add tty and listing devices that use VT100 (and xterm) line-drawing X-Git-Tag: v0.6.0~342 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baf657198fcf0cabe289246dc07a82da67c86f5b;p=pspp-builds.git Add tty and listing devices that use VT100 (and xterm) line-drawing characters, and corresponding support for an initialization string in the ASCII output device. --- diff --git a/config/ChangeLog b/config/ChangeLog index b5f672a3..b865ad2d 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,8 @@ +2007-07-25 Ben Pfaff + + * devices: Add tty and listing devices that use VT100 (and xterm) + line-drawing characters. + 2007-07-25 Ben Pfaff * devices: Add an "interactive" category that defaults to diff --git a/config/devices b/config/devices index ab96d66d..32d51bef 100644 --- a/config/devices +++ b/config/devices @@ -61,6 +61,20 @@ raw-ascii:ascii:screen:width=9999 length=9999 output-file=${list-output-file} \ tty-ascii-bi:ascii:screen:output-file=${tty-output-file} list-ascii-bi:ascii:listing:length=66 width=79 output-file=${list-output-file} +# VT100 graphics devices. +define vt100-graphics \ + init='\033(B\033)0' \ + box[1000]='\16q\17' box[1010]='\16q\17' box[0010]='\16q\17' \ + box[0100]='\16x\17' box[0101]='\16x\17' box[0001]='\16x\17' \ + box[0011]='\16j\17' box[1100]='\16l\17' box[0110]='\16k\17' \ + box[1001]='\16m\17' box[1110]='\16w\17' box[1101]='\16t\17' \ + box[0111]='\16u\17' box[1011]='\16v\17' box[1111]='\16n\17' + +tty-vt100:ascii:screen:squeeze=on headers=off top-margin=0 bottom-margin=0 \ + paginate=off output-file=${tty-output-file} ${vt100-graphics} +list-vt100:ascii:listing:length=66 width=79 output-file=${list-output-file} \ + ${vt100-graphics} + # HTML device. html:html:: diff --git a/doc/configuring.texi b/doc/configuring.texi index b4aea100..43be3d67 100644 --- a/doc/configuring.texi +++ b/doc/configuring.texi @@ -668,7 +668,7 @@ The available options are listed below. @item output-file=@var{file-name} File to which output should be sent. This can be an ordinary file name -(e.g., @code{"pspp.txt"}), a pipe (e.g., @code{"|lpr"}), or +(e.g., @code{"pspp.txt"}), a pipe (e.g., @code{"|more"}), or stdout (@code{"-"}). Default: @code{"pspp.list"}. @item paginate=@var{boolean} @@ -781,6 +781,11 @@ For all others, @samp{+} is used unless there are double lines or special lines, in which case @samp{#} is used. @end itemize +@item init=@var{init-string} +If set, this string is written at the beginning of each output file. +It can be used to initialize device features, e.g.@: to enable VT100 +line-drawing characters. + @item emphasis=@var{emphasis-style} How to emphasize text. Your choices are @code{bold}, @code{underline}, diff --git a/src/output/ChangeLog b/src/output/ChangeLog index 5b0318f7..12f93d64 100644 --- a/src/output/ChangeLog +++ b/src/output/ChangeLog @@ -1,3 +1,14 @@ +2007-07-25 Ben Pfaff + + Allow the user to specify an initialization string to write at the + beginning of an ASCII output file. + * ascii.c (struct ascii_driver_ext): New member `init'. + (ascii_open_driver): Initialize `init'. + (ascii_close_driver): Parse `init'. + (ascii_open_page): Write `init' to output file. + + * output.c (get_option_token): Fix parsing of octal constants. + 2007-07-25 Ben Pfaff Make interactive output go to the terminal (bug #17213), by diff --git a/src/output/ascii.c b/src/output/ascii.c index f1d5a9be..0a26c75a 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -53,6 +53,7 @@ bottom-margin=2 box[x]="strng" Sets box character X (X in base 4: 0-3333). + init="string" Set initialization string. */ /* Disable messages by failed range checks. */ @@ -106,6 +107,7 @@ struct ascii_driver_ext int bottom_margin; /* Bottom margin in lines. */ char *box[LNS_COUNT]; /* Line & box drawing characters. */ + char *init; /* Device initialization string. */ /* Internal state. */ char *file_name; /* Output file name. */ @@ -144,6 +146,7 @@ ascii_open_driver (struct outp_driver *this, struct substring options) x->bottom_margin = 2; for (i = 0; i < LNS_COUNT; i++) x->box[i] = NULL; + x->init = NULL; x->file_name = pool_strdup (x->pool, "pspp.list"); x->file = NULL; x->page_number = 0; @@ -231,10 +234,11 @@ ascii_close_driver (struct outp_driver *this) enum { boolean_arg, - string_arg, + emphasis_arg, nonneg_int_arg, pos_int_arg, - output_file_arg + output_file_arg, + string_arg }; static const struct outp_option option_tab[] = @@ -243,7 +247,7 @@ static const struct outp_option option_tab[] = {"paginate", boolean_arg, 1}, {"squeeze", boolean_arg, 2}, - {"emphasis", string_arg, 3}, + {"emphasis", emphasis_arg, 0}, {"output-file", output_file_arg, 0}, @@ -254,6 +258,8 @@ static const struct outp_option option_tab[] = {"bottom-margin", nonneg_int_arg, 1}, {"tab-width", nonneg_int_arg, 2}, + {"init", string_arg, 0}, + {NULL, 0, 0}, }; @@ -318,7 +324,7 @@ handle_option (struct outp_driver *this, const char *key, } } break; - case string_arg: + case emphasis_arg: if (!strcmp (value, "bold")) x->emphasis = EMPH_BOLD; else if (!strcmp (value, "underline")) @@ -390,6 +396,10 @@ handle_option (struct outp_driver *this, const char *key, } } break; + case string_arg: + free (x->init); + x->init = pool_strdup (x->pool, value); + break; default: NOT_REACHED (); } @@ -413,6 +423,9 @@ ascii_open_page (struct outp_driver *this) return; } pool_attach_file (x->pool, x->file); + + if (x->init != NULL) + fputs (x->init, x->file); } x->page_number++; diff --git a/src/output/output.c b/src/output/output.c index 243e7cd3..3f1dd904 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -562,7 +562,7 @@ get_option_token (struct substring *s, const char *driver_name, case '7': out = c - '0'; while (ss_first (*s) >= '0' && ss_first (*s) <= '7') - out = c * 8 + (ss_get_char (s) - '0'); + out = out * 8 + (ss_get_char (s) - '0'); break; case 'x': case 'X':