]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
More 'standard conformant blurb' nonsense.
[lyx.git] / src / text.C
index ebbe4e107dfd3f9537ac1e6250a6bb7d188c4daf..aac263891554fdde9793cfdf40a301d491e3d0ac 100644 (file)
@@ -97,44 +97,14 @@ void LyXText::updateRowPositions()
 
 int LyXText::top_y() const
 {
-       if (anchor_row_ == endRow())
-               return 0;
-
-       return anchor_row_->y() + anchor_row_offset_;
+       return anchor_y_;
 }
 
 
 void LyXText::top_y(int newy)
 {
-       if (ownerParagraphs().begin()->rows.empty())
-               return;
-
-       if (isInInset()) {
-               anchor_row_ = firstRow();
-               anchor_row_offset_ = newy;
-               return;
-       }
-
-       lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
-
-       int y = newy;
-       ParagraphList::iterator dummypit;
-       anchor_row_ = getRowNearY(y, dummypit);
-       anchor_row_offset_ = newy - y;
-       lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_
-              << " offset: " << anchor_row_offset_ << endl;
-}
-
-
-void LyXText::anchor_row(RowList::iterator rit)
-{
-       int old_y = top_y();
-       anchor_row_offset_ = 0;
-       anchor_row_ = rit;
-       anchor_row_offset_ = old_y - top_y();
-       lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: "
-                          << &*anchor_row_ << " offset: "
-                          << anchor_row_offset_ << endl;
+       anchor_y_ = newy;
+       lyxerr[Debug::GUI] << "changing reference to offset: " << anchor_y_ << endl;
 }
 
 
@@ -253,26 +223,12 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
 
        if (c == Paragraph::META_INSET) {
                InsetOld * tmpinset = pit->getInset(pos);
-               if (tmpinset) {
-                       if (tmpinset->lyxCode() == InsetOld::HFILL_CODE) {
-                               // Because of the representation as vertical lines
-                               return 3;
-                       }
-#if 0
-#warning enabling this fixes the 'insets of width 0 on load' problem
-                       // this IS needed otherwise on initialitation we don't get the fill
-                       // of the row right (ONLY on initialization if we read a file!)
-                       // should be changed! (Jug 20011204)
-                       //tmpinset->update(bv());
-                       Dimension dim;
-                       MetricsInfo mi(bv(), font, workWidth());
-                       tmpinset->metrics(mi, dim);
-                       return dim.wid;
-#else
-                       return tmpinset->width();
-#endif
+               Assert(tmpinset);
+               if (tmpinset->lyxCode() == InsetOld::HFILL_CODE) {
+                       // Because of the representation as vertical lines
+                       return 3;
                }
-               return 0;
+               return tmpinset->width();
        }
 
        if (IsSeparatorChar(c))
@@ -2196,34 +2152,18 @@ RowList::iterator LyXText::cursorIRow() const
 RowList::iterator LyXText::getRowNearY(int & y,
        ParagraphList::iterator & pit) const
 {
-       ParagraphList::iterator const end = ownerParagraphs().end();
        //lyxerr << "getRowNearY: y " << y << endl;
+       pit = ownerParagraphs().begin();
+       RowList::iterator rit = firstRow();
+       RowList::iterator rend = endRow();
 
-       for (pit = ownerParagraphs().begin(); pit != end; ++pit) {
-               RowList::iterator rit = pit->rows.begin();
-               RowList::iterator rend = pit->rows.end();
-
-               for ( ; rit != rend; ++rit) {
-                       //rit->dump();
-                       if (rit->y() >= y) {
-                               if (rit != firstRow())
-                                       previousRow(pit, rit);
-                               y = rit->y();
-                               return rit;
-                       }
-               }
-       }
+       for (; rit != rend; nextRow(pit, rit))
+               if (rit->y() > y)
+                       break;
 
-#if 1
-       pit = ownerParagraphs().begin();
-       y = 0;
-       lyxerr << "row not found near " << y << "  pit: " << &*pit << endl;
-       return firstRow();
-#else
-       pit = boost::prior(ownerParagraphs().end());
-       lyxerr << "row not found near " << y << "  pit: " << &*pit << endl;
-       return lastRow();
-#endif
+       previousRow(pit, rit);
+       y = rit->y();
+       return rit;
 }
 
 
@@ -2254,12 +2194,11 @@ RowList::iterator LyXText::endRow() const
 void LyXText::nextRow(ParagraphList::iterator & pit,
        RowList::iterator & rit) const
 {
-       if (boost::next(rit) != pit->rows.end()) {
-               rit = boost::next(rit);
-       } else {
+       ++rit;
+       if (rit == pit->rows.end()) {
                ++pit;
                if (pit == ownerParagraphs().end())
-                       rit = boost::next(rit);
+                       --pit;
                else
                        rit = pit->rows.begin();
        }
@@ -2270,7 +2209,7 @@ void LyXText::previousRow(ParagraphList::iterator & pit,
        RowList::iterator & rit) const
 {
        if (rit != pit->rows.begin())
-               rit = boost::prior(rit);
+               --rit;
        else {
                Assert(pit != ownerParagraphs().begin());
                --pit;