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
23
src/boxes.c
23
src/boxes.c
@ -124,6 +124,7 @@ static void usage (FILE *st)
|
||||
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, " -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, " -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);
|
||||
@ -404,7 +405,7 @@ static int process_commandline (int argc, char *argv[])
|
||||
* Parse Command Line
|
||||
*/
|
||||
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) {
|
||||
|
||||
@ -658,6 +659,13 @@ static int process_commandline (int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
/*
|
||||
* Activate special behavior for web UI (undocumented)
|
||||
*/
|
||||
opt.q = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
/*
|
||||
* Remove box from input
|
||||
@ -833,6 +841,7 @@ static int process_commandline (int argc, char *argv[])
|
||||
opt.justify? opt.justify: '?');
|
||||
fprintf (stderr, "- Kill blank lines: %d\n", opt.killblank);
|
||||
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, "- Design Definition W shape: %s\n",
|
||||
opt.cld? opt.cld: "n/a");
|
||||
@ -1069,6 +1078,10 @@ static int list_styles()
|
||||
/*
|
||||
* Display all shapes
|
||||
*/
|
||||
if (opt.q) {
|
||||
fprintf (opt.outfile, "Sample:\n%s\n", d->sample);
|
||||
}
|
||||
else {
|
||||
fprintf (opt.outfile, "Defined Shapes: ");
|
||||
until = -1;
|
||||
sstart = 0;
|
||||
@ -1122,6 +1135,7 @@ static int list_styles()
|
||||
fprintf (opt.outfile, "\n");
|
||||
} while (until < ANZ_SHAPES-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
@ -1140,6 +1154,7 @@ static int list_styles()
|
||||
|
||||
sprintf (buf, "%d", anz_designs);
|
||||
|
||||
if (!opt.q) {
|
||||
fprintf (opt.outfile, "%d Available Style%s in \"%s\":\n",
|
||||
anz_designs, anz_designs==1?"":"s", yyfilename);
|
||||
fprintf (opt.outfile, "-----------------------%s",
|
||||
@ -1147,7 +1162,12 @@ static int list_styles()
|
||||
for (i=strlen(yyfilename)+strlen(buf); i>0; --i)
|
||||
fprintf (opt.outfile, "-");
|
||||
fprintf (opt.outfile, "\n\n");
|
||||
}
|
||||
for (i=0; i<anz_designs; ++i) {
|
||||
if (opt.q) {
|
||||
fprintf(opt.outfile, "%s\n", list[i]->name);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
@ -1164,6 +1184,7 @@ static int list_styles()
|
||||
fprintf(opt.outfile, "%s:\n\n%s\n\n", list[i]->name, list[i]->sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
BFREE (list);
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,7 @@ extern char *yyfilename; /* name of config file */
|
||||
typedef struct { /* Command line options: */
|
||||
int l; /* list available designs */
|
||||
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 tabstop; /* tab stop distance */
|
||||
char tabexp; /* tab expansion mode (for leading tabs) */
|
||||
|
Loading…
Reference in New Issue
Block a user