From e035d673ffd941c2c3332fbc3eb09c1d1daca531 Mon Sep 17 00:00:00 2001 From: Asger Ottar Alstrup Date: Fri, 20 Oct 2006 20:57:21 +0000 Subject: [PATCH] - Dump parpos cache if you use -dbg workarea on command line git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15419 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 4 ++++ src/coordcache.C | 20 ++++++++++++++++++++ src/coordcache.h | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/BufferView.C b/src/BufferView.C index ad86b9f944..26008cacd4 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -1365,6 +1365,10 @@ void BufferView::updateMetrics(bool singlepar) << endl; metrics_info_ = ViewMetricsInfo(pit1, pit2, y1, y2, singlepar, size); + + if (lyxerr.debugging(Debug::WORKAREA)) { + coord_cache_.dump(); + } } diff --git a/src/coordcache.C b/src/coordcache.C index f3647189fb..a7f8a511e2 100644 --- a/src/coordcache.C +++ b/src/coordcache.C @@ -49,4 +49,24 @@ Point CoordCache::get(LyXText const * text, lyx::pit_type pit) return posit->second; } +void +CoordCache::dump() const { + lyxerr << "ParPosCache contains:" << std::endl; + for (ParPosCache::const_iterator i = getParPos().begin(); i != getParPos().end(); ++i) { + LyXText const * lt = (*i).first; + InnerParPosCache const & cache = (*i).second; + lyxerr << "LyXText:" << lt << std::endl; + for (InnerParPosCache::const_iterator j = cache.begin(); j != cache.end(); ++j) { + pit_type pit = (*j).first; + Paragraph const & par = lt->getPar(pit); + Point p = (*j).second; + lyxerr << "Paragraph " << pit << ": \""; + for (int k = 0; k < std::min(10, par.size()); ++k) { + lyxerr << lyx::to_utf8(docstring(1,par.getChar(k))); + } + lyxerr << "\" has point " << p.x_ << "," << p.y_ << std::endl; + } + } +} + } // namespace lyx diff --git a/src/coordcache.h b/src/coordcache.h index 4423b3459d..1b87794afd 100644 --- a/src/coordcache.h +++ b/src/coordcache.h @@ -105,7 +105,7 @@ private: * A global cache that allows us to come from a paragraph in a document * to a position point on the screen. * All points cached in this cache are only valid between subsequent - * updated. (x,y) == (0,0) is the upper left screen corner, x increases + * updates. (x,y) == (0,0) is the upper left screen corner, x increases * to the right, y increases downwords. * The cache is built in BufferView::updateMetrics which is called * from BufferView::Pimpl::update. The individual points are added @@ -142,6 +142,8 @@ public: return boundary ? slices1_ : slices0_; } + /// Dump the contents of the cache to lyxerr in debugging form + void dump() const; private: /// MathArrays CoordCacheBase arrays_; -- 2.39.2