mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
Handle cursor position after last char in row before a inset which uses a whole row
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10233 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6ee9bbab04
commit
88d9527776
@ -1,3 +1,10 @@
|
||||
2005-07-16 Juergen Vigna <jug@lyx.org>
|
||||
|
||||
* cursor.C (bruteFind2):
|
||||
* bufferview_funcs.C (coordOffset):
|
||||
* text.C (cursorX,cursorY): Handle cursor position after last char
|
||||
in row before a inset which uses a whole row.
|
||||
|
||||
2005-07-15 José Matos <jamatos@lyx.org>
|
||||
|
||||
* output_plaintext.[Ch] (writeFileAscii): control reference title
|
||||
|
@ -7,6 +7,7 @@
|
||||
* \author Jean-Marc Lasgouttes
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
* \author Juergen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -162,7 +163,7 @@ Point coordOffset(DocIterator const & dit, bool boundary)
|
||||
CursorSlice const & sl = dit[i];
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
sl.inset().cursorPos(sl, boundary, xx, yy);
|
||||
sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
|
||||
x += xx;
|
||||
y += yy;
|
||||
//lyxerr << "LCursor::getPos, i: "
|
||||
@ -173,12 +174,23 @@ Point coordOffset(DocIterator const & dit, bool boundary)
|
||||
CursorSlice const & sl = dit[0];
|
||||
Paragraph const & par = sl.text()->getPar(sl.pit());
|
||||
y -= par.rows()[0].ascent();
|
||||
//size_t rend = par.pos2row(sl.pos() - boundary ? 1 : 0);
|
||||
#if 1
|
||||
size_t rend;
|
||||
if (sl.pos() > 0 && dit.depth() == 1) {
|
||||
int pos = sl.pos();
|
||||
if (pos && boundary)
|
||||
--pos;
|
||||
// lyxerr << "coordOffset: boundary:" << boundary << " depth:" << dit.depth() << " pos:" << pos << " sl.pos:" << sl.pos() << std::endl;
|
||||
rend = par.pos2row(pos);
|
||||
} else
|
||||
rend = par.pos2row(sl.pos());
|
||||
#else
|
||||
size_t rend = par.pos2row(sl.pos());
|
||||
#endif
|
||||
for (size_t rit = 0; rit != rend; ++rit)
|
||||
y += par.rows()[rit].height();
|
||||
y += par.rows()[rend].ascent();
|
||||
x += dit.bottom().text()->cursorX(dit.bottom(), boundary);
|
||||
x += dit.bottom().text()->cursorX(dit.bottom(), boundary && dit.depth() == 1);
|
||||
// The following correction should not be there at all.
|
||||
// The cursor looks much better with the -1, though.
|
||||
--x;
|
||||
|
@ -96,7 +96,7 @@ namespace {
|
||||
for (int i = 0; ; ++i) {
|
||||
int xo;
|
||||
int yo;
|
||||
it.inset().cursorPos(it.top(), c.boundary(), xo, yo);
|
||||
it.inset().cursorPos(it.top(), c.boundary() && ((i+1) == it.depth()), xo, yo);
|
||||
double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
|
||||
// '<=' in order to take the last possible position
|
||||
// this is important for clicking behind \sum in e.g. '\sum_i a'
|
||||
|
36
src/text.C
36
src/text.C
@ -1882,7 +1882,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
|
||||
Row const & row1 = par1.getRow(beg.pos());
|
||||
y1 = bv_funcs::getPos(beg, beg.boundary()).y_ - row1.ascent();
|
||||
y2 = y1 + row1.height();
|
||||
int const startx = cursorX(beg.top(), beg.boundary());
|
||||
int const startx = cursorX(beg.top(), false);
|
||||
x1 = !isRTL(par1) ? startx : 0;
|
||||
x2 = !isRTL(par1) ? 0 + dim_.wid : startx;
|
||||
}
|
||||
@ -1897,7 +1897,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
|
||||
Row const & row2 = par2.getRow(end.pos());
|
||||
Y1 = bv_funcs::getPos(end, end.boundary()).y_ - row2.ascent();
|
||||
Y2 = Y1 + row2.height();
|
||||
int const endx = cursorX(end.top(), end.boundary());
|
||||
int const endx = cursorX(end.top(), false);
|
||||
X1 = !isRTL(par2) ? 0 : endx;
|
||||
X2 = !isRTL(par2) ? endx : 0 + dim_.wid;
|
||||
}
|
||||
@ -2065,12 +2065,12 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
|
||||
if (par.rows().empty())
|
||||
return 0;
|
||||
|
||||
pos_type pos = sl.pos();
|
||||
pos_type ppos = sl.pos();
|
||||
//// Correct position in front of big insets
|
||||
//if (pos && boundary)
|
||||
// --pos;
|
||||
if (ppos && boundary)
|
||||
--ppos;
|
||||
|
||||
Row const & row = par.getRow(pos);
|
||||
Row const & row = par.getRow(ppos);
|
||||
|
||||
pos_type cursor_vpos = 0;
|
||||
|
||||
@ -2082,16 +2082,16 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
|
||||
|
||||
if (end <= row_pos)
|
||||
cursor_vpos = row_pos;
|
||||
else if (pos >= end)
|
||||
else if (ppos >= end)
|
||||
cursor_vpos = isRTL(par) ? row_pos : end;
|
||||
else if (pos > row_pos && pos >= end)
|
||||
else if (ppos > row_pos && ppos >= end)
|
||||
// Place cursor after char at (logical) position pos - 1
|
||||
cursor_vpos = (bidi.level(pos - 1) % 2 == 0)
|
||||
? bidi.log2vis(pos - 1) + 1 : bidi.log2vis(pos - 1);
|
||||
cursor_vpos = (bidi.level(ppos - 1) % 2 == 0)
|
||||
? bidi.log2vis(ppos - 1) + 1 : bidi.log2vis(ppos - 1);
|
||||
else
|
||||
// Place cursor before char at (logical) position pos
|
||||
cursor_vpos = (bidi.level(pos) % 2 == 0)
|
||||
? bidi.log2vis(pos) : bidi.log2vis(pos) + 1;
|
||||
// Place cursor before char at (logical) position ppos
|
||||
cursor_vpos = (bidi.level(ppos) % 2 == 0)
|
||||
? bidi.log2vis(ppos) : bidi.log2vis(ppos) + 1;
|
||||
|
||||
pos_type body_pos = par.beginOfBody();
|
||||
if (body_pos > 0 &&
|
||||
@ -2123,8 +2123,8 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
|
||||
}
|
||||
|
||||
// see correction above
|
||||
//if (pos && boundary)
|
||||
// x += singleWidth(par, pos + 1);
|
||||
if (ppos && boundary)
|
||||
x += singleWidth(par, ppos);
|
||||
|
||||
return int(x);
|
||||
}
|
||||
@ -2138,8 +2138,10 @@ int LyXText::cursorY(CursorSlice const & sl, bool boundary) const
|
||||
h -= pars_[0].rows()[0].ascent();
|
||||
for (pit_type pit = 0; pit < sl.pit(); ++pit)
|
||||
h += pars_[pit].height();
|
||||
//size_t const rend = par.pos2row(sl.pos() - boundary ? 1 : 0);
|
||||
size_t const rend = par.pos2row(sl.pos());
|
||||
int pos = sl.pos();
|
||||
if (pos && boundary)
|
||||
--pos;
|
||||
size_t const rend = par.pos2row(pos);
|
||||
for (size_t rit = 0; rit != rend; ++rit)
|
||||
h += par.rows()[rit].height();
|
||||
h += par.rows()[rend].ascent();
|
||||
|
Loading…
Reference in New Issue
Block a user