diff --git a/src/boxes.c b/src/boxes.c index 1e27c69..1d9317f 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -922,6 +922,20 @@ static int build_design (design_t **adesigns, const char *cld) } +static char* escape (const char* org, const int pLength) +{ + char* result = (char *) calloc (1, 2 * strlen(org) + 1); + int orgIdx, resultIdx; + for (orgIdx=0, resultIdx=0; orgIdxsample); } else { - fprintf (opt.outfile, "Defined Shapes: "); - until = -1; - sstart = 0; - do { - sstart = until + 1; - for (w=0, i=sstart; ishape+i)) - continue; - w += 6; - w += d->shape[i].width; - w += strlen(shape_name[i]); - if (i == 0) - w -= 2; - else if (w > 56) { /* assuming an 80 character screen */ - until = i - 1; - break; - } + int first_shape = 1; + for (i=0; ishape+i)) { + continue; } - if (i == ANZ_SHAPES) - until = ANZ_SHAPES - 1; - for (w=0, i=sstart; i<=until; ++i) { - if (d->shape[i].height > w) - w = d->shape[i].height; + for (w=0; wshape[i].height; ++w) { + char* escaped_line = escape(d->shape[i].chars[w], d->shape[i].width); + fprintf (opt.outfile, "%-24s%3s%c \"%s\"%c\n", + (first_shape==1 && w==0? "Defined Shapes:": ""), + (w==0? shape_name[i]: ""), (w==0? ':':' '), + escaped_line, + (wshape[i].height-1? ',': ' ') + ); + BFREE (escaped_line); } - for (j=0; j 0 || sstart > 0) - fprintf (opt.outfile, " "); - for (i=sstart; i<=until; ++i) { - if (isempty(d->shape+i)) - continue; - fprintf (opt.outfile, " "); - if (j == 0) - fprintf (opt.outfile, "%s: ", shape_name[i]); - else { - space[strlen(shape_name[i])+2] = '\0'; - fprintf (opt.outfile, "%s", space); - space[strlen(shape_name[i])+2] = ' '; - } - if (j < d->shape[i].height) { - fprintf (opt.outfile, "\"%s\"", d->shape[i].chars[j]); - } - else { - space[d->shape[i].width+2] = '\0'; - fprintf (opt.outfile, "%s", space); - space[d->shape[i].width+2] = ' '; - } - } - fprintf (opt.outfile, "\n"); - } - if (until < ANZ_SHAPES-1 && d->maxshapeheight > 2) - fprintf (opt.outfile, "\n"); - } while (until < ANZ_SHAPES-1); + first_shape = 0; + } } }