]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
Make autocorrect (still disabled) better. Now switched
[lyx.git] / src / mathed / InsetMathNest.cpp
index ef2d659d8d355b2f00bdd2a0de8884ec2091b37c..efd473ba04bdc8850a92a4daa3928e232674fa29 100644 (file)
@@ -633,7 +633,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                // Now that we know exactly what we want to do, let's do it!
                cur.selHandle(select);
-               cur.autocorrect() = false;
                cur.clearTargetX();
                cur.macroModeClose();
                // try moving forward or backwards as necessary...
@@ -840,7 +839,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        //case LFUN_SERVER_GET_XY:
-       //      sprintf(dispatch_buffer, "%d %d",);
        //      break;
 
        case LFUN_SERVER_SET_XY: {
@@ -1055,15 +1053,18 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_SPACE_INSERT:
                cur.recordUndoSelection();
-               cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
+               cur.insert(MathAtom(new InsetMathSpace));
                break;
 
        case LFUN_MATH_SPACE:
                cur.recordUndoSelection();
                if (cmd.argument().empty())
-                       cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
-               else
-                       cur.insert(MathAtom(new InsetMathSpace(cmd.argument())));
+                       cur.insert(MathAtom(new InsetMathSpace));
+               else {
+                       string const name = cmd.getArg(0);
+                       string const len = cmd.getArg(1);
+                       cur.insert(MathAtom(new InsetMathSpace(name, len)));
+               }
                break;
 
        case LFUN_ERT_INSERT:
@@ -1131,6 +1132,9 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (name == "ref") {
                        InsetMathRef tmp(name);
                        data = tmp.createDialogStr(to_utf8(name));
+               } else if (name == "mathspace") {
+                       InsetMathSpace tmp;
+                       data = tmp.createDialogStr();
                }
                cur.bv().showDialog(to_utf8(name), data);
                break;
@@ -1274,7 +1278,7 @@ bool InsetMathNest::getStatus(Cursor & cur, FuncRequest const & cmd,
                // getStatus is not called with a valid reference and the
                // dialog would not be applyable.
                string const name = cmd.getArg(0);
-               flag.setEnabled(name == "ref");
+               flag.setEnabled(name == "ref" || name == "mathspace");
                break;
        }
 
@@ -1520,8 +1524,14 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
 
 #ifdef AUTOCORRECT
                // leave autocorrect mode if necessary
-               if (cur.autocorrect() && c == ' ') {
+               if (c == ' ' && cur.autocorrect()) {
                        cur.autocorrect() = false;
+                       cur.message(_("Autocorrect Off ('!' to enter)"));
+                       return true;
+               } 
+               if (c == '!' && !cur.autocorrect()) {
+                       cur.autocorrect() = true;
+                       cur.message(_("Autocorrect On (<space> to exit)"));
                        return true;
                }
 #endif
@@ -1629,7 +1639,12 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
 
        // no special circumstances, so insert the character without any fuss
        cur.insert(c);
-       cur.autocorrect() = true;
+#ifdef AUTOCORRECT
+       if (!cur.autocorrect())
+               cur.message(_("Autocorrect Off ('!' to enter)"));
+       else
+               cur.message(_("Autocorrect On (<space> to exit)"));
+#endif
        return true;
 }