I continue my backwards visit of history.
JMarc
+++ b/src/TextMetrics.cpp
@@ -16,7 +16,6 @@
*/
#include <config.h>
-
#include "TextMetrics.h"
There is no reason to delete a line here. You should always before
pushing a commit look at the diff and spot this kind of unintented changes.
#include "Bidi.h"
@@ -2113,6 +2112,11 @@ void TextMetrics::drawParagraph(PainterInfo & pi,
pit_typ
e pit, int x, int y) co
}
}
+ CursorSlice const & cs = cur.bottom();
+ ParagraphMetrics const & bottom_pm =
cur.bv().parMetrics(cs.text(), cs.p
it());
+ bool const bndry = (cur.depth() == 1) && cur.boundary();
+ Row const & cur_bottom_row = bottom_pm.getRow(cs.pos(), bndry);
+
This chunk really deserves a comment, like for example
// Get the top-level row in which the cursor is, that is the
// one that is not indide insets. This code is adapted from
// Cursor::textRow.
@@ -2123,7 +2127,46 @@ void TextMetrics::drawParagraph(PainterInfo & pi,
pit_type pit, int x, int y) co
&& y - row.ascent() < ww);
// It is not needed to draw on screen if we are not inside.
pi.pain.setDrawingEnabled(inside &&
original_drawing_state);
- RowPainter rp(pi, *text_, pit, row, bidi, x, y);
+
+ cur.setTargetX();
Did you check that this is still needed?
+ BufferView & bv = cur.bv();
+
+ // Current screen width in pixels
+ int const screen_width = bv.workWidth();
It is clearer to use bv.workWidth() everywhere in the code, since it is
not more expensive to compute and it makes the code more explicit.
+
+ // Current x position of the cursor in pixels
+ int cur_x = bv.getPos(cur).x_;
+
+ // Left edge value of the screen in pixels
+ int left_edge = cur.getLeftEdge();
+
+ // New x value modified to handle horizontal scrolling
+ int new_x = x;
Be careful! There is extra spacing after this line.
+
+ cout << "Loop:" << left_edge << " " << cur_x << " " <<
&cur_bottom_row << " " << &row<<endl;
We never use cout/cerr in LyX code. All debug output should go to lyxerr
stream. In particular, this code does not compile for me because cout is
not declared for some reason.
+ // Loop to handle horizontal sliding for too long insets
+ if (&cur_bottom_row == &row)
This is not a loop, just a test.
+ {
+ cout << "comes into if (current row)" << endl;
Avoid cout.
+ // If no need to slide from current position
+ if (cur_x <= (left_edge + screen_width - 10)
+ && cur_x >= left_edge + 10) {
+ }
It does not make sense to start your stream of tests by a if without a
then clause. obviously the right stream is
if (cur_x < left_edge + 10) ... else if (cur_x > left_edge +
screen_width - 10) ...
+
+ // If need to slide right
+ else if (cur_x < left_edge + 10) {
+ cur.setLeftEdge(cur_x - 10);
+ }
+
This line should be empty, but it contains tabs.
+ // If need to slide left (cur_x > left_edge +
screen_width - 10)
+ else {
+ cur.setLeftEdge(cur_x - screen_width + 10);
+ }
+ new_x -= left_edge;
I really doubt that this last line is correct, because you have not
modified the left_edge variable in the above if/else clauses. What would
be correct is to change the value of left_edge in the tests above and
that add a line
cur.setLeftEdge(left_edge);
after the tests (we do not care whether the value was already set).
Or you drop completely new_x and change the pain command to use x -
cur.leftEdge() instead of new_x. Actually I think this would be clearer
(less variables).
+ }
+
+ RowPainter rp(pi, *text_, pit, row, bidi, new_x, y);
JMarc