]> git.lyx.org Git - features.git/commitdiff
don't crash on C-m
authorAndré Pönitz <poenitz@gmx.net>
Thu, 12 Aug 2004 19:49:25 +0000 (19:49 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 12 Aug 2004 19:49:25 +0000 (19:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8884 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_nestinset.C
src/text2.C
src/text3.C

index 2f593493da8f272f5cbdd9611d253444ab5910ab..5133148207d0ae9f0b20190849cc50b61437ce46 100644 (file)
@@ -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))
index dfcac666b53251c1211cc756922b678a3495d191..8b8db5f61ecaa5ac0f28df41f8b23f9725cfe9d6 100644 (file)
@@ -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());
 }
 
 
index 53b37b8961f7cc190108d98c514c447990785d73..4a36c41392de4c570bfb55a7c9ceb768d8ae3f66 100644 (file)
@@ -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: