]> git.lyx.org Git - lyx.git/blobdiff - src/coordcache.h
minimal effort implementation of:
[lyx.git] / src / coordcache.h
index 779427525516c06d4c3112ce7a51d45804a8e4b1..535a712716335793da79335c2392b64481edeaa5 100644 (file)
@@ -1,3 +1,13 @@
+// -*- C++ -*-
+/* \file coordcache.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #ifndef COORDCACHE_H
 #define COORDCACHE_H
 
@@ -20,18 +30,18 @@ public:
                : x_(0), y_(0)
        {}
 
-       Point(int x, int y) : x_(x), y_(y)
+       Point(int x, int y)
+               : x_(x), y_(y)
        {
-               BOOST_ASSERT(x > -3000);
-               BOOST_ASSERT(x <  4000);
-               BOOST_ASSERT(y > -3000);
-               BOOST_ASSERT(y <  4000);
+               BOOST_ASSERT(x > -1000000);
+               BOOST_ASSERT(x <  1000000);
+               BOOST_ASSERT(y > -1000000);
+               BOOST_ASSERT(y <  1000000);
        }
 
        int x_, y_;
 };
 
-
 template <class T> class CoordCacheBase {
 public:
        void clear()
@@ -98,12 +108,6 @@ private:
  */
 class CoordCache {
 public:
-       CoordCache() : updating(false) { }
-       /// In order to find bugs, we record when we start updating the cache
-       void startUpdating();
-       /// When we are done, we record that to help find bugs
-       void doneUpdating();
-
        void clear();
        Point get(LyXText const *, lyx::pit_type);
 
@@ -111,30 +115,39 @@ public:
        typedef std::map<lyx::pit_type, Point> InnerParPosCache;
        /// A map from a LyXText to the map of paragraphs to screen points
        typedef std::map<LyXText const *, InnerParPosCache> ParPosCache;
+       /// A map from a CursorSlice to screen points
+       typedef std::map<LyXText const *, InnerParPosCache> SliceCache;
 
        /// A map from MathArray to position on the screen
-       CoordCacheBase<MathArray> & arrays() { BOOST_ASSERT(updating); return arrays_; }
+       CoordCacheBase<MathArray> & arrays() { return arrays_; }
        CoordCacheBase<MathArray> const & getArrays() const { return arrays_; }
        /// A map from insets to positions on the screen
-       CoordCacheBase<InsetBase> & insets() { BOOST_ASSERT(updating); return insets_; }
+       CoordCacheBase<InsetBase> & insets() { return insets_; }
        CoordCacheBase<InsetBase> const & getInsets() const { return insets_; }
        /// A map from (LyXText, paragraph) pair to screen positions
-       ParPosCache & parPos() { BOOST_ASSERT(updating); return pars_; }
+       ParPosCache & parPos() { return pars_; }
        ParPosCache const & getParPos() const { return pars_; }
+       ///
+       SliceCache & slice(bool boundary)
+       {
+               return boundary ? slices1_ : slices0_;
+       }
+       SliceCache const & getSlice(bool boundary) const
+       {
+               return boundary ? slices1_ : slices0_;
+       }
+
 private:
+       /// MathArrays
        CoordCacheBase<MathArray> arrays_;
-       
-       // all insets
+       // All insets
        CoordCacheBase<InsetBase> insets_;
-
-       // paragraph grouped by owning text
+       /// Paragraph grouped by owning text
        ParPosCache pars_;
-
-       /**
-        * Debugging flag only: Set to true while the cache is being built.
-        * No changes to the structure are allowed unless we are updating.
-        */
-       bool updating;
+       /// Used with boundary == 0
+       SliceCache slices0_;
+       /// Used with boundary == 1
+       SliceCache slices1_;
 };
 
 extern CoordCache theCoords;