summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2012-11-14 12:27:50 +0100
committerSebastian Geerken <devnull@localhost>2012-11-14 12:27:50 +0100
commit7a991750e1f7bdfe6bd39f95343cc742d00c6596 (patch)
tree63ca76e60873f69ad31b80fe99bc10d497b5a87c
parentc762eb9ab50bcc5d35194a82cf7837dbd3604984 (diff)
Penalty index is now calculated correctly.
-rw-r--r--dw/textblock.hh10
-rw-r--r--dw/textblock_linebreaking.cc3
2 files changed, 12 insertions, 1 deletions
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 99d1e713..5f588a23 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -515,6 +515,16 @@ protected:
{
return lineYOffsetCanvas (lines->getRef (lineIndex));
}
+
+ inline int calcPenaltyIndexForNewLine ()
+ {
+ if (lines->size() == 0)
+ return 0;
+ else
+ return
+ (words->getRef(lines->getLastRef()->lastWord)->flags &
+ (Word::DIV_CHAR_AT_EOL | Word::PERM_DIV_CHAR)) ? 1 : 0;
+ }
bool sendSelectionEvent (core::SelectionState::EventType eventType,
core::MousePositionEvent *event);
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index c98596c6..bac23cb9 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -487,7 +487,7 @@ void Textblock::wordWrap (int wordIndex, bool wrapAll)
accumulateWordData (wordIndex);
- int penaltyIndex = 0;
+ int penaltyIndex = calcPenaltyIndexForNewLine ();
bool newLine;
do {
@@ -615,6 +615,7 @@ void Textblock::wordWrap (int wordIndex, bool wrapAll)
tempNewLine ? "temporally" : "permanently",
firstIndex, breakPos);
lineAdded = true;
+ penaltyIndex = calcPenaltyIndexForNewLine ();
} else {
// TODO hyphenateWord() should return whether something has
// changed at all. So that a second run, with