]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
bug 2298: cursorTop/Bottom/Home/End does not redraw after dEPM
[lyx.git] / src / text3.C
index e93a70b0080e453526ba87e30bc402ea43256c86..f34b24ab10557bd252a2c50804a54a987362078d 100644 (file)
@@ -158,16 +158,21 @@ namespace {
                        // create a macro if we see "\\newcommand"
                        // somewhere, and an ordinary formula
                        // otherwise
+                       istringstream is(sel);
                        if (sel.find("\\newcommand") == string::npos
                            && sel.find("\\def") == string::npos)
                        {
-                               cur.insert(new MathHullInset("simple"));
-                               cur.dispatch(FuncRequest(LFUN_RIGHT));
-                               cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
-                       } else {
-                               istringstream is(sel);
+                               MathHullInset * formula = new MathHullInset;
+                               LyXLex lex(0, 0);
+                               lex.setStream(is);
+                               formula->read(cur.buffer(), lex);
+                               if (formula->getType() == "none")
+                                       // Don't create pseudo formulas if
+                                       // delimiters are left out
+                                       formula->mutate("simple");
+                               cur.insert(formula);
+                       } else
                                cur.insert(new MathMacroTemplate(is));
-                       }
                }
                cur.message(N_("Math editor mode"));
        }
@@ -382,7 +387,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                if (cur.depth() == 1) {
                        if (!cur.mark())
                                cur.clearSelection();
-                       cursorTop(cur);
+                       needsUpdate = cursorTop(cur);
                        finishChange(cur, false);
                } else {
                        cur.undispatched();
@@ -393,7 +398,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                if (cur.depth() == 1) {
                        if (!cur.selection())
                                cur.resetAnchor();
-                       cursorTop(cur);
+                       needsUpdate = cursorTop(cur);
                        finishChange(cur, true);
                } else {
                        cur.undispatched();
@@ -404,7 +409,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                if (cur.depth() == 1) {
                        if (!cur.mark())
                                cur.clearSelection();
-                       cursorBottom(cur);
+                       needsUpdate = cursorBottom(cur);
                        finishChange(cur, false);
                } else {
                        cur.undispatched();
@@ -415,7 +420,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                if (cur.depth() == 1) {
                        if (!cur.selection())
                                cur.resetAnchor();
-                       cursorBottom(cur);
+                       needsUpdate = cursorBottom(cur);
                        finishChange(cur, true);
                } else {
                        cur.undispatched();
@@ -515,7 +520,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                update(cur);
                if (!cur.selection())
                        cur.resetAnchor();
-               cursorPrevious(cur);
+               needsUpdate = cursorPrevious(cur);
                finishChange(cur, true);
                break;
 
@@ -523,7 +528,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                update(cur);
                if (!cur.selection())
                        cur.resetAnchor();
-               cursorNext(cur);
+               needsUpdate = cursorNext(cur);
                finishChange(cur, true);
                break;
 
@@ -531,7 +536,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                update(cur);
                if (!cur.selection())
                        cur.resetAnchor();
-               cursorHome(cur);
+               needsUpdate = cursorHome(cur);
                finishChange(cur, true);
                break;
 
@@ -539,7 +544,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                update(cur);
                if (!cur.selection())
                        cur.resetAnchor();
-               cursorEnd(cur);
+               needsUpdate = cursorEnd(cur);
                finishChange(cur, true);
                break;
 
@@ -599,14 +604,14 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_HOME:
                if (!cur.mark())
                        cur.clearSelection();
-               cursorHome(cur);
+               needsUpdate = cursorHome(cur);
                finishChange(cur, false);
                break;
 
        case LFUN_END:
                if (!cur.mark())
                        cur.clearSelection();
-               cursorEnd(cur);
+               needsUpdate = cursorEnd(cur);
                finishChange(cur, false);
                break;
 
@@ -623,12 +628,16 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
 
        case LFUN_DELETE:
                if (!cur.selection()) {
+                       if (cur.pos() == cur.paragraph().size())
+                               // Par boundary, force full-screen update
+                               singleParUpdate = false;
                        needsUpdate = Delete(cur);
                        cur.resetAnchor();
                        // It is possible to make it a lot faster still
                        // just comment out the line below...
                } else {
                        cutSelection(cur, true, false);
+                       singleParUpdate = false;
                }
                moveCursor(cur, false);
                break;
@@ -651,6 +660,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_BACKSPACE:
                if (!cur.selection()) {
                        if (bv->owner()->getIntl().getTransManager().backspace()) {
+                               // Par boundary, full-screen update
+                               if (cur.pos() == 0)
+                                       singleParUpdate = false;
                                needsUpdate = backspace(cur);
                                cur.resetAnchor();
                                // It is possible to make it a lot faster still
@@ -658,6 +670,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                        }
                } else {
                        cutSelection(cur, true, false);
+                       singleParUpdate = false;
                }
                bv->switchKeyMap();
                break;
@@ -1527,10 +1540,14 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
 
        if (singleParUpdate)
                // Inserting characters does not change par height
-               if (cur.bottom().paragraph().dim().height() 
+               if (cur.bottom().paragraph().dim().height() 
                    == olddim.height()) {
                        // if so, update _only_ this paragraph
-                       cur.bv().update(Update::SinglePar | Update::Force);
+                       cur.bv().update(Update::SinglePar |
+                                       Update::FitCursor |
+                                       Update::MultiParSel);
+                       cur.noUpdate();
+                       return;
                } else
                        needsUpdate = true;
        if (!needsUpdate