]> git.lyx.org Git - features.git/commitdiff
Add parameter boundary for getRow() function
authorJürgen Vigna <jug@sad.it>
Sun, 17 Jul 2005 12:02:48 +0000 (12:02 +0000)
committerJürgen Vigna <jug@sad.it>
Sun, 17 Jul 2005 12:02:48 +0000 (12:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10276 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/dociterator.C
src/paragraph.C
src/paragraph.h
src/text.C
src/text2.C

index e1f0dadee929a1e5ccba0b606eb16d534f36adde..6317ed4e278d582950d4df00dc6adc1cbf3dd743 100644 (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
 
index 4243e639cce9867bdce38313e7ad65373f5f3a17..2ede4d4518fdc1c5f27a41bf54f01ebe5ec4dcbf 100644 (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_);
 }
 
 
index bf272458c4a03ba8ce7488f9a5bb207da760fd13..93003af27c41aa00e22367a4c4d0ca841602bb5b 100644 (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();
 
index 36739946f9523494586abacace1c46eddb933cb2..2002676b04e065b34b28ae606244bd193482ec57 100644 (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;
 
index 9f5a56b5c3607f1979476cdddcb6b10a9f32bff3..12a1985c121106c10fd8b52774979a3171a95322 100644 (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;
 
index 77f4699c4ae2372147d625c9f8e3f85368314393..77ce0814e71604a5e603238bd5212aae86fae5e3 100644 (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());
 }