#include "MathCompletionList.h"
#include "MathData.h"
#include "MathFactory.h"
-#include "MathMacro.h"
-#include "MathMacroArgument.h"
+#include "InsetMathMacro.h"
+#include "InsetMathMacroArgument.h"
#include "MathParser.h"
#include "MathStream.h"
#include "MathSupport.h"
case LFUN_MOUSE_DOUBLE:
case LFUN_WORD_SELECT:
cur.pos() = 0;
- cur.resetAnchor();
- cur.selection(true);
+ cur.bv().mouseSetCursor(cur);
cur.pos() = cur.lastpos();
- cur.bv().cursor() = cur;
+ cur.bv().mouseSetCursor(cur, true);
break;
case LFUN_MOUSE_TRIPLE:
cur.idx() = 0;
cur.pos() = 0;
- cur.resetAnchor();
- cur.selection(true);
+ cur.bv().mouseSetCursor(cur);
cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
- cur.bv().cursor() = cur;
+ cur.bv().mouseSetCursor(cur, true);
break;
case LFUN_LINE_BEGIN:
cur.recordUndoSelection();
// if the inset can not be removed from within, delete it
if (!cur.backspace(cmd.getArg(0) == "force")) {
- FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
- cur.innerText()->dispatch(cur, cmd);
+ FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
+ cur.innerText()->dispatch(cur, newcmd);
}
break;
cur.recordUndoSelection();
// if the inset can not be removed from within, delete it
if (!cur.erase(cmd.getArg(0) == "force")) {
- FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
- cur.innerText()->dispatch(cur, cmd);
+ FuncRequest newcmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD, "force");
+ cur.innerText()->dispatch(cur, newcmd);
}
break;
if (cur.selection())
cur.clearSelection();
else {
- cmd = FuncRequest(LFUN_FINISHED_FORWARD);
- cur.undispatched();
+ if (cur.inMacroMode())
+ cur.macroModeClose(true);
+ else {
+ cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+ cur.undispatched();
+ }
}
break;
int y = 0;
istringstream is(to_utf8(cmd.argument()));
is >> x >> y;
- cur.setScreenPos(x, y);
+ cur.setTargetX(x);
break;
}
bool fold = act == LFUN_MATH_MACRO_FOLD;
bool found = findMacroToFoldUnfold(it, fold);
if (found) {
- MathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
+ InsetMathMacro * macro = it.nextInset()->asInsetMath()->asMacro();
cur.recordUndoInset();
if (fold)
macro->fold(cur);
// go backward through the current cell
Inset * inset = it.nextInset();
while (inset && inset->asInsetMath()) {
- MathMacro * macro = inset->asInsetMath()->asMacro();
+ InsetMathMacro * macro = inset->asInsetMath()->asMacro();
if (macro) {
// found the an macro to open/close?
if (macro->folded() != fold)
Inset * InsetMathNest::editXY(Cursor & cur, int x, int y)
{
- int idx_min = 0;
+ int idx_min = -1;
int dist_min = 1000000;
for (idx_type i = 0, n = nargs(); i != n; ++i) {
int const d = cell(i).dist(cur.bv(), x, y);
idx_min = i;
}
}
+ if (idx_min == -1)
+ return this;
+
MathData & ar = cell(idx_min);
cur.push(*this);
cur.idx() = idx_min;
cur.backspace();
int n = c - '0';
if (n >= 1 && n <= 9)
- cur.insert(new MathMacroArgument(n));
+ cur.insert(new InsetMathMacroArgument(n));
return true;
}
#if 0
// FIXME: this creates duplicates in the completion popup
// which looks ugly. Moreover the changes the list lengths
- // which seems to
- confuse the popup as well.
+ // which seems to confuse the popup as well.
MathCompletionList::addToFavorites(inset->name());
#endif
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, " "));