]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
fix bug with relative paths in insetgraphics
[lyx.git] / src / text2.C
index f9d2a574d6fa65b3dc144d7cca2d1ea2ca3c0568..bab91e69280dadb45ba976238749aead0761c195 100644 (file)
@@ -909,7 +909,7 @@ bool LyXText::fullRebreak(BufferView * bview)
                need_break_row = 0;
                return true;
        }
-       return false;
+       return true;
 }
 
 
@@ -1647,13 +1647,12 @@ void LyXText::insertInset(BufferView * bview, Inset * inset)
 {
        if (!cursor.par()->insetAllowed(inset->lyxCode()))
                return;
-       // I don't know if this is necessary here (Jug 20020102)
-       setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next());
+       setUndo(bview, Undo::FINISH, cursor.par(), cursor.par()->next());
+       freezeUndo();
        cursor.par()->insertInset(cursor.pos(), inset);
        // Just to rebreak and refresh correctly.
        // The character will not be inserted a second time
        insertChar(bview, Paragraph::META_INSET);
-#if 1
        // If we enter a highly editable inset the cursor should be to before
        // the inset. This couldn't happen before as Undo was not handled inside
        // inset now after the Undo LyX tries to call inset->Edit(...) again
@@ -1662,7 +1661,7 @@ void LyXText::insertInset(BufferView * bview, Inset * inset)
        if (isHighlyEditableInset(inset)) {
                cursorLeft(bview, true);
        }
-#endif
+       unFreezeUndo();
 }
 
 
@@ -2061,20 +2060,24 @@ void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
        cur.pos(pos);
        cur.boundary(boundary);
 
-#if 0
-       if (pos && par->getChar(pos) == Paragraph::META_INSET &&
-               par->getInset(pos)) {
-               Inset * ins = par->getInset(pos);
-               if (ins->needFullRow() || ins->display()) {
-                       --pos;
-                       boundary = true;
-               }
-       }
-#endif
-
        // get the cursor y position in text
        int y = 0;
        Row * row = getRow(par, pos, y);
+       Row * old_row = row;
+       // if we are before the first char of this row and are still in the
+       // same paragraph and there is a previous row then put the cursor on
+       // the end of the previous row
+       cur.iy(y + row->baseline());
+       Inset * ins;
+       if (row->previous() && pos &&
+               par->getChar(pos) == Paragraph::META_INSET &&
+               (ins=par->getInset(pos)) && (ins->needFullRow() || ins->display()))
+       {
+               row = row->previous();
+               y -= row->height();
+       }
+
+       cur.row(row);
        // y is now the beginning of the cursor row
        y += row->baseline();
        // y is now the cursor baseline
@@ -2088,7 +2091,7 @@ void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
        prepareToPrint(bview, row, x, fill_separator, fill_hfill,
                       fill_label_hfill);
        pos_type cursor_vpos = 0;
-       pos_type last = rowLastPrintable(row);
+       pos_type last = rowLastPrintable(old_row);
 
        if (pos > last + 1) {
                // This shouldn't happen.
@@ -2149,7 +2152,6 @@ void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
 
        cur.x(int(x));
        cur.x_fix(cur.x());
-       cur.row(row);
 }
 
 
@@ -2247,6 +2249,16 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur,
        cur.pos(row->pos() + column);
        cur.x(x);
        cur.y(y + row->baseline());
+       Inset * ins;
+       if (row->next() && cur.pos() &&
+               cur.par()->getChar(cur.pos()) == Paragraph::META_INSET &&
+               (ins=cur.par()->getInset(cur.pos())) &&
+               (ins->needFullRow() || ins->display()))
+       {
+               cur.iy(y + row->height() + row->next()->baseline());
+       } else {
+               cur.iy(cur.y());
+       }
        cur.row(row);
        cur.boundary(bound);
 }