]> git.lyx.org Git - features.git/commitdiff
Indicate see[also] refs in label and outliner
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 2 Nov 2022 14:56:59 +0000 (15:56 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 2 Nov 2022 14:56:59 +0000 (15:56 +0100)
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h

index b3024bf74cfd05f55070089d11a16e25d2d7d61e..5458c838bbbdcecdcb72dec83af4ed5640eb7fdc 100644 (file)
@@ -776,7 +776,8 @@ void InsetIndex::getSeeRefs(otexstream & os, OutputParams const & runparams) con
 }
 
 
-docstring InsetIndex::getSeeAsText(OutputParams const & runparams) const
+docstring InsetIndex::getSeeAsText(OutputParams const & runparams,
+                                  bool const asLabel) const
 {
        Paragraph const & par = paragraphs().front();
        InsetList::const_iterator it = par.insetList().begin();
@@ -786,9 +787,14 @@ docstring InsetIndex::getSeeAsText(OutputParams const & runparams) const
                        InsetIndexMacro const & iim =
                                static_cast<InsetIndexMacro const &>(inset);
                        if (iim.params().type == InsetIndexMacroParams::See) {
-                               otexstringstream os;
-                               iim.getLatex(os, runparams);
-                               return os.str();
+                               if (asLabel) {
+                                       docstring const l;
+                                       return iim.getNewLabel(l);
+                               } else {
+                                       otexstringstream os;
+                                       iim.getLatex(os, runparams);
+                                       return os.str();
+                               }
                        }
                }
        }
@@ -796,7 +802,8 @@ docstring InsetIndex::getSeeAsText(OutputParams const & runparams) const
 }
 
 
-std::vector<docstring> InsetIndex::getSeeAlsoesAsText(OutputParams const & runparams) const
+std::vector<docstring> InsetIndex::getSeeAlsoesAsText(OutputParams const & runparams,
+                                                     bool const asLabel) const
 {
        std::vector<docstring> seeAlsoes;
 
@@ -808,9 +815,14 @@ std::vector<docstring> InsetIndex::getSeeAlsoesAsText(OutputParams const & runpa
                        InsetIndexMacro const & iim =
                                static_cast<InsetIndexMacro const &>(inset);
                        if (iim.params().type == InsetIndexMacroParams::Seealso) {
-                               otexstringstream os;
-                               iim.getLatex(os, runparams);
-                               seeAlsoes.emplace_back(os.str());
+                               if (asLabel) {
+                                       docstring const l;
+                                       seeAlsoes.emplace_back(iim.getNewLabel(l));
+                               } else {
+                                       otexstringstream os;
+                                       iim.getLatex(os, runparams);
+                                       seeAlsoes.emplace_back(os.str());
+                               }
                        }
                }
        }
@@ -968,6 +980,13 @@ docstring const InsetIndex::buttonLabel(BufferView const & bv) const
                        res += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
                        res += " " + sublbl;
                }
+               docstring see = getSeeAsText(rp, true);
+               if (see.empty() && !getSeeAlsoesAsText(rp, true).empty())
+                       see = getSeeAlsoesAsText(rp, true).front();
+               if (!see.empty()) {
+                       res += " " + docstring(1, char_type(0x261e));// WHITE RIGHT POINTING INDEX
+                       res += " " + see;
+               }
        }
        if (!insetindexpagerangetranslator_latex().find(params_.range).empty())
                res += " " + from_ascii(insetindexpagerangetranslator_latex().find(params_.range));
@@ -1032,6 +1051,13 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
                        str += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
                        str += " " + sublbl;
                }
+               docstring see = getSeeAsText(rp, true);
+               if (see.empty() && !getSeeAlsoesAsText(rp, true).empty())
+                       see = getSeeAlsoesAsText(rp, true).front();
+               if (!see.empty()) {
+                       str += " " + docstring(1, char_type(0x261e));// WHITE RIGHT POINTING INDEX
+                       str += " " + see;
+               }
        }
        string type = "index";
        if (buffer().masterBuffer()->params().use_indices)
index 742ecae5459515992d360c98aeb44cf11ea64c06..a89a684974fa39e1ec9d4df81a44bc54981884b3 100644 (file)
@@ -113,9 +113,11 @@ private:
        ///
        void getSeeRefs(otexstream &, OutputParams const &) const;
        ///
-       docstring getSeeAsText(OutputParams const & runparams) const;
+       docstring getSeeAsText(OutputParams const & runparams,
+                              bool const asLabel = false) const;
        ///
-       std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams) const;
+       std::vector<docstring> getSeeAlsoesAsText(OutputParams const & runparams,
+                                                 bool const asLabel = false) const;
        ///
        bool hasSubentries() const;
        ///