]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Fix bug 9798.
[lyx.git] / src / Cursor.cpp
index b82da98ad85e303caf5e53d9c35057f4cd369ce9..92c9bdda2639161664d5b3d31efa6b85e851e1c1 100644 (file)
@@ -21,7 +21,6 @@
 #include "Cursor.h"
 #include "CutAndPaste.h"
 #include "DispatchResult.h"
-#include "Encoding.h"
 #include "Font.h"
 #include "FuncCode.h"
 #include "FuncRequest.h"
@@ -454,19 +453,6 @@ int Cursor::currentMode()
 }
 
 
-bool Cursor::inCoordCache() const
-{
-       // the root inset is not in cache, but we do not need it.
-       if (depth() == 1)
-               return true;
-       CoordCache::Insets const & icache = bv_->coordCache().getInsets();
-       for (size_t i = 1 ; i < depth() ; ++i)
-               if (!icache.has(&(*this)[i].inset()))
-                       return false;
-       return true;
-}
-
-
 void Cursor::getPos(int & x, int & y) const
 {
        Point p = bv().getPos(*this);
@@ -1414,7 +1400,7 @@ bool Cursor::down()
 }
 
 
-bool Cursor::macroModeClose()
+bool Cursor::macroModeClose(bool cancel)
 {
        if (!inMacroMode())
                return false;
@@ -1426,14 +1412,15 @@ bool Cursor::macroModeClose()
        --pos();
        cell().erase(pos());
 
-       // do nothing if the macro name is empty
-       if (s == "\\")
-               return false;
-
        // trigger updates of macros, at least, if no full
        // updates take place anyway
        screenUpdateFlags(Update::Force);
 
+       // do nothing if the macro name is empty
+       if (s == "\\" || cancel) {
+               return false;
+       }
+
        docstring const name = s.substr(1);
        InsetMathNest * const in = inset().asInsetMath()->asNestInset();
        if (in && in->interpretString(*this, s))
@@ -1464,9 +1451,10 @@ bool Cursor::macroModeClose()
 
        MathWordList const & words = mathedWordList();
        MathWordList::const_iterator it = words.find(name);
-       bool keep_mathmode = it != words.end() && (it->second.inset == "font"
-                                               || it->second.inset == "oldfont"
-                                               || it->second.inset == "mbox");
+       bool keep_mathmode = user_macro
+               || (it != words.end() && (it->second.inset == "font"
+                                         || it->second.inset == "oldfont"
+                                         || it->second.inset == "mbox"));
        bool ert_macro = !user_macro && it == words.end() && atomAsMacro;
 
        if (in && in->currentMode() == Inset::TEXT_MODE
@@ -2137,22 +2125,6 @@ docstring Cursor::getPossibleLabel() const
 }
 
 
-Encoding const * Cursor::getEncoding() const
-{
-       if (empty())
-               return 0;
-       BufferParams const & bp = bv().buffer().params();
-       if (bp.useNonTeXFonts)
-               return encodings.fromLyXName("utf8-plain");
-
-       CursorSlice const & sl = innerTextSlice();
-       Text const & text = *sl.text();
-       Font font = text.getPar(sl.pit()).getFont(bp, sl.pos(),
-                                                 text.outerFont(sl.pit()));
-       return font.language()->encoding();
-}
-
-
 void Cursor::undispatched() const
 {
        disp_.dispatched(false);