]> git.lyx.org Git - lyx.git/blobdiff - src/TextCache.C
insetquote fix; getStatus tweaks
[lyx.git] / src / TextCache.C
index 5e11893eb98bda06fb8fd3a4e246c432b2a27139..6b3d9b4b832cecf651d6584cb91b968693ed618f 100644 (file)
@@ -3,9 +3,9 @@
  * 
  *           LyX, The Document Processor        
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team
+ *           Copyright 1995-2001 The LyX Team
  *
- *           This file is Copyright 2000
+ *           This file is Copyright 2000-2001
  *           Lars Gullik Bjønnes
  *
  * ====================================================== */
@@ -21,6 +21,7 @@
 #include "TextCache.h"
 #include "buffer.h"
 #include "bufferlist.h"
+#include "debug.h"
 
 using std::ostream;
 using std::for_each;
@@ -31,6 +32,8 @@ using std::make_pair;
 
 extern BufferList bufferlist;
 
+namespace {
+
 class text_fits {
 public:
        text_fits(Buffer * b, int p)
@@ -46,19 +49,6 @@ private:
 };
 
 
-LyXText * TextCache::findFit(Buffer * b, int p)
-{
-       Cache::iterator it = find_if(cache.begin(), cache.end(),
-                                    text_fits(b, p));
-       if (it != cache.end()) {
-               LyXText * tmp = (*it).second.second;
-               cache.erase(it);
-               return tmp;
-       }
-       return 0;
-}
-
-
 class show_text {
 public:
        show_text(ostream & o) : os(o) {}
@@ -71,6 +61,29 @@ private:
 };
 
 
+class delete_text {
+public:
+       void operator()(TextCache::value_type & vt) {
+               delete vt.second.second;
+       }
+};
+
+} // namespace anon
+
+
+LyXText * TextCache::findFit(Buffer * b, int p)
+{
+       Cache::iterator it = find_if(cache.begin(), cache.end(),
+                                    text_fits(b, p));
+       if (it != cache.end()) {
+               LyXText * tmp = it->second.second;
+               cache.erase(it);
+               return tmp;
+       }
+       return 0;
+}
+
+
 void TextCache::show(ostream & os, string const & str)
 {
        os << "TextCache: " << str << endl;
@@ -87,25 +100,17 @@ void TextCache::show(ostream & os, TextCache::value_type const & vt)
 
 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
 {
-       lyxerr.debug() << "TextCache::add " << text;
+       lyxerr[Debug::INFO] << "TextCache::add " << text;
        if (bufferlist.isLoaded(buf)) {
                cache[buf] = make_pair(workwidth, text);
-               lyxerr.debug() << " added" << endl;
+               lyxerr[Debug::INFO] << " added" << endl;
        } else {
                delete text;
-               lyxerr.debug() << " deleted" << endl;
+               lyxerr[Debug::INFO] << " deleted" << endl;
        }
 }
 
 
-class delete_text {
-public:
-       void operator()(TextCache::value_type & vt) {
-               delete vt.second.second;
-       }
-};
-
-
 void TextCache::clear()
 {
        for_each(cache.begin(), cache.end(), delete_text());
@@ -113,19 +118,6 @@ void TextCache::clear()
 }
 
 
-class has_buffer {
-public:
-       has_buffer(Buffer * b)
-               : buf(b) {}
-       bool operator()(TextCache::value_type const & vt) const{
-               if (vt.first == buf) return true;
-               return false;
-       }
-private:
-       Buffer const * buf;
-};
-
-
 void TextCache::removeAllWithBuffer(Buffer * buf)
 {
        cache.erase(buf);