]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_hullinset.C
Fix math cursor positioning bug
[lyx.git] / src / mathed / math_hullinset.C
index 64ac084e3d9002081fa818707cc93011dfc0f55d..092b15decdc6b9b05577072876d7bfab41b37497 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "BufferView.h"
 #include "CutAndPaste.h"
+#include "FuncStatus.h"
 #include "LColor.h"
 #include "LaTeXFeatures.h"
 #include "cursor.h"
@@ -48,6 +49,7 @@
 #include <sstream>
 
 using lyx::cap::grabAndEraseSelection;
+using lyx::support::bformat;
 using lyx::support::subst;
 
 using std::endl;
@@ -1094,6 +1096,7 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
        case LFUN_MATH_MUTATE:
        case LFUN_MATH_DISPLAY:
                // we handle these
+               flag.enabled(true);
                return true;
        case LFUN_TABULAR_FEATURE: {
                istringstream is(cmd.argument);
@@ -1102,19 +1105,40 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
                if (!rowChangeOK()
                    && (s == "append-row"
                        || s == "delete-row"
-                       || s == "copy-row"))
-                       return false;
-               if (nrows() <= 1
-                   && (s == "delete-row" || s == "swap-row"))
-                       return false;
+                       || s == "copy-row")) {
+                       flag.message(bformat(
+                               N_("Can't change number of rows in '%1$s'"),
+                               type_));
+                       flag.enabled(false);
+                       return true;
+               }
                if (!colChangeOK()
                    && (s == "append-column"
                        || s == "delete-column"
-                       || s == "copy-column"))
-                       return false;
-               if (ncols() <= 1
-                   && (s == "delete-column" || s == "swap-column"))
-                       return false;
+                       || s == "copy-column")) {
+                       flag.message(bformat(
+                               N_("Can't change number of columns in '%1$s'"),
+                               type_));
+                       flag.enabled(false);
+                       return true;
+               }
+               if ((type_ == "simple" 
+                 || type_ == "equation" 
+                 || type_ == "none") &&
+                   (s == "add-hline-above" || s == "add-hline-below")) {
+                       flag.message(bformat(
+                               N_("Can't add horizontal grid lines in '%1$s'"),
+                               type_));
+                       flag.enabled(false);
+                       return true;
+               }
+               if (s == "add-vline-left" || s == "add-vline-right") { 
+                       flag.message(bformat(
+                               N_("Can't add vertical grid lines in '%1$s'"),
+                               type_));
+                       flag.enabled(false);
+                       return true;
+               }
                return MathGridInset::getStatus(cur, cmd, flag);
        }
        default: