]> git.lyx.org Git - features.git/commitdiff
Fix bug 11070.
authorRichard Heck <rgheck@lyx.org>
Sat, 7 Apr 2018 01:31:11 +0000 (21:31 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 4 Oct 2018 04:17:47 +0000 (00:17 -0400)
Allows plural, caps, no prefix to be set via context menu.

(cherry picked from commit 35afcfb6dd4fe9519cb132c55714c73be981b275)

lib/ui/stdcontext.inc
src/insets/InsetRef.cpp
src/insets/InsetRef.h
status.23x

index 9acf334562eab6471a87906774ebe2fc388af2d9..47cf349784e0719ab710500cc192704fc603f7db 100644 (file)
@@ -96,6 +96,10 @@ Menuset
                Item "Textual Reference|x" "inset-modify changetype nameref"
                Item "Label Only|L" "inset-modify changetype labelonly"
                Separator
+               OptItem "Plural|a" "inset-modify ref toggle-plural"
+               OptItem "Capitalize|C" "inset-modify ref toggle-caps"
+               Item "No Prefix" "inset-modify ref toggle-noprefix"
+               Separator
                Item "Settings...|S" "inset-settings"
        End
 
index 44770e80524141baa3f243b18c3a92cfa0803fb1..124738daf7a88d6e0bea4584527eaf2d5d72a545 100644 (file)
@@ -15,6 +15,7 @@
 #include "BufferParams.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
+#include "FuncStatus.h"
 #include "InsetLabel.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
@@ -78,6 +79,60 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
 }
 
 
+void InsetRef::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+       string const inset = cmd.getArg(0);
+       string const arg   = cmd.getArg(1);
+       string pstring;
+       if (cmd.action() == LFUN_INSET_MODIFY && inset == "ref") {
+               if (arg == "toggle-plural")
+                       pstring = "plural";
+               else if (arg == "toggle-caps")
+                       pstring = "caps";
+               else if (arg == "toggle-noprefix")
+                       pstring = "noprefix";
+       }
+       // 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"));
+}
+
+
+bool InsetRef::getStatus(Cursor & cur, FuncRequest const & cmd,
+       FuncStatus & status) const
+{
+       if (cmd.action() != LFUN_INSET_MODIFY)
+               return InsetCommand::getStatus(cur, cmd, status);
+       if (cmd.getArg(0) != "ref")
+               return InsetCommand::getStatus(cur, cmd, status);
+
+       string const arg = cmd.getArg(1);
+       string pstring;
+       if (arg == "toggle-plural")
+               pstring = "plural";
+       else if (arg == "toggle-caps")
+               pstring = "caps";
+       if (!pstring.empty()) {
+               status.setEnabled(buffer().params().use_refstyle &&
+                       params().getCmdName() == "formatted");
+               bool const isSet = (getParam(pstring) == "true");
+               status.setOnOff(isSet);
+               return true;
+       }
+       if (arg == "toggle-noprefix") {
+               status.setEnabled(params().getCmdName() == "labelonly");
+               bool const isSet = (getParam("noprefix") == "true");
+               status.setOnOff(isSet);
+               return true;
+       }
+       // otherwise not for us
+       return InsetCommand::getStatus(cur, cmd, status);
+}
+
+
 namespace {
 
 void capitalize(docstring & s) {
index 066a596630b15f55399e015f96bdafd364780a7d..0f5a5b201d87983b5cd66d64dd3073240124a965 100644 (file)
@@ -40,6 +40,10 @@ public:
        /// \name Public functions inherited from Inset class
        //@{
        ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const;
+       ///
        bool isLabeled() const { return true; }
        ///
        docstring toolTip(BufferView const &, int, int) const
index 979bdb83002fa074641e908ce2844610e505c474..ff82428777129859b722a40478514c0847045199 100644 (file)
@@ -148,6 +148,9 @@ What's new
 
 - Avoid white space before math completion (bug 11283).
 
+- View and change Plural, Capitalization, and No Prefix options for 
+  cross-references from the context menu (bug 11070).
+
 
 * INTERNALS