* Full author contact details are available in file CREDITS.
*/
-//#define KEEP_OLD_METRICS_CODE 1
+#define KEEP_OLD_METRICS_CODE 1
#include <config.h>
int const width = max_width_ - right_margin;
pos_type const body_pos = par.beginOfBody();
row.clear();
- row.dimension().wid = leftMargin(max_width_, pit, pos);
- row.x = row.width();
+ row.x = leftMargin(max_width_, pit, pos);
+ row.dimension().wid = row.x;
row.right_margin = right_margin;
if (pos >= end || row.width() > width) {
// x is an absolute screen coord
// returns the column near the specified x-coordinate of the row
// x is set to the real beginning of this column
-pos_type TextMetrics::getColumnNearX(pit_type const pit,
+pos_type TextMetrics::getPosNearX(pit_type const pit,
Row const & row, int & x, bool & boundary) const
{
pos_type pos = row.pos();
boundary = false;
- if (row.x >= x || row.empty())
+ if (row.empty())
x = row.x;
- else if (x >= row.width() - row.right_margin) {
+ else if (x < row.x) {
+ pos = row.front().font.isVisibleRightToLeft() ?
+ row.front().endpos : row.front().pos;
+ x = row.x;
+ } else if (x > row.width() - row.right_margin) {
+ pos = row.back().font.isVisibleRightToLeft() ?
+ row.back().pos : row.back().endpos;
x = row.width() - row.right_margin;
- pos = row.back().endpos;
} else {
double w = row.x;
Row::const_iterator cit = row.begin();
boundary = row.right_boundary();
x += xo;
-#if !defined(KEEP_OLD_METRICS_CODE)
- return pos - row.pos();
-#else
+#ifdef KEEP_OLD_METRICS_CODE
Buffer const & buffer = bv_->buffer();
int x2 = x_orig;
#endif
x2 = int(tmpx) + xo;
- pos_type const col = c - row.pos();
+ //pos_type const col = c - row.pos();
if (abs(x2 - x) > 0.1 || boundary != boundary
|| c != pos) {
- lyxerr << "getColumnNearX: new=(x=" << x - xo << ", b=" << boundary << ", p=" << pos << "), "
+ lyxerr << "getPosNearX(" << x_orig << "): new=(x=" << x - xo << ", b=" << boundary << ", p=" << pos << "), "
<< "old=(x=" << x2 - xo << ", b=" << boundary2 << ", p=" << c << "), " << row;
}
+#if 0
if (!c || end == par.size())
return col;
}
return min(col, end - 1 - row.pos());
-#endif
+#endif // 0
+#endif // KEEP_OLD_METRICS_CODE
+ return pos;
}
LBUFERR(row < int(pm.rows().size()));
bool bound = false;
Row const & r = pm.rows()[row];
- return r.pos() + getColumnNearX(pit, r, x, bound);
+ return getPosNearX(pit, r, x, bound);
}
if (!it) {
// No inset, set position in the text
- bool bound = false; // is modified by getColumnNearX
- int xx = x; // is modified by getColumnNearX
- cur.pos() = row.pos()
- + getColumnNearX(pit, row, xx, bound);
+ bool bound = false; // is modified by getPosNearX
+ int xx = x; // is modified by getPosNearX
+ cur.pos() = getPosNearX(pit, row, xx, bound);
cur.boundary(bound);
cur.setCurrentFont();
cur.setTargetX(xx);
bool bound = false;
int xx = x;
- pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
+ pos_type const pos = getPosNearX(pit, row, xx, bound);
LYXERR(Debug::DEBUG, "setting cursor pit: " << pit << " pos: " << pos);
double x = row.x;
/**
- * When boundary is true, position is on the row element (pos, endpos)
+ * When boundary is true, position i is in the row element (pos, endpos)
* if
- * pos < pos <= endpos
+ * pos < i <= endpos
* whereas, when boundary is false, the test is
- * pos <= pos < endpos
+ * pos <= i < endpos
* The correction below allows to handle both cases.
*/
int const boundary_corr = (boundary && pos) ? -1 : 0;
+ //?????
if (row.empty()
- || (row.begin()->font.isRightToLeft()
+ || (row.begin()->font.isVisibleRightToLeft()
&& pos == row.begin()->endpos))
return int(x);
}
if (cit == row.end()
- && (row.back().font.isRightToLeft() || pos != row.back().endpos))
- lyxerr << "NOT FOUND!"
- << "pos=" << pos << "(" << boundary_corr << ")" << "\n"
- << row;
+ && (row.back().font.isVisibleRightToLeft() || pos != row.back().endpos))
+ LYXERR0("cursorX(" << pos - boundary_corr
+ << ", " << boundary_corr << "): NOT FOUND! " << row);
#ifdef KEEP_OLD_METRICS_CODE
Paragraph const & par = text_->paragraphs()[pit];
}
if (abs(x2 - x) > 0.01) {
- lyxerr << "cursorX: x2=" << x2 << ", x=" << x;
+ lyxerr << "cursorX(" << pos - boundary_corr << ", " << boundary_corr
+ << "): old=" << x2 << ", new=" << x;
if (cit == row.end())
- lyxerr << "Element not found for "
- << pos - boundary_corr << "(" << boundary_corr << ")";
+ lyxerr << "Element not found\n";
else
- lyxerr << " in [" << cit->pos << "/"
- << pos - boundary_corr << "(" << boundary_corr << ")"
- << "/" << cit->endpos << "] of " << *cit << "\n";
+ lyxerr << " found in " << *cit << "\n";
lyxerr << row <<endl;
}
-#endif
+#endif // KEEP_OLD_METRICS_CODE
return int(x);
}