commit 2737f82139350bb084dd4b59e51e6a9bf5fd81f3
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Oct 17 14:34:09 2014 +0200
Fix bug #9288: Cannot position cursor near the end of a line.
The problem was that some parts of the code assume that the right margin is
part of the width of the row. This is not the case, only the left margin
(Row::x) is counted.
The code has been fixed and documented to reflect this.
diff --git a/src/Row.h b/src/Row.h
index 04890f7..13a11b4 100644
--- a/src/Row.h
+++ b/src/Row.h
@@ -165,7 +165,7 @@ public:
Dimension & dimension() { return dim_; }
///
int height() const { return dim_.height(); }
- ///
+ /// The width of the row, including the left margin, but not the right
one.
int width() const { return dim_.wid; }
///
int ascent() const { return dim_.asc; }
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 637ce1f..6c3126b 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -808,7 +808,6 @@ void TextMetrics::breakRow(Row & row, int const
right_margin, pit_type const pit
row.right_margin = right_margin;
if (pos >= end || row.width() > width) {
- row.dimension().wid += right_margin;
row.endpos(end);
return;
}
@@ -1122,9 +1121,9 @@ pos_type TextMetrics::getPosNearX(Row const & row, int &
x,
else if (x <= row.x) {
pos = row.front().left_pos();
x = int(row.x);
- } else if (x >= row.width() - row.right_margin) {
+ } else if (x >= row.width()) {
pos = row.back().right_pos();
- x = row.width() - row.right_margin;
+ x = row.width();
} else {
double w = row.x;
Row::const_iterator cit = row.begin();
@@ -1140,7 +1139,7 @@ pos_type TextMetrics::getPosNearX(Row const & row, int &
x,
}
if (cit == row.end()) {
pos = row.back().right_pos();
- x = row.width() - row.right_margin;
+ x = row.width();
}
/** This tests for the case where the cursor is placed
* just before a font direction change. See comment on