]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
Fixup 572b06d6: reduce cache size for breakString
[lyx.git] / src / insets / InsetRef.cpp
index 3e299d84a39a766381b5c9b53e9b0da44790deb3..eab3e69c1c840adc8d79b16ef86c846d4cd00159 100644 (file)
@@ -103,6 +103,13 @@ void InsetRef::changeTarget(docstring const & new_label)
 
 void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
+       // Ctrl + click: go to label
+       if (cmd.action() == LFUN_MOUSE_RELEASE && cmd.modifier() == ControlModifier) {
+                       lyx::dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
+                       lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference")));
+                       return;
+               }
+
        string const inset = cmd.getArg(0);
        string const arg   = cmd.getArg(1);
        string pstring;
@@ -124,19 +131,13 @@ void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
        }
 
-       // Ctrl + click: go to label
-       if (cmd.action() == LFUN_MOUSE_RELEASE && cmd.modifier() == ControlModifier) {
-                       lyx::dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
-                       lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference")));
-                       return;
-               }
-
        // otherwise not for us
        if (pstring.empty())
                return InsetCommand::doDispatch(cur, cmd);
 
        bool const isSet = (getParam(pstring) == "true");
        setParam(pstring, from_ascii(isSet ? "false"  : "true"));
+       cur.forceBufferUpdate();
 }
 
 
@@ -424,9 +425,11 @@ void InsetRef::toString(odocstream & os) const
 
 void InsetRef::forOutliner(docstring & os, size_t const, bool const) const
 {
-       // There's no need for details in the TOC, and a long label
-       // will just get in the way.
-       os += '#';
+       // It's hard to know what to do here. Should we show XREF in the TOC?
+       // Or should we just show that there is one? For now, we do the former.
+       odocstringstream ods;
+       plaintext(ods, OutputParams(nullptr));
+       os += ods.str();
 }
 
 
@@ -458,6 +461,18 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType, bool const /*del
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
                if (cmd == types[i].latex_name) {
                        label = _(types[i].short_gui_name);
+                       // indicate plural and caps
+                       if (cmd == "formatted") {
+                               bool const isPlural = getParam("plural") == "true";
+                               bool const isCaps = getParam("caps") == "true";
+                               if (isPlural)
+                                       label += from_ascii("+");
+                               if (isCaps) {
+                                       // up arrow (shift key) symbol
+                                       label += docstring(1, char_type(0x21E7));
+                               }
+                       }
+                       label += from_ascii(": ");
                        break;
                }
        }
@@ -522,7 +537,9 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
        broken_ = true;
        setBroken(broken_);
        shared_ptr<Toc> toc = backend.toc("label");
-       toc->push_back(TocItem(cpit, 0, screenLabel(), output_active));
+       if (TocBackend::findItem(*toc, 0, label) == toc->end())
+               toc->push_back(TocItem(cpit, 0, label, output_active, true));
+       toc->push_back(TocItem(cpit, 1, screenLabel(), output_active));
        shared_ptr<Toc> toc2 = backend.toc("brokenrefs");
        toc2->push_back(TocItem(cpit, 0, screenLabel(), output_active));
 }
@@ -579,14 +596,14 @@ bool InsetRef::forceLTR(OutputParams const & rp) const
 
 
 InsetRef::type_info const InsetRef::types[] = {
-       { "ref",       N_("Standard"),              N_("Ref")},
-       { "eqref",     N_("Equation"),              N_("EqRef")},
-       { "pageref",   N_("Page Number"),           N_("Page")},
-       { "vpageref",  N_("Textual Page Number"),   N_("TextPage")},
-       { "vref",      N_("Standard+Textual Page"), N_("Ref+Text")},
-       { "nameref",   N_("Reference to Name"),     N_("NameRef")},
-       { "formatted", N_("Formatted"),             N_("Format")},
-       { "labelonly", N_("Label Only"),            N_("Label")},
+       { "ref",       N_("Standard"),              N_("Ref")},
+       { "eqref",     N_("Equation"),              N_("EqRef")},
+       { "pageref",   N_("Page Number"),           N_("Page")},
+       { "vpageref",  N_("Textual Page Number"),   N_("TextPage")},
+       { "vref",      N_("Standard+Textual Page"), N_("Ref+Text")},
+       { "nameref",   N_("Reference to Name"),     N_("NameRef")},
+       { "formatted", N_("Formatted"),             N_("Format")},
+       { "labelonly", N_("Label Only"),            N_("Label")},
        { "", "", "" }
 };