commit 975f304185eca53d62de8b36e6fc5f95b2da4fd9
Author: Juergen Spitzmueller <[email protected]>
Date:   Wed Nov 2 15:56:59 2022 +0100

    Indicate see[also] refs in label and outliner
---
 src/insets/InsetIndex.cpp |   42 ++++++++++++++++++++++++++++++++++--------
 src/insets/InsetIndex.h   |    6 ++++--
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index b3024bf..5458c83 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -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)
diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h
index 742ecae..a89a684 100644
--- a/src/insets/InsetIndex.h
+++ b/src/insets/InsetIndex.h
@@ -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;
        ///
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to