]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.C
try to correct x position where curosr drops of inset.
[lyx.git] / src / mathed / math_cursor.C
index df7444f328c9ce9072bc6b2df674698ccfe4239b..6a371a2a9b121baa0c54a7a1e87c38fa037328db 100644 (file)
@@ -670,12 +670,22 @@ void MathCursor::handleNest(MathAtom const & a)
 }
 
 
-void MathCursor::getPos(int & x, int & y)
+void MathCursor::getPos(int & x, int & y) const
 {
        par()->getPos(idx(), pos(), x, y);
 }
 
 
+int MathCursor::targetX() const
+{
+       if (targetx_ != -1)
+               return targetx_;
+       int x = 0, y = 0;
+       getPos(x, y);
+       return x;
+}
+
+
 MathInset * MathCursor::par() const
 {
        return cursor().par_;
@@ -1159,7 +1169,7 @@ bool MathCursor::script(bool up)
        // Hack to get \\^ and \\_ working
        if (inMacroMode() && macroName() == "\\") {
                if (up)
-                       interpret("\\mathcircumflex");
+                       niceInsert(createMathInset("mathcircumflex"));
                else
                        interpret('_');
                return true;
@@ -1219,12 +1229,6 @@ bool MathCursor::interpret(char c)
                string name = macroName();
                //lyxerr << "interpret name: '" << name << "'\n";
 
-               if (name.empty() && c == '\\') {
-                       backspace();
-                       interpret("\\backslash");
-                       return true;
-               }
-
                if (isalpha(c)) {
                        activeMacro()->setName(activeMacro()->name() + c);
                        return true;
@@ -1234,10 +1238,13 @@ bool MathCursor::interpret(char c)
                if (name == "\\") {
                        // remove the '\\'
                        backspace();
-                       if (c == '\\')
-                               interpret("\\backslash");
-                       else
-                               interpret(string("\\") + c);
+                       if (c == '\\') {
+                               if (currentMode() == MathInset::TEXT_MODE)
+                                       niceInsert(createMathInset("textbackslash"));
+                               else
+                                       niceInsert(createMathInset("backslash"));
+                       } else
+                               niceInsert(createMathInset(string(1, c)));
                        return true;
                }