Cursor::Cursor(BufferView & bv)
: CursorData(&bv.buffer()), bv_(&bv),
x_target_(-1), textTargetOffset_(0),
+ x_clickpos_(-1), y_clickpos_(-1),
beforeDispatchPosX_(0), beforeDispatchPosY_(0)
{}
beginUndoGroup();
+ Inset * nextins = nextInset();
// Is this a function that acts on inset at point?
- if (lyxaction.funcHasFlag(cmd.action(), LyXAction::AtPoint)
- && nextInset()) {
+ if (lyxaction.funcHasFlag(cmd.action(), LyXAction::AtPoint) && nextins) {
disp_.dispatched(true);
disp_.screenUpdate(Update::FitCursor | Update::Force);
FuncRequest tmpcmd = cmd;
- LYXERR(Debug::DEBUG, "Cursor::dispatch: (AtPoint) cmd: "
+ LYXERR(Debug::ACTION, "Cursor::dispatch: (AtPoint) cmd: "
<< cmd0 << endl << *this);
- nextInset()->dispatch(*this, tmpcmd);
+ nextins->dispatch(*this, tmpcmd);
if (disp_.dispatched()) {
endUndoGroup();
return;
// store some values to be used inside of the handlers
beforeDispatchCursor_ = *this;
for (; depth(); pop(), boundary(false)) {
- LYXERR(Debug::DEBUG, "Cursor::dispatch: cmd: "
+ LYXERR(Debug::ACTION, "Cursor::dispatch: cmd: "
<< cmd0 << endl << *this);
// In any of these cases, the cursor is invalid, and we should
// it completely to get a 'bomb early' behaviour in case this
// object will be used again.
if (!disp_.dispatched()) {
- LYXERR(Debug::DEBUG, "RESTORING OLD CURSOR!");
+ LYXERR(Debug::ACTION, "RESTORING OLD CURSOR!");
// We might have invalidated the cursor when removing an empty
// paragraph while the cursor could not be moved out the inset
// while we initially thought we could. This might happen when
void Cursor::push(Inset & inset)
{
push_back(CursorSlice(inset));
- inset.setBuffer(*buffer());
+ // See bug #13050
+ // inset.setBuffer(*buffer());
}
}
+void Cursor::setClickPos(int x, int y)
+{
+ x_clickpos_ = x;
+ y_clickpos_ = y;
+}
+
+
bool Cursor::selHandle(bool selecting)
{
//lyxerr << "Cursor::selHandle" << endl;
LASSERT(!empty(), return);
if (inMathed()) {
cap::selClearOrDel(*this);
- insert(new InsetMathChar(c));
+ insert(new InsetMathChar(buffer(), c));
} else {
text()->insertChar(*this, c);
}
docstring const name = t->asMacro()->name();
MacroData const * data = buffer()->getMacro(name);
if (data && data->numargs() - data->optionals() > 0) {
- plainInsert(MathAtom(new InsetMathBrace(ar)));
+ plainInsert(MathAtom(new InsetMathBrace(buffer(), ar)));
posBackward();
}
}
bool keep_mathmode = user_macro
|| (it != words.end() && (it->second.inset == "font"
|| it->second.inset == "oldfont"
+ || it->second.inset == "textsize"
|| it->second.inset == "mbox"));
bool ert_macro = !user_macro && it == words.end() && atomAsMacro;
// finally put the macro argument behind, if needed
if (macroArg) {
if (selection.size() > 1 || selection[0]->asScriptInset())
- plainInsert(MathAtom(new InsetMathBrace(selection)));
+ plainInsert(MathAtom(new InsetMathBrace(buffer(), selection)));
else
insert(selection);
}
plainErase();
cell().insert(pos(), ar);
resetAnchor();
- } else {
- //formula()->mutateToText();
}
}
// try to find best position within this inset
if (!selection())
setCursor(bruteFind(*this, xo, yo));
+ // FIXME : this is actually only needed for InsetMathMacro (bug #12952).
+ screenUpdateFlags(Update::SinglePar);
return true;
}
}
-bool Cursor::upDownInText(bool up, bool & updateNeeded)
+bool Cursor::upDownInText(bool up)
{
LASSERT(text(), return false);
getPos(xo, yo);
xo = beforeDispatchPosX_;
+ // Is a full repaint necessary?
+ bool updateNeeded = false;
+
// update the targetX - this is here before the "return false"
// to set a new target which can be used by InsetTexts above
// if we cannot move up/down inside this inset anymore
dummy.pos() = dummy.pos() == 0 ? dummy.lastpos() : 0;
dummy.pit() = dummy.pit() == 0 ? dummy.lastpit() : 0;
- updateNeeded |= bv().checkDepm(dummy, *this);
- updateTextTargetOffset();
- if (updateNeeded)
+ if (bv().checkDepm(dummy, *this)) {
+ updateNeeded = true;
forceBufferUpdate();
+ }
+ updateTextTargetOffset();
}
- return false;
+ return updateNeeded;
}
// with and without selection are handled differently
++dummy.pos();
if (bv().checkDepm(dummy, old)) {
updateNeeded = true;
+ forceBufferUpdate();
// Make sure that cur gets back whatever happened to dummy (Lgb)
operator=(dummy);
}
// When selection==false, this is done by TextMetrics::editXY
setCurrentFont();
- updateNeeded |= bv().checkDepm(*this, old);
+ if (bv().checkDepm(*this, old)) {
+ updateNeeded = true;
+ forceBufferUpdate();
+ }
}
- if (updateNeeded)
- forceBufferUpdate();
updateTextTargetOffset();
- return true;
+ return updateNeeded;
}