]> git.lyx.org Git - lyx.git/commitdiff
fix row breaking again ..
authorJohn Levon <levon@movementarian.org>
Fri, 11 Apr 2003 03:28:06 +0000 (03:28 +0000)
committerJohn Levon <levon@movementarian.org>
Fri, 11 Apr 2003 03:28:06 +0000 (03:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6775 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C

index 35f6f5f18c5235f8ea8de6e76051545257c256ad..3ee0e7681ac415a3fba86a482b7b0433efcf6101 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-11  John Levon  <levon@movementarian.org>
+
+       * text.C (rowBreakPoint): reintroduce the labelEnd
+       checks, code copied from the row fill stuff. Deep voodoo.
+
+       * text.C (fill): add a comment and debugging for the
+       next poor soul.
+
 2003-04-11  John Levon  <levon@movementarian.org>
 
        * text.C: make sure fullrow insets get wrapped to the next line,
index 893a952904e25d3f2f5de571b4adca0ca4dbebad..d3a665d4eb162678d7c270044b9b3f895119f716 100644 (file)
@@ -793,14 +793,20 @@ LyXText::rowBreakPoint(Row const & row) const
 
                char const c = pit->getChar(i);
 
-               int thiswidth = singleWidth(pit, i, c);
+               int thiswidth;
 
                // add the auto-hfill from label end to the body
                if (body_pos && i == body_pos) {
-                       thiswidth += font_metrics::width(layout->labelsep,
-                                   getLabelFont(bv()->buffer(), pit));
+                       thiswidth = font_metrics::width(layout->labelsep,
+                               getLabelFont(bv()->buffer(), pit));
                        if (pit->isLineSeparator(i - 1))
                                thiswidth -= singleWidth(pit, i - 1);
+                       int left_margin = labelEnd(row);
+                       if (thiswidth + x < left_margin)
+                               thiswidth = left_margin - x;
+                       thiswidth += singleWidth(pit, i, c);
+               } else {
+                       thiswidth = singleWidth(pit, i, c);
                }
 
                x += thiswidth;
@@ -918,6 +924,20 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
        }
 
        int const fill = paper_width - w - rightMargin(*bv()->buffer(), *row);
+
+       // If this case happens, it means that our calculation
+       // of the widths of the chars when we do rowBreakPoint()
+       // went wrong for some reason. Typically in list bodies.
+       // Things just about hobble on anyway, though you'll end
+       // up with a "fill_separator" less than zero, which corresponds
+       // to inter-word spacing being too small. Hopefully this problem
+       // will die when the label hacks die.
+       if (lyxerr.debugging() && fill < 0) {
+               lyxerr[Debug::GUI] << "Eek, fill() was < 0: " << fill
+                       << " w " << w << " paper_width " << paper_width
+                       << " right margin " << rightMargin(*bv()->buffer(), *row) << endl;
+       }
+
        return fill;
 }