output-item: Add basic support for visibility.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 16 Jan 2021 05:52:14 +0000 (21:52 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 25 Jan 2021 04:51:49 +0000 (20:51 -0800)
src/output/output-item.c
src/output/output-item.h
src/output/spv/spv-writer.c

index 1b7b4b7d1c06c90714fce02a49ec45e6f70680e5..0168b10b4a5e6a07caa206d6dd6f8248d6a49793 100644 (file)
@@ -36,7 +36,7 @@
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 \f
-#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)
     {
index 6c0c17592f75b07b49e37c4ab37b78082a83b2ee..a408807f0fe7c9114125633b996f2820d0fe0211 100644 (file)
@@ -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
       {
index 270f6beb87ff95c63b2757673f0cdc0a43cbce5a..70b455d4567a67e0de3ddf17f12eff0e34d8e9ea 100644 (file)
@@ -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");