I continue the review. Coding style point: please leave two empty lines
between method definitions.
JMarc
+++ b/src/Cursor.cpp
@@ -278,7 +278,7 @@ CursorData::CursorData(DocIterator const & dit)
// bv functions are not yet available!
Cursor::Cursor(BufferView & bv)
: CursorData(&bv.buffer()), bv_(&bv),
- x_target_(-1), textTargetOffset_(0)
+ x_target_(-1), textTargetOffset_(0),left_edge_(0)
{}
Didn't you forget too_wide_row_?
@@ -538,7 +538,33 @@ Row const & Cursor::textRow() const
{
CursorSlice const & cs = innerTextSlice();
ParagraphMetrics const & pm = bv().parMetrics(cs.text(), cs.pit());
- return pm.getRow(pos(), boundary());
+ bool const bndry = inTexted() ? boundary() : false;
+ return pm.getRow(cs.pos(), bndry);
+}
+
+int Cursor::getLeftEdge() const
+{
+ return left_edge_;
+}
+
+Row const & Cursor::getToowideRow()
+{
+ return *too_wide_row_;
+}
As I already said, I think this name is not good. I would propose
current_row_ or current_bottpm_row_. THe question is not to know whether
the row is to wide, but what is the row to which the value of left_edge
makes reference.
+
+void Cursor::setLeftEdge(int leftEdge)
+{
+ left_edge_ = leftEdge;
+}
+
+void Cursor::setLeftEdge(int leftEdge) const
+{
+ const_cast<Cursor *>(this)->setLeftEdge(leftEdge);
+}
When you have to do something like this, then something is usually
wrong. I think it would be better to make a cast the cursor to an
unconstified version in drawParagraphs that to create const methods that
are not const. This is just cheating.
+
+void Cursor::setToowideRow(Row & wideRow) const
+{
+ *too_wide_row_ = wideRow;
}
@@ -1757,6 +1784,14 @@ void Cursor::setTargetX()
setTargetX(x);
}
+void Cursor::setTargetX() const
+{
+ int x;
+ int y;
+ getPos(x, y);
+ const_cast<Cursor *>(this)->setTargetX(x);
+}
+
Again, I think this is plain wrong. Besides, when you really want to do
this, it is always better to do
void Cursor::setTargetX() const
{
const_cast<Cursor *>(this)->setTargetX();
}
bool Cursor::inMacroMode() const
{
@@ -1842,8 +1877,10 @@ bool Cursor::upDownInMath(bool up)
// check if we had something else in mind, if not, this is the
future
// target
- if (x_target_ == -1)
+ if (x_target_ == -1){
setTargetX(xo);
+ left_edge_=0;
+ }
else if (inset().asInsetText() && xo - textTargetOffset() !=
x_target()) {
// In text mode inside the line (not left or right)
possibly set a new target_x,
// but only if we are somewhere else than the previous
target-offset.
@@ -1981,8 +2018,10 @@ bool Cursor::upDownInText(bool up, bool &
updateNeeded)
// update the targetX - this is here before the "return false"
// to set a new target which can be used by InsetTexts above
// if we cannot move up/down inside this inset anymore
- if (x_target_ == -1)
+ if (x_target_ == -1){
setTargetX(xo);
+ left_edge_=0;
+ }
Are you sure that this one is needed? What is the use case?