From 08b29513b3e9a83ebe6baf5796ee7a3d584a855e Mon Sep 17 00:00:00 2001 From: John Levon Date: Fri, 11 Apr 2003 03:28:06 +0000 Subject: [PATCH] fix row breaking again .. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6775 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 ++++++++ src/text.C | 26 +++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 35f6f5f18c..3ee0e7681a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-04-11 John Levon + + * 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 * text.C: make sure fullrow insets get wrapped to the next line, diff --git a/src/text.C b/src/text.C index 893a952904..d3a665d4eb 100644 --- a/src/text.C +++ b/src/text.C @@ -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; }