Le 12/09/13 08:53, Hashini Senaratne a écrit :
I tried with removing this. If you also try that, you will see that the it
will introduce an abnormal behaviour when moving from the rightmost position
of the math inset to the below row, using right arrow. The observation is
word "Graphics" get scrolled to left.
Hi,
Here is a quick patch I tried yesterday. Please start from it and remove
completely the commented out lines. It seems to work.
Sorry to be terse, I am in a hurry.
JMarc
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4222315..92fdea8 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2847,21 +2847,10 @@ void checkCursorLeftEdge(PainterInfo & pi, Cursor const
& cur,
Bidi bidi;
Row const & row = cur.bottomRow();
BufferView const & bv = cur.bv();
- bool row_moved = false;
-
- // Left edge value of the screen in pixels
- int left_edge = cur.getLeftEdge();
// Set the row on which the cursor lives.
cur.setCurrentRow(&row);
- // If the row has changed, return for the first time
- // This is because the row chage within math inset for mouse clicks
- if (cur.getLeftEdge() == 0
- && left_edge != 0) {
- return;
- }
-
// Force the recomputation of inset positions
bool const drawing = pi.pain.isDrawingEnabled();
pi.pain.setDrawingEnabled(false);
@@ -2873,6 +2862,10 @@ void checkCursorLeftEdge(PainterInfo & pi, Cursor const
& cur,
// Current x position of the cursor in pixels
int const cur_x = bv.getPos(cur).x_;
+ // Left edge value of the screen in pixels
+ int left_edge = cur.getLeftEdge();
+ bool row_moved = false;
+
// If need to slide right
if (cur_x < left_edge + 10) {
left_edge = cur_x - 10;
@@ -2885,12 +2878,14 @@ void checkCursorLeftEdge(PainterInfo & pi, Cursor const
& cur,
row_moved = true;
}
- if (strategy == NoScreenUpdate && row_moved) {
+ if (strategy == NoScreenUpdate && (row_moved || cur.getPreviousRow())) {
// FIXME: if one uses SingleParUpdate, then home/end
// will not work on long rows. Why?
strategy = FullScreenUpdate;
}
+ lyxerr << "Cursor row=" << cur.getCurrentRow() << ", strategy=" <<
strategy << ", prerow=" << cur.getPreviousRow() << ", left_edge=" << left_edge
<< endl;
+
cur.setLeftEdge(left_edge);
}
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 2c537d3..9276c6f 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -576,6 +576,7 @@ void Cursor::setLeftEdge(int leftEdge) const
void Cursor::setCurrentRow(Row const * wideRow) const
{
+ lyxerr << "setCurrentRow " << current_row_ << " => " << wideRow << ",
left_edge=" << left_edge_ << endl;
// nothing to do if the cursor was already on this row
if (current_row_ == wideRow) {
previous_row_ = 0;
@@ -1792,7 +1793,7 @@ int Cursor::targetX() const
int x = 0;
int y = 0;
getPos(x, y);
- const_cast<Cursor *>(this)->setLeftEdge(0);
+// const_cast<Cursor *>(this)->setLeftEdge(0);
return x;
}
@@ -1898,7 +1899,7 @@ bool Cursor::upDownInMath(bool up)
// target
if (x_target_ == -1){
setTargetX(xo);
- left_edge_=0;
+// 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,
@@ -2039,7 +2040,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
// if we cannot move up/down inside this inset anymore
if (x_target_ == -1){
setTargetX(xo);
- left_edge_=0;
+// left_edge_=0;
}
else if (xo - textTargetOffset() != x_target() &&
depth() ==
beforeDispatchCursor_.depth()) {