if (sel.empty()) {
const int old_pos = cur.pos();
- cur.insert(new MathHullInset);
+ cur.insert(new MathHullInset("simple"));
BOOST_ASSERT(old_pos == cur.pos());
cur.nextInset()->edit(cur, true);
- cur.dispatch(FuncRequest(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 --
// I really hate "LyXfunc overloading"...
if (display)
cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
- cur.dispatch(FuncRequest(LFUN_INSERT_MATH, cmd.argument));
+ // Avoid an unnecessary undo step if cmd.argument
+ // is empty
+ if (!cmd.argument.empty())
+ cur.dispatch(FuncRequest(LFUN_INSERT_MATH,
+ cmd.argument));
} else {
// create a macro if we see "\\newcommand"
// somewhere, and an ordinary formula
if (sel.find("\\newcommand") == string::npos
&& sel.find("\\def") == string::npos)
{
- cur.insert(new MathHullInset);
+ cur.insert(new MathHullInset("simple"));
cur.dispatch(FuncRequest(LFUN_RIGHT));
- cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
} else {
istringstream is(sel);
int x = cur.x_target();
- setCursorFromCoordinates(cur, x, 0);
- bool updated = cursorUp(cur);
+ bool updated = setCursorFromCoordinates(cur, x, 0);
+ if (updated)
+ cur.bv().update();
+ updated |= cursorUp(cur);
if (cpar == cur.pit() && cpos == cur.pos()) {
// we have a row which is taller than the workarea. The
lyx::pit_type cpar = cur.pit();
int x = cur.x_target();
- setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
- bool updated = cursorDown(cur);
+ bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
+ if (updated)
+ cur.bv().update();
+ updated |= cursorDown(cur);
if (cpar == cur.pit() && cpos == cur.pos()) {
// we have a row which is taller than the workarea. The
CursorSlice oldTopSlice = cur.top();
bool oldBoundary = cur.boundary();
bool sel = cur.selection();
- bool needsUpdate = !lyxaction.funcHasFlag(cmd.action, LyXAction::NoUpdate);
+ // Signals that, even if needsUpdate == false, an update of the
+ // cursor paragraph is required
+ bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
+ LyXAction::SingleParUpdate);
+ // Signals that a full-screen update is required
+ bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
+ LyXAction::NoUpdate) || singleParUpdate);
+ // Remember the old paragraph metric
+ Dimension olddim = cur.paragraph().dim();
switch (cmd.action) {
cur.insert(new InsetQuotes(c,
bufparams.quotes_language,
InsetQuotes::SingleQ));
- else if (arg == "double")
+ else
cur.insert(new InsetQuotes(c,
bufparams.quotes_language,
InsetQuotes::DoubleQ));
- else
- cur.insert(new InsetQuotes(c, bufparams));
cur.posRight();
}
else
cur.resetAnchor();
moveCursor(cur, false);
-
- needsUpdate = redoParagraph(cur.pit());
- if (!needsUpdate) {
- // update only this paragraph
- cur.bv().update(Update::SinglePar | Update::Force);
- }
-
bv->updateScrollbar();
break;
}
int const nargs = s1.empty() ? 0 : convert<int>(s1);
string const s2 = token(s, ' ', 2);
string const type = s2.empty() ? "newcommand" : s2;
- cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, s2));
+ cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
//cur.nextInset()->edit(cur, true);
}
break;
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM: {
- cur.insert(new MathHullInset);
+ cur.insert(new MathHullInset("simple"));
cur.dispatch(FuncRequest(LFUN_RIGHT));
- cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
cur.dispatch(cmd);
break;
}
cur.selection() = false;
} else {
cur.undispatched();
- cmd = FuncRequest(LFUN_FINISHED_LEFT);
+ cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
break;
break;
}
+ if (singleParUpdate)
+ // Inserting characters does not change par height
+ if (cur.paragraph().dim().asc == olddim.asc
+ && cur.paragraph().dim().des == olddim.des) {
+ // if so, update _only_ this paragraph
+ cur.bv().update(Update::SinglePar | Update::Force);
+ } else
+ needsUpdate = true;
if (!needsUpdate
&& &oldTopSlice.inset() == &cur.inset()
&& oldTopSlice.idx() == cur.idx()