mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-01-07 06:28:57 +01:00
Add undocumented option -q, use it for -l
This commit is contained in:
parent
b39076ea19
commit
25b9e7ac58
157
src/boxes.c
157
src/boxes.c
@ -124,6 +124,7 @@ static void usage (FILE *st)
|
|||||||
fprintf (st, " -l list available box designs w/ samples\n");
|
fprintf (st, " -l list available box designs w/ samples\n");
|
||||||
fprintf (st, " -m mend box, i.e. remove it and redraw it afterwards\n");
|
fprintf (st, " -m mend box, i.e. remove it and redraw it afterwards\n");
|
||||||
fprintf (st, " -p fmt padding [default: none]\n");
|
fprintf (st, " -p fmt padding [default: none]\n");
|
||||||
|
//fprintf (st, " -q modify command for needs of the web UI (undocumented)\n");
|
||||||
fprintf (st, " -r remove box\n");
|
fprintf (st, " -r remove box\n");
|
||||||
fprintf (st, " -s wxh box size (width w and/or height h)\n");
|
fprintf (st, " -s wxh box size (width w and/or height h)\n");
|
||||||
fprintf (st, " -t str tab stop distance and expansion [default: %de]\n", DEF_TABSTOP);
|
fprintf (st, " -t str tab stop distance and expansion [default: %de]\n", DEF_TABSTOP);
|
||||||
@ -404,7 +405,7 @@ static int process_commandline (int argc, char *argv[])
|
|||||||
* Parse Command Line
|
* Parse Command Line
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
oc = getopt (argc, argv, "a:c:d:f:hi:k:lmp:rs:t:v");
|
oc = getopt (argc, argv, "a:c:d:f:hi:k:lmp:qrs:t:v");
|
||||||
|
|
||||||
switch (oc) {
|
switch (oc) {
|
||||||
|
|
||||||
@ -658,6 +659,13 @@ static int process_commandline (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'q':
|
||||||
|
/*
|
||||||
|
* Activate special behavior for web UI (undocumented)
|
||||||
|
*/
|
||||||
|
opt.q = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
/*
|
/*
|
||||||
* Remove box from input
|
* Remove box from input
|
||||||
@ -833,6 +841,7 @@ static int process_commandline (int argc, char *argv[])
|
|||||||
opt.justify? opt.justify: '?');
|
opt.justify? opt.justify: '?');
|
||||||
fprintf (stderr, "- Kill blank lines: %d\n", opt.killblank);
|
fprintf (stderr, "- Kill blank lines: %d\n", opt.killblank);
|
||||||
fprintf (stderr, "- Remove box: %d\n", opt.r);
|
fprintf (stderr, "- Remove box: %d\n", opt.r);
|
||||||
|
fprintf (stderr, "- Special handling for Web UI: %d\n", opt.q);
|
||||||
fprintf (stderr, "- Mend box: %d\n", opt.mend);
|
fprintf (stderr, "- Mend box: %d\n", opt.mend);
|
||||||
fprintf (stderr, "- Design Definition W shape: %s\n",
|
fprintf (stderr, "- Design Definition W shape: %s\n",
|
||||||
opt.cld? opt.cld: "n/a");
|
opt.cld? opt.cld: "n/a");
|
||||||
@ -1069,58 +1078,63 @@ static int list_styles()
|
|||||||
/*
|
/*
|
||||||
* Display all shapes
|
* Display all shapes
|
||||||
*/
|
*/
|
||||||
fprintf (opt.outfile, "Defined Shapes: ");
|
if (opt.q) {
|
||||||
until = -1;
|
fprintf (opt.outfile, "Sample:\n%s\n", d->sample);
|
||||||
sstart = 0;
|
}
|
||||||
do {
|
else {
|
||||||
sstart = until + 1;
|
fprintf (opt.outfile, "Defined Shapes: ");
|
||||||
for (w=0, i=sstart; i<ANZ_SHAPES; ++i) {
|
until = -1;
|
||||||
if (isempty(d->shape+i))
|
sstart = 0;
|
||||||
continue;
|
do {
|
||||||
w += 6;
|
sstart = until + 1;
|
||||||
w += d->shape[i].width;
|
for (w=0, i=sstart; i<ANZ_SHAPES; ++i) {
|
||||||
w += strlen(shape_name[i]);
|
|
||||||
if (i == 0)
|
|
||||||
w -= 2;
|
|
||||||
else if (w > 56) { /* assuming an 80 character screen */
|
|
||||||
until = i - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 (j=0; j<w; ++j) {
|
|
||||||
if (j > 0 || sstart > 0)
|
|
||||||
fprintf (opt.outfile, " ");
|
|
||||||
for (i=sstart; i<=until; ++i) {
|
|
||||||
if (isempty(d->shape+i))
|
if (isempty(d->shape+i))
|
||||||
continue;
|
continue;
|
||||||
fprintf (opt.outfile, " ");
|
w += 6;
|
||||||
if (j == 0)
|
w += d->shape[i].width;
|
||||||
fprintf (opt.outfile, "%s: ", shape_name[i]);
|
w += strlen(shape_name[i]);
|
||||||
else {
|
if (i == 0)
|
||||||
space[strlen(shape_name[i])+2] = '\0';
|
w -= 2;
|
||||||
fprintf (opt.outfile, "%s", space);
|
else if (w > 56) { /* assuming an 80 character screen */
|
||||||
space[strlen(shape_name[i])+2] = ' ';
|
until = i - 1;
|
||||||
}
|
break;
|
||||||
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 (i == ANZ_SHAPES)
|
||||||
}
|
until = ANZ_SHAPES - 1;
|
||||||
if (until < ANZ_SHAPES-1 && d->maxshapeheight > 2)
|
for (w=0, i=sstart; i<=until; ++i) {
|
||||||
fprintf (opt.outfile, "\n");
|
if (d->shape[i].height > w)
|
||||||
} while (until < ANZ_SHAPES-1);
|
w = d->shape[i].height;
|
||||||
|
}
|
||||||
|
for (j=0; j<w; ++j) {
|
||||||
|
if (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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1140,28 +1154,35 @@ static int list_styles()
|
|||||||
|
|
||||||
sprintf (buf, "%d", anz_designs);
|
sprintf (buf, "%d", anz_designs);
|
||||||
|
|
||||||
fprintf (opt.outfile, "%d Available Style%s in \"%s\":\n",
|
if (!opt.q) {
|
||||||
anz_designs, anz_designs==1?"":"s", yyfilename);
|
fprintf (opt.outfile, "%d Available Style%s in \"%s\":\n",
|
||||||
fprintf (opt.outfile, "-----------------------%s",
|
anz_designs, anz_designs==1?"":"s", yyfilename);
|
||||||
anz_designs==1? "": "-");
|
fprintf (opt.outfile, "-----------------------%s",
|
||||||
for (i=strlen(yyfilename)+strlen(buf); i>0; --i)
|
anz_designs==1? "": "-");
|
||||||
fprintf (opt.outfile, "-");
|
for (i=strlen(yyfilename)+strlen(buf); i>0; --i)
|
||||||
fprintf (opt.outfile, "\n\n");
|
fprintf (opt.outfile, "-");
|
||||||
|
fprintf (opt.outfile, "\n\n");
|
||||||
|
}
|
||||||
for (i=0; i<anz_designs; ++i) {
|
for (i=0; i<anz_designs; ++i) {
|
||||||
if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) {
|
if (opt.q) {
|
||||||
fprintf(opt.outfile, "%s\n%s, coded by %s:\n\n%s\n\n", list[i]->name,
|
fprintf(opt.outfile, "%s\n", list[i]->name);
|
||||||
list[i]->designer, list[i]->author, list[i]->sample);
|
|
||||||
}
|
|
||||||
else if (list[i]->designer) {
|
|
||||||
fprintf(opt.outfile, "%s\n%s:\n\n%s\n\n", list[i]->name,
|
|
||||||
list[i]->designer, list[i]->sample);
|
|
||||||
}
|
|
||||||
else if (list[i]->author) {
|
|
||||||
fprintf(opt.outfile, "%s\nunknown artist, coded by %s:\n\n%s\n\n", list[i]->name,
|
|
||||||
list[i]->author, list[i]->sample);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(opt.outfile, "%s:\n\n%s\n\n", list[i]->name, list[i]->sample);
|
if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) {
|
||||||
|
fprintf(opt.outfile, "%s\n%s, coded by %s:\n\n%s\n\n", list[i]->name,
|
||||||
|
list[i]->designer, list[i]->author, list[i]->sample);
|
||||||
|
}
|
||||||
|
else if (list[i]->designer) {
|
||||||
|
fprintf(opt.outfile, "%s\n%s:\n\n%s\n\n", list[i]->name,
|
||||||
|
list[i]->designer, list[i]->sample);
|
||||||
|
}
|
||||||
|
else if (list[i]->author) {
|
||||||
|
fprintf(opt.outfile, "%s\nunknown artist, coded by %s:\n\n%s\n\n", list[i]->name,
|
||||||
|
list[i]->author, list[i]->sample);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(opt.outfile, "%s:\n\n%s\n\n", list[i]->name, list[i]->sample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BFREE (list);
|
BFREE (list);
|
||||||
|
@ -121,6 +121,7 @@ extern char *yyfilename; /* name of config file */
|
|||||||
typedef struct { /* Command line options: */
|
typedef struct { /* Command line options: */
|
||||||
int l; /* list available designs */
|
int l; /* list available designs */
|
||||||
int mend; /* 1 if -m is given, 2 in 2nd loop */
|
int mend; /* 1 if -m is given, 2 in 2nd loop */
|
||||||
|
int q; /* special handling of web UI needs */
|
||||||
int r; /* remove box from input */
|
int r; /* remove box from input */
|
||||||
int tabstop; /* tab stop distance */
|
int tabstop; /* tab stop distance */
|
||||||
char tabexp; /* tab expansion mode (for leading tabs) */
|
char tabexp; /* tab expansion mode (for leading tabs) */
|
||||||
|
Loading…
Reference in New Issue
Block a user