From 37a3446f43f6572f05783972df75ba6b9d1a0bea Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 15 Jan 2021 21:52:14 -0800 Subject: [PATCH] output-item: Add basic support for visibility. --- src/output/output-item.c | 3 ++- src/output/output-item.h | 8 ++++++++ src/output/spv/spv-writer.c | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/output/output-item.c b/src/output/output-item.c index 1b7b4b7d1c..0168b10b4a 100644 --- a/src/output/output-item.c +++ b/src/output/output-item.c @@ -36,7 +36,7 @@ #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#define OUTPUT_ITEM_INITIALIZER(TYPE) .type = TYPE, .ref_cnt = 1 +#define OUTPUT_ITEM_INITIALIZER(TYPE) .type = TYPE, .ref_cnt = 1, .show = true /* Increases ITEM's reference count, indicating that it has an additional owner. An output item that is shared among multiple owners must not be @@ -126,6 +126,7 @@ output_item_unshare (struct output_item *old) .label = xstrdup_if_nonnull (old->label), .command_name = xstrdup_if_nonnull (old->command_name), .type = old->type, + .show = old->show, }; switch (old->type) { diff --git a/src/output/output-item.h b/src/output/output-item.h index 6c0c17592f..a408807f0f 100644 --- a/src/output/output-item.h +++ b/src/output/output-item.h @@ -59,6 +59,14 @@ struct output_item output. */ char *command_name; + /* For OUTPUT_ITEM_GROUP_OPEN, this is true if the group's subtree should + be expanded in an outline view, false otherwise. + + For other kinds of output items, this is true to show the item's + content, false to hide it. The item's label is always shown in an + outline view. */ + bool show; + enum output_item_type type; union { diff --git a/src/output/spv/spv-writer.c b/src/output/spv/spv-writer.c index 270f6beb87..70b455d456 100644 --- a/src/output/spv/spv-writer.c +++ b/src/output/spv/spv-writer.c @@ -234,6 +234,8 @@ spv_writer_open_heading (struct spv_writer *w, const struct output_item *item) start_elem (w, "heading"); if (item->command_name) write_attr (w, "commandName", item->command_name); + if (!item->show) + write_attr (w, "visibility", "collapsed"); /* XXX locale */ /* XXX olang */ @@ -280,7 +282,7 @@ open_container (struct spv_writer *w, const struct output_item *item, const char *inner_elem) { start_elem (w, "container"); - write_attr (w, "visibility", "visible"); + write_attr (w, "visibility", item->show ? "visible" : "hidden"); if (w->need_page_break) { write_attr (w, "page-break-before", "always"); -- 2.30.2