]> git.lyx.org Git - features.git/commitdiff
fix the row breaking. Sorry all !
authorJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 01:46:40 +0000 (01:46 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 01:46:40 +0000 (01:46 +0000)
Anyway, this *should* have one bug less, and be understandable.

Guess if my opinion on the "cleverness" of inset-as-metachar has changed
(hint: I wasn't a fan)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6408 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C

index 5f4f6511e4277914143f0281e38fbb743aec86b3..e85f2081d7d6ca45247b54c920c54f9340ee1806 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-10  John Levon  <levon@movementarian.org>
+
+       * text.C: fix the last commit
+
 2003-03-09  John Levon  <levon@movementarian.org>
 
        * lyxtext.h:
index 8a154ed7825a9210260d331d739b6484aec26fe9..1c117d7051ca9bfe807d806e66542fa21343c68d 100644 (file)
@@ -741,7 +741,7 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
                x += singleWidth(&bv, par, i, c);
 
                // add the auto-hfill from label end to the body
-               if (i == body_pos) {
+               if (body_pos && i == body_pos) {
                        x += font_metrics::width(layout->labelsep,
                                    getLabelFont(bv.buffer(), par));
                        if (par->isLineSeparator(i - 1))
@@ -751,11 +751,22 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
                                x = left_margin;
                }
 
+               Inset * in = par->isInset(i) ? par->getInset(i) : 0;
+               bool display = (in && (in->display() || in->needFullRow()));
+
+               // check whether a Display() inset is valid here.
+               // If not, change it to non-display. FIXME:
+               // we should not be modifying things at this
+               // point !
+               if (in && in->display() && (layout->isCommand() ||
+                   (layout->labeltype == LABEL_MANUAL && i < body_pos)))
+                       in->display(false);
+
                // break before a character that will fall off
                // the right of the row
                if (x >= width) {
-                       // if no break before, break here.
-                       if (point == last) {
+                       // if no break before or this is a fullrow inset, break here.
+                       if (point == last || display) {
                                if (pos < i)
                                        point = i - 1;
                                else
@@ -764,44 +775,40 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
                        break;
                }
 
-               Inset * in = par->isInset(i) ? par->getInset(i) : 0;
-
                if (!in || in->isChar()) {
                        // some insets are line separators too
                        if (par->isLineSeparator(i))
                                point = i;
                        continue;
-
                }
 
-               // check wether a Display() inset is valid here.
-               // If not, change it to non-display. FIXME:
-               // we should not be modifying things at this
-               // point !
-               if (in->display() && (layout->isCommand() ||
-                   (layout->labeltype == LABEL_MANUAL && i < body_pos))) {
-                       in->display(false);
-               } else if (in->display() || in->needFullRow()) {
-                       // displayed insets start at a new row
-                       if (i == pos) {
-                               if (pos < last - 1) {
-                                       point = i;
-                                       if (par->isLineSeparator(i + 1))
-                                               ++point;
-                               } else {
-                                       // to avoid extra rows
-                                       point = last;
-                               }
+               if (!display)
+                       continue;
+                       
+               // full row insets start at a new row
+               if (i == pos) {
+                       if (pos < last - 1) {
+                               point = i;
+                               if (par->isLineSeparator(i + 1))
+                                       ++point;
                        } else {
-                               point = i - 1;
+                               // to avoid extra rows
+                               point = last;
                        }
-                       break;
+               } else {
+                       point = i - 1;
                }
+               break;
        }
 
-       // didn't find one, break at the point we reached the edge
-       if (point == last && x >= width)
+       if (point == last && x >= width) {
+               // didn't find one, break at the point we reached the edge
                point = i;
+       } else if (i == last && x < width) {
+               // found one, but we fell off the end of the par, so prefer
+               // that.
+               point = last;
+       }
 
        // manual labels cannot be broken in LaTeX
        if (body_pos && point < body_pos)