On 02/02/2012 08:39 AM, lasgout...@lyx.org wrote:
Author: lasgouttes
Date: Thu Feb  2 14:39:05 2012
New Revision: 40700
URL: http://www.lyx.org/trac/changeset/40700

Log:
* InsetMathScript::doDispatch : properly record undo information before
changing limits status (fixes bug #8007)
* InsetMathScript::getStatus (new) : handle properly status for 
LFUN_MATH_LIMITS here, along with checkmark support for the menu)
Looks fine for branch, I'd say. If you feel comfortable with it, please go ahead.

Richard

Modified:
    lyx-devel/trunk/src/mathed/InsetMathNest.cpp
    lyx-devel/trunk/src/mathed/InsetMathScript.cpp
    lyx-devel/trunk/src/mathed/InsetMathScript.h

Modified: lyx-devel/trunk/src/mathed/InsetMathNest.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathNest.cpp        Thu Feb  2 01:25:13 
2012        (r40699)
+++ lyx-devel/trunk/src/mathed/InsetMathNest.cpp        Thu Feb  2 14:39:05 
2012        (r40700)
@@ -1368,7 +1368,6 @@
        // we just need to be in math mode to enable that
        case LFUN_MATH_SIZE:
        case LFUN_MATH_SPACE:
-       case LFUN_MATH_LIMITS:
        case LFUN_MATH_EXTERN:
                flag.setEnabled(true);
                break;

Modified: lyx-devel/trunk/src/mathed/InsetMathScript.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathScript.cpp      Thu Feb  2 01:25:13 
2012        (r40699)
+++ lyx-devel/trunk/src/mathed/InsetMathScript.cpp      Thu Feb  2 14:39:05 
2012        (r40700)
@@ -14,6 +14,7 @@
  #include "Cursor.h"
  #include "DispatchResult.h"
  #include "FuncRequest.h"
+#include "FuncStatus.h"
  #include "InsetMathFont.h"
  #include "InsetMathScript.h"
  #include "InsetMathSymbol.h"
@@ -754,6 +755,7 @@
        //LYXERR("InsetMathScript: request: "<<  cmd);

        if (cmd.action() == LFUN_MATH_LIMITS) {
+               cur.recordUndoInset();
                if (!cmd.argument().empty()) {
                        if (cmd.argument() == "limits")
                                limits_ = 1;
@@ -772,6 +774,26 @@
  }


+bool InsetMathScript::getStatus(Cursor&  cur, FuncRequest const&  cmd,
+                               FuncStatus&  flag) const
+{
+       if (cmd.action() == LFUN_MATH_LIMITS) {
+               if (!cmd.argument().empty()) {
+                       if (cmd.argument() == "limits")
+                               flag.setOnOff(limits_ == 1);
+                       else if (cmd.argument() == "nolimits")
+                               flag.setOnOff(limits_ == -1);
+                       else
+                               flag.setOnOff(limits_ == 0);
+               }
+               flag.setEnabled(true);
+               return true;
+       }
+
+       return InsetMathNest::getStatus(cur, cmd, flag);
+}
+
+
  // the idea for dual scripts came from the eLyXer code
  void InsetMathScript::validate(LaTeXFeatures&  features) const
  {

Modified: lyx-devel/trunk/src/mathed/InsetMathScript.h
==============================================================================
--- lyx-devel/trunk/src/mathed/InsetMathScript.h        Thu Feb  2 01:25:13 
2012        (r40699)
+++ lyx-devel/trunk/src/mathed/InsetMathScript.h        Thu Feb  2 14:39:05 
2012        (r40700)
@@ -110,6 +110,9 @@
        void validate(LaTeXFeatures&features) const;
  protected:
        virtual void doDispatch(Cursor&  cur, FuncRequest&  cmd);
+       /// do we want to handle this event?
+       bool getStatus(Cursor&  cur, FuncRequest const&  cmd,
+               FuncStatus&  status) const;
  private:
        virtual Inset * clone() const;
        /// returns x offset for main part

Reply via email to