]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Call an update before setting the_locking_inset = 0 as otherwise we
[lyx.git] / src / text2.C
index 64c45adcd4dba101a12f6494daff96fd2099a81f..08d31a00fb063ac8e2fcc967ba1cc0a73ded9a34 100644 (file)
@@ -500,14 +500,16 @@ Paragraph * LyXText::setLayout(BufferView * bview,
        // ok we have a selection. This is always between sstart_cur
        // and sel_end cursor
        cur = sstart_cur;
+       Paragraph * par = sstart_cur.par();
+       Paragraph * epar = send_cur.par()->next();
 
        LyXLayout const & lyxlayout =
                textclasslist[bview->buffer()->params.textclass][layout];
 
        do {
-               cur.par()->applyLayout(layout);
-               makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-               Paragraph * fppar = cur.par();
+               par->applyLayout(layout);
+               makeFontEntriesLayoutSpecific(bview->buffer(), par);
+               Paragraph * fppar = par;
                fppar->params().spaceTop(lyxlayout.fill_top ?
                                         VSpace(VSpace::VFILL)
                                         : VSpace(VSpace::NONE));
@@ -515,15 +517,15 @@ Paragraph * LyXText::setLayout(BufferView * bview,
                                            VSpace(VSpace::VFILL)
                                            : VSpace(VSpace::NONE));
                if (lyxlayout.margintype == MARGIN_MANUAL)
-                       cur.par()->setLabelWidthString(lyxlayout.labelstring());
+                       par->setLabelWidthString(lyxlayout.labelstring());
                if (lyxlayout.labeltype != LABEL_BIBLIO
                    && fppar->bibkey) {
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
                }
-               if (cur.par() != send_cur.par())
-                       cur.par(cur.par()->next());
-       } while (cur.par() != send_cur.par());
+               cur.par(par);
+               par = par->next();
+       } while (par != epar);
 
        return endpar;
 }
@@ -2319,17 +2321,21 @@ void LyXText::cursorRight(BufferView * bview, bool internal) const
 }
 
 
-void LyXText::cursorUp(BufferView * bview) const
+void LyXText::cursorUp(BufferView * bview, bool selecting) const
 {
 #if 1
        int x = cursor.x_fix();
        int y = cursor.y() - cursor.row()->baseline() - 1;
        setCursorFromCoordinates(bview, x, y);
-       int y1 = cursor.iy() - first_y;
-       int y2 = y1;
-       Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
-       if (inset_hit && isHighlyEditableInset(inset_hit)) {
-               inset_hit->edit(bview, x, y - (y2 - y1), 0);
+       if (!selecting) {
+               int y1 = cursor.iy() - first_y;
+               int y2 = y1;
+               y -= first_y;
+               Inset * inset_hit =
+                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               if (inset_hit && isHighlyEditableInset(inset_hit)) {
+                       inset_hit->edit(bview, x, y - (y2 - y1), 0);
+               }
        }
 #else
        setCursorFromCoordinates(bview, cursor.x_fix(),
@@ -2338,18 +2344,22 @@ void LyXText::cursorUp(BufferView * bview) const
 }
 
 
-void LyXText::cursorDown(BufferView * bview) const
+void LyXText::cursorDown(BufferView * bview, bool selecting) const
 {
 #if 1
        int x = cursor.x_fix();
        int y = cursor.y() - cursor.row()->baseline() +
                cursor.row()->height() + 1;
        setCursorFromCoordinates(bview, x, y);
-       int y1 = cursor.iy() - first_y;
-       int y2 = y1;
-       Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
-       if (inset_hit && isHighlyEditableInset(inset_hit)) {
-               inset_hit->edit(bview, x, y - (y2 - y1), 0);
+       if (!selecting && cursor.row() == cursor.irow()) {
+               int y1 = cursor.iy() - first_y;
+               int y2 = y1;
+               y -= first_y;
+               Inset * inset_hit =
+                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               if (inset_hit && isHighlyEditableInset(inset_hit)) {
+                       inset_hit->edit(bview, x, y - (y2 - y1), 0);
+               }
        }
 #else
        setCursorFromCoordinates(bview, cursor.x_fix(),