15/07/2013 19:22, Hashini Senaratne:
Hello Jean-Marc,
What do you mean by "cursor positions"?
The position where the text-cursor seems to be appear. I have to edit it as
the next step.
OK.
Besides, is it intentionnlly that you skipped the use of
(set|get)ToowideRow?
What I thought about this ToowideRow is to be used to set the cursor
position, when the cursor move from one row to another. I cannot think of a
way to use this to identify the current row where the cursor lies; because I
hope to update this variable from the same place that I am sliding the too
wide rows. So I used the condition; if (&cur.textRow() == &row).
The problem is that, when you leave a row where left_edge>0 (row has
been slid), this value of left_edge will apply to the row where the
cursor is. The code that I proposed is the most convenient place to
update this value IMO.
But this does not seem to work for too wide tables. I tried disabling half
back solution for the tables (commenting all the content in void
InsetTabular::resetPos(Cursor & cur) const). But the table did not slide. I
cannot find a reason.
OK, try to start from the attached patch. What it does is, instead of
using textRow, which would here be the inner row contained in the table
cell, it works at the most outer row level. The code I added is
copy-and-pasted from Cursor::textRow and adapted to have the most global
row. It seems to work with my limited testing.
When I run the program without disabling half back solution and add some
text to the final (right most) column, text did get shifted to left
unexpectedly. This happens if I edit the table after going along too wide
math equation. So I believe this can be fixed using TooWideRow variable.
Indeed.
JMarc
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index f254b80..b1fb10f 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -2113,6 +2113,11 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co
}
}
+ CursorSlice const & cs = cur.bottom();
+ ParagraphMetrics const & bottom_pm = cur.bv().parMetrics(cs.text(), cs.pit());
+ bool const bndry = (cur.depth() == 1) && cur.boundary();
+ Row const & cur_bottom_row = bottom_pm.getRow(cs.pos(), bndry);
+
for (size_t i = 0; i != nrows; ++i) {
Row const & row = pm.rows()[i];
@@ -2136,7 +2141,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co
int new_x=x;
// loop to handle horizontal sliding for too long insects
- if (&cur.textRow() == &row)
+ if (&cur_bottom_row == &row)
{
//if no need to slide from current position
if(cur_x<(left_edge+screen_width)
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 5571de0..b8b3335 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -5136,6 +5136,7 @@ int InsetTabular::cellXPos(idx_type const cell) const
void InsetTabular::resetPos(Cursor & cur) const
{
+#if 0
BufferView & bv = cur.bv();
int const maxwidth = bv.workWidth();
@@ -5161,6 +5162,7 @@ void InsetTabular::resetPos(Cursor & cur) const
// only update if offset changed
if (scx_ != scx_old)
cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+#endif
}