From 3c4af0ffbf73289dc6a1dd63fe9e90f41fa8b546 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 14 Feb 2005 08:17:23 +0000 Subject: [PATCH] =?utf8?q?Andr=EF=BF=BD's=20font=20changes=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9621 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 5 +++++ src/ChangeLog | 7 +++++++ src/dociterator.C | 38 ++++++++++++++++++++++++++++++++++++++ src/dociterator.h | 4 +++- src/text2.C | 4 +++- 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 2527b90044..76aae37e59 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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; diff --git a/src/ChangeLog b/src/ChangeLog index 7ca58b3487..f068424106 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2005-02-14 André Pönitz + + * 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 * lyx_main.C (init): invoke prependEnvPath to adjust the PATH diff --git a/src/dociterator.C b/src/dociterator.C index 81f465826b..b4fd5c2218 100644 --- a/src/dociterator.C +++ b/src/dociterator.C @@ -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(); diff --git a/src/dociterator.h b/src/dociterator.h index a91fd32af3..9fc912ec07 100644 --- a/src/dociterator.h +++ b/src/dociterator.h @@ -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(); diff --git a/src/text2.C b/src/text2.C index f515328c4b..673287fbbb 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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); -- 2.39.5