InsetFormulaBase::InsetFormulaBase()
- : xo_(0), yo_(0)
{
// This is needed as long the math parser is not re-entrant
initMath();
void InsetFormulaBase::insetUnlock(BufferView * bv)
{
if (mathcursor) {
- if (mathcursor->inMacroMode()) {
+ if (mathcursor->inMacroMode())
mathcursor->macroModeClose();
- bv->updateInset(this);
- }
releaseMathCursor(bv);
}
if (bv->buffer())
generatePreview(*bv->buffer());
- bv->updateInset(this);
+ bv->update();
}
}
-void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
+void InsetFormulaBase::getCursorPos(int, int & x, int & y) const
{
- // calling metrics here destroys the cached xo,yo positions e.g. in
- // MathParboxinset. And it would be too expensive anyway...
- //metrics(bv);
if (!mathcursor) {
lyxerr << "getCursorPos - should not happen";
- x = y = 0;
+ x = 0;
+ y = 0;
return;
}
mathcursor->getPos(x, y);
}
-void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
+void InsetFormulaBase::getCursorDim(int & asc, int & desc) const
{
if (!mathcursor)
return;
- int x, y, asc, des;
asc = 10;
- des = 2;
+ desc = 2;
//math_font_max_dim(font_, asc, des);
- getCursorPos(bv, x, y);
- //y += yo_;
- //lyxerr << "fitInsetCursor: x: " << x << " y: " << y << " yo: " << yo_ << endl;
- bv->fitLockedInsetCursor(x, y, asc, des);
}
void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
{
if (mathcursor)
- bv->updateInset(this);
+ bv->update();
}
return DispatchResult(false);
BufferView * bv = cmd.view();
- bv->updateInset(this);
+ bv->update();
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button3) {
mathcursor->selClear();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
mathcursor->insert(ar);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
return DispatchResult(true, true);
}
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
BufferView * bv = cmd.view();
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
- bv->updateInset(this);
+ bv->update();
return DispatchResult(true, true);
}
lyxerr << "Called FormulaBase::edit" << endl;
releaseMathCursor(bv);
mathcursor = new MathCursor(this, left);
- bv->cursor().push(this);
+ bv->fullCursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
- bv->updateInset(this);
+ bv->update();
}
mathcursor = new MathCursor(this, true);
//metrics(bv);
mathcursor->setPos(x + xo_, y + yo_);
- bv->cursor().push(this);
+ bv->fullCursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
- bv->updateInset(this);
+ bv->update();
}
case LFUN_RIGHTSEL:
sel = true; // fall through...
case LFUN_RIGHT:
- result = mathcursor->right(sel) ? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
+ result = mathcursor->right(sel) ?
+ DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
//lyxerr << "calling scroll 20" << endl;
//scroll(bv, 20);
// write something to the minibuffer
case LFUN_LEFTSEL:
sel = true; // fall through
case LFUN_LEFT:
- result = mathcursor->left(sel) ? DispatchResult(true, true) : DispatchResult(true, FINISHED);
+ result = mathcursor->left(sel) ?
+ DispatchResult(true, true) : DispatchResult(false, FINISHED);
break;
case LFUN_UPSEL:
sel = true; // fall through
case LFUN_UP:
- result = mathcursor->up(sel) ? DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
+ result = mathcursor->up(sel) ?
+ DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
break;
case LFUN_DOWNSEL:
sel = true; // fall through
case LFUN_DOWN:
- result = mathcursor->down(sel) ? DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
+ result = mathcursor->down(sel) ?
+ DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
break;
case LFUN_WORDSEL:
break;
}
- case LFUN_SUPERSCRIPT:
- case LFUN_SUBSCRIPT:
- {
- recordUndo(bv, Undo::ATOMIC);
- mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
- break;
- }
-
- case LFUN_MATH_DELIM:
- {
+ case LFUN_MATH_DELIM: {
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'" << endl;
string ls;
string rs = split(cmd.argument, ls, ' ');
result = DispatchResult(false);
else
bv->owner()->getDialogs().show(name, data, 0);
+ break;
}
- break;
case LFUN_INSET_APPLY: {
string const name = cmd.getArg(0);
result = DispatchResult(false);
}
}
+ break;
+ }
+
+ case LFUN_WORD_REPLACE:
+ case LFUN_WORD_FIND: {
+ result =
+ searchForward(cmd.view(), cmd.getArg(0), false, false)
+ ? DispatchResult(true, true) : DispatchResult(false);
+ break;
}
- break;
default:
result = DispatchResult(false);
}
if (result == DispatchResult(true, true))
- bv->updateInset(this);
+ bv->update();
mathcursor->normalize();
mathcursor->touch();
toggleInsetSelection(bv);
if (result.dispatched()) {
- fitInsetCursor(bv);
revealCodes(bv);
cmd.view()->stuffClipboard(mathcursor->grabSelection());
} else {
#warning pretty ugly
#endif
static InsetFormulaBase * lastformula = 0;
- static MathIterator current = MathIterator(ibegin(par().nucleus()));
+ static CursorBase current = CursorBase(ibegin(par().nucleus()));
static MathArray ar;
static string laststr;
ar.clear();
mathed_parse_cell(ar, str);
} else {
- ++current;
+ increment(current);
}
//lyxerr << "searching '" << str << "' in " << this << ar << endl;
- for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
- if (it.cell().matchpart(ar, it.back().pos_)) {
+ for (CursorBase it = current; it != iend(par().nucleus()); increment(it)) {
+ CursorSlice & top = it.back();
+ MathArray const & a = top.asMathInset()->cell(top.idx_);
+ if (a.matchpart(ar, top.pos_)) {
delete mathcursor;
mathcursor = new MathCursor(this, true);
//metrics(bv);
mathcursor->setSelection(it, ar.size());
current = it;
- it.jump(ar.size());
- bv->updateInset(this);
+ top.pos_ += ar.size();
+ bv->update();
return true;
}
}
if (sel.empty()) {
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
- bv->cursor().innerInset()->
+ bv->fullCursor().innerInset()->
dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset
case LFUN_MATH_DELIM: {
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
- UpdatableInset * inset = bv->cursor().innerInset();
+ UpdatableInset * inset = bv->fullCursor().innerInset();
inset->dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
inset->dispatch(cmd);
}