summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-11-03 02:17:19 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-11-03 02:17:19 (GMT)
commit8d7d7ced0392b39e72a7a0dfe9de2deb112fd01f (patch)
tree52a93f9d06a094077e17b83a59cba483a12c854c /gfx
parent02bb8b3210667825a1fceedfb9c5b46b8177a9cb (diff)
downloadeeshow-8d7d7ced0392b39e72a7a0dfe9de2deb112fd01f.zip
eeshow-8d7d7ced0392b39e72a7a0dfe9de2deb112fd01f.tar.gz
eeshow-8d7d7ced0392b39e72a7a0dfe9de2deb112fd01f.tar.bz2
gtx/cro.c, main/eeplot.c: new option -n to include sheet numbers in PDF TOC
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index c68ba01..68c0616 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -71,6 +71,7 @@ struct cro_ctx {
const char *output_name;
bool add_toc;
+ bool sheet_numbers;
struct pdftoc *toc;
int color_override; /* FIG color, COLOR_NONE if no override */
@@ -528,6 +529,7 @@ static struct cro_ctx *new_cc(void)
cc->output_name = NULL;
cc->add_toc = 1;
+ cc->sheet_numbers = 0;
cc->toc = NULL;
/*
* record_init does not perform allocations or such, so it's safe to
@@ -567,6 +569,9 @@ static bool cr_args(void *ctx, int argc, char *const *argv, const char *opts)
colon = strchr(optarg, ':');
cc->output_name = colon ? colon + 1 : optarg;
break;
+ case 'n':
+ cc->sheet_numbers = 1;
+ break;
case 's':
cc->scale = atof(optarg) * cc->default_scale;
break;
@@ -682,8 +687,13 @@ static void cr_pdf_sheet_name(void *ctx, const char *name)
{
struct cro_ctx *cc = ctx;
- if (cc->toc)
- pdftoc_title(cc->toc, name ? name : "???");
+ if (!cc->toc)
+ return;
+ if (cc->sheet_numbers)
+ pdftoc_title(cc->toc, "%u %s",
+ cc->n_sheets + 1, name ? name : "???");
+ else
+ pdftoc_title(cc->toc, "%s", name ? name : "???");
}
@@ -1166,7 +1176,7 @@ static const char *const cro_pdf_ext[] = { "pdf" };
const struct gfx_ops cro_pdf_ops = {
.ext = cro_pdf_ext,
.n_ext = ARRAY_ELEMENTS(cro_pdf_ext),
- .opts = "o:s:T",
+ .opts = "o:ns:T",
.line = record_line,
.poly = record_poly,