]> git.lyx.org Git - features.git/commitdiff
Andr�'s font changes fix
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 14 Feb 2005 08:17:23 +0000 (08:17 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 14 Feb 2005 08:17:23 +0000 (08:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9621 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/dociterator.C
src/dociterator.h
src/text2.C

index 2527b900449661f1b3802714004e85400b2ca28d..76aae37e595d80dc20ce9da8306d7e3f8b93f720 100644 (file)
@@ -1270,15 +1270,20 @@ ViewMetricsInfo BufferView::Pimpl::metrics()
 
        // Redo paragraphs below cursor if necessary
        int y2 = y0;
+       lyxerr << "y2 (1): " << y2 << endl;
        while (y2 < bv.workHeight() && pit2 < int(npit) - 1) {
                y2 += text->getPar(pit2).descent();
+               lyxerr << "y2 (2): " << y2 << endl;
                ++pit2;
                text->redoParagraph(pit2);
                y2 += text->getPar(pit2).ascent();
+               lyxerr << "y2 (3): " << y2 << endl;
        }
 
        // Take care of descent of last line
        y2 += text->getPar(pit2).descent();
+       lyxerr << "text->getPar(pit2).descent(): " << text->getPar(pit2).descent() << endl;
+       lyxerr << "y2 (4): " << y2 << endl;
 
        // The coordinates of all these paragraphs are correct, cache them
        int y = y1;
index 7ca58b34872609051a5e4ce9cd3af2f532b163ea..f0684241066e0cd34de8511d6e213c37ea2b3308 100644 (file)
@@ -1,3 +1,10 @@
+2005-02-14  André Pönitz  <poenitz@gmx.net>
+
+       * dociterator.[Ch]: new member forwardPosNoDescent(),
+       which doesn't enter nested insets.
+       * text2.C (setFont): use forwardPosNoDescent() instead
+       of ForwardPos() (fixes crash on font change).
+
 2005-02-13  Angus Leeming  <leeming@lyx.org>
 
        * lyx_main.C (init): invoke prependEnvPath to adjust the PATH
index 81f465826baa3d697e9c56a20b9d554464a5a6d3..b4fd5c2218892b23fc26617c782ea0f2451d8137 100644 (file)
@@ -138,6 +138,8 @@ LyXText const * DocIterator::text() const
 
 Paragraph & DocIterator::paragraph()
 {
+       if (!inTexted()) 
+               lyxerr << *this << endl;
        BOOST_ASSERT(inTexted());
        return top().paragraph();
 }
@@ -341,6 +343,42 @@ void DocIterator::forwardPos()
 }
 
 
+void DocIterator::forwardPosNoDescend()
+{
+       CursorSlice & tip = top();
+       pos_type const lastp = lastpos();
+
+       //  move on one position if possible
+       if (tip.pos() < lastp) {
+               //lyxerr << "... next pos" << endl;
+               ++tip.pos();
+               return;
+       }
+       //lyxerr << "... no next pos" << endl;
+
+       // otherwise move on one paragraph if possible
+       if (tip.pit() < lastpit()) {
+               //lyxerr << "... next par" << endl;
+               ++tip.pit();
+               tip.pos() = 0;
+               return;
+       }
+       //lyxerr << "... no next pit" << endl;
+
+       // otherwise try to move on one cell if possible
+       if (tip.idx() < lastidx()) {
+               //lyxerr << "... next idx" << endl;
+               ++tip.idx();
+               tip.pit() = 0;
+               tip.pos() = 0;
+               return;
+       }
+       //lyxerr << "... no next idx" << endl;
+
+       // otherwise we can't move on
+}
+
+
 void DocIterator::forwardPar()
 {
        forwardPos();
index a91fd32af39c17077bcc9ecaefddf4d145cc4a53..9fc912ec0792ef0b8d36c93709758cd0371314db 100644 (file)
@@ -177,7 +177,9 @@ public:
        //
        // elementary moving
        //
-       /// move on one logical position
+       /// move on one logical position, do not descend into nested insets
+       void forwardPosNoDescend();
+       /// move on one logical position, descend into nested insets
        void forwardPos();
        /// move on one physical character or inset
        void forwardChar();
index f515328c4b7641cc318fd9fcf96d76b53f5eb70a..673287fbbb595796f0fedb4242fbf7cb15b9ebde 100644 (file)
@@ -440,7 +440,9 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
 
        // Don't use forwardChar here as ditend might have
        // pos() == lastpos() and forwardChar would miss it.
-       for (; dit != ditend; dit.forwardPos()) {
+       // Can't use forwardPos either as this descends into
+       // nested insets. 
+       for (; dit != ditend; dit.forwardPosNoDescend()) {
                if (dit.pos() != dit.lastpos()) {
                        LyXFont f = getFont(dit.paragraph(), dit.pos());
                        f.update(font, params.language, toggleall);