#include "Cursor.h"
#include "CutAndPaste.h"
#include "DispatchResult.h"
-#include "Encoding.h"
#include "Font.h"
#include "FuncCode.h"
#include "FuncRequest.h"
}
-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);
}
-bool Cursor::macroModeClose()
+bool Cursor::macroModeClose(bool cancel)
{
if (!inMacroMode())
return false;
--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))
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
}
-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);