diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 2f593493da..5133148207 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -25,6 +25,7 @@ #include "math_parser.h" #include "math_scriptinset.h" #include "math_spaceinset.h" +#include "math_symbolinset.h" #include "math_support.h" #include "math_unknowninset.h" @@ -1006,6 +1007,9 @@ bool MathNestInset::interpret(LCursor & cur, char c) } else if (c == '{') { cur.backspace(); cur.niceInsert(MathAtom(new MathBraceInset)); + } else if (c == '%') { + cur.backspace(); + cur.niceInsert(MathAtom(new MathSymbolInset("%"))); } else if (c == '#') { lyxerr << "setting name to " << name + c << endl; BOOST_ASSERT(cur.activeMacro()); @@ -1088,15 +1092,15 @@ bool MathNestInset::interpret(LCursor & cur, char c) return true; } - if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#') { + if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || c == '%') { cur.niceInsert(createMathInset(string(1, c))); return true; } - if (c == '%') { - cur.niceInsert(MathAtom(new MathCommentInset)); - return true; - } + //if (c == '%') { + // cur.niceInsert(MathAtom(new MathCommentInset)); + // return true; + //} // try auto-correction //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c)) diff --git a/src/text2.C b/src/text2.C index dfcac666b5..8b8db5f61e 100644 --- a/src/text2.C +++ b/src/text2.C @@ -854,13 +854,13 @@ void LyXText::updateCounters() } +// this really should just inset the inset and not move the cursor. void LyXText::insertInset(LCursor & cur, InsetBase * inset) { BOOST_ASSERT(this == cur.text()); BOOST_ASSERT(inset); cur.paragraph().insertInset(cur.pos(), inset); redoParagraph(cur); - setCursor(cur, cur.par(), cur.pos() + 1, false, cur.boundary()); } diff --git a/src/text3.C b/src/text3.C index 53b37b8961..4a36c41392 100644 --- a/src/text3.C +++ b/src/text3.C @@ -137,7 +137,9 @@ namespace { lyxerr << "selection is: '" << sel << "'" << endl; if (sel.empty()) { + const int old_pos = cur.pos(); cur.insert(new MathHullInset); + 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 @@ -351,8 +353,10 @@ void doInsertInset(LCursor & cur, LyXText * text, gotsel = true; } text->insertInset(cur, inset); + if (edit) inset->edit(cur, true); + if (gotsel && pastesel) cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE)); } @@ -792,8 +796,10 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_INSET_INSERT: { recordUndo(cur); InsetBase * inset = createInset(bv, cmd); - if (inset) + if (inset) { insertInset(cur, inset); + cur.posRight(); + } break; } @@ -1031,8 +1037,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) cur.insert(new InsetQuotes(c, bufparams.quotes_language, InsetQuotes::DoubleQ)); - else + else cur.insert(new InsetQuotes(c, bufparams)); + cur.posRight(); } else bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\"")); @@ -1275,11 +1282,13 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // Open the inset, and move the current selection // inside it. doInsertInset(cur, this, cmd, true, true); + cur.posRight(); break; case LFUN_INDEX_INSERT: // Just open the inset doInsertInset(cur, this, cmd, true, false); + cur.posRight(); break; case LFUN_INDEX_PRINT: @@ -1289,6 +1298,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_INSERT_PAGEBREAK: // do nothing fancy doInsertInset(cur, this, cmd, false, false); + cur.posRight(); break; case LFUN_DEPTH_MIN: