Add parameter boundary for getRow() function

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10276 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2005-07-17 12:02:48 +00:00
parent baa6723a40
commit 4126b3f828
6 changed files with 40 additions and 22 deletions

View File

@ -1,3 +1,13 @@
2005-07-17 Juergen Vigna <jug@lyx.org>
* text2.C (cursorHome):
* text.C (drawSelection, cursorX):
* dociterator.C (textRow): add boundary to getRow() call
* paragraph.C (getRow): implementation of below
* paragraph.h: add parameter boundary for getRow() function
2005-07-18 José Matos <jamatos@fc.up.pt>
* buffer.C:
@ -5,7 +15,7 @@
* tex-strings.[Ch]: new file format, remove support for a4.sty,
a4wide.sty and a4widemargins.
2005-07-17 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
2005-07-17 Juergen Vigna <jug@lyx.org>
* text2.C (cursorLeft): fix one of error

View File

@ -156,14 +156,14 @@ Paragraph const & DocIterator::paragraph() const
Row & DocIterator::textRow()
{
BOOST_ASSERT(!paragraph().rows().empty());
return paragraph().getRow(pos());
return paragraph().getRow(pos(), boundary_);
}
Row const & DocIterator::textRow() const
{
BOOST_ASSERT(!paragraph().rows().empty());
return paragraph().getRow(pos());
return paragraph().getRow(pos(), boundary_);
}

View File

@ -1791,10 +1791,15 @@ bool Paragraph::allowEmpty() const
}
Row & Paragraph::getRow(pos_type pos)
Row & Paragraph::getRow(pos_type pos, bool boundary)
{
BOOST_ASSERT(!rows().empty());
// If boundary is set we should return the row on which
// the character before is inside.
if (pos > 0 && boundary)
--pos;
RowList::iterator rit = rows_.end();
RowList::iterator const begin = rows_.begin();
@ -1805,10 +1810,15 @@ Row & Paragraph::getRow(pos_type pos)
}
Row const & Paragraph::getRow(pos_type pos) const
Row const & Paragraph::getRow(pos_type pos, bool boundary) const
{
BOOST_ASSERT(!rows().empty());
// If boundary is set we should return the row on which
// the character before is inside.
if (pos > 0 && boundary)
--pos;
RowList::const_iterator rit = rows_.end();
RowList::const_iterator const begin = rows_.begin();

View File

@ -357,9 +357,9 @@ public:
ParagraphParameters const & params() const;
///
Row & getRow(lyx::pos_type pos);
Row & getRow(lyx::pos_type pos, bool boundary);
///
Row const & getRow(lyx::pos_type pos) const;
Row const & getRow(lyx::pos_type pos, bool boundary) const;
///
size_t pos2row(lyx::pos_type pos) const;

View File

@ -1767,7 +1767,7 @@ void LyXText::draw(PainterInfo & pi, int x, int y) const
}
/*
#if 0
// only used for inset right now. should also be used for main text
void LyXText::drawSelection(PainterInfo & pi, int x , int) const
{
@ -1794,8 +1794,8 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const
Paragraph const & par1 = pars_[beg.pit()];
Paragraph const & par2 = pars_[end.pit()];
Row const & row1 = par1.getRow(beg.pos());
Row const & row2 = par2.getRow(end.pos());
Row const & row1 = par1.getRow(beg.pos(), beg.boundary());
Row const & row2 = par2.getRow(end.pos(), end.boundary());
int y1,x1,x2;
if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_ABOVE) {
@ -1836,8 +1836,8 @@ void LyXText::drawSelection(PainterInfo & pi, int x , int) const
pi.pain.fillRectangle(x + X1, y2 - row2.height(),
X2 - X1, row2.height(), LColor::background);
}
*/
#else
void LyXText::drawSelection(PainterInfo & pi, int x, int) const
{
@ -1878,7 +1878,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
x1 = 0;
x2 = dim_.wid;
} else {
Row const & row1 = par1.getRow(beg.pos());
Row const & row1 = par1.getRow(beg.pos(), beg.boundary());
y1 = bv_funcs::getPos(beg, beg.boundary()).y_ - row1.ascent();
y2 = y1 + row1.height();
int const startx = cursorX(beg.top(), false);
@ -1893,7 +1893,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
X1 = 0;
X2 = dim_.wid;
} else {
Row const & row2 = par2.getRow(end.pos());
Row const & row2 = par2.getRow(end.pos(), end.boundary());
Y1 = bv_funcs::getPos(end, end.boundary()).y_ - row2.ascent();
Y2 = Y1 + row2.height();
int const endx = cursorX(end.top(), false);
@ -1901,8 +1901,8 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
X2 = !isRTL(par2) ? endx : 0 + dim_.wid;
}
if (!above && !below && &par1.getRow(beg.pos())
== &par2.getRow(end.pos()))
if (!above && !below && &par1.getRow(beg.pos(), end.boundary())
== &par2.getRow(end.pos(), end.boundary()))
{
// paint only one rectangle
pi.pain.fillRectangle(x + x1, y1, X2 - x1, y2 - y1,
@ -1920,7 +1920,7 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const
pi.pain.fillRectangle(x, y2, dim_.wid,
Y1 - y2, LColor::selection);
}
#endif
bool LyXText::isLastRow(pit_type pit, Row const & row) const
{
@ -2070,7 +2070,7 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
if (boundary_correction)
--ppos;
Row const & row = par.getRow(ppos);
Row const & row = par.getRow(sl.pos(), boundary);
pos_type cursor_vpos = 0;

View File

@ -481,11 +481,9 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
void LyXText::cursorHome(LCursor & cur)
{
BOOST_ASSERT(this == cur.text());
Paragraph const & par = cur.paragraph();
if (cur.boundary() && cur.pos())
setCursor(cur, cur.pit(), par.getRow(cur.pos()-1).pos());
else
setCursor(cur, cur.pit(), cur.textRow().pos());
Row const & row = cur.paragraph().getRow(cur.pos(),cur.boundary());
setCursor(cur, cur.pit(), row.pos());
}