1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2001 The LyX Team
8 * This file is Copyright 2000-2001
11 * ====================================================== */
16 #pragma implementation
21 #include "TextCache.h"
23 #include "bufferlist.h"
33 extern BufferList bufferlist;
39 text_fits(Buffer * b, int p)
41 bool operator()(TextCache::value_type const & vt) const {
42 if (vt.first == buf && vt.second.first == pw)
54 show_text(ostream & o) : os(o) {}
55 void operator()(TextCache::value_type const & vt) {
56 os << "\tBuffer: " << vt.first
57 << "\tWidth: " << vt.second.first << endl;
66 void operator()(TextCache::value_type & vt) {
67 delete vt.second.second;
74 LyXText * TextCache::findFit(Buffer * b, int p)
76 Cache::iterator it = find_if(cache.begin(), cache.end(),
78 if (it != cache.end()) {
79 LyXText * tmp = it->second.second;
87 void TextCache::show(ostream & os, string const & str)
89 os << "TextCache: " << str << endl;
90 for_each(cache.begin(), cache.end(), show_text(os));
94 void TextCache::show(ostream & os, TextCache::value_type const & vt)
101 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
103 lyxerr[Debug::INFO] << "TextCache::add " << text;
104 if (bufferlist.isLoaded(buf)) {
105 cache[buf] = make_pair(workwidth, text);
106 lyxerr[Debug::INFO] << " added" << endl;
109 lyxerr[Debug::INFO] << " deleted" << endl;
114 void TextCache::clear()
116 for_each(cache.begin(), cache.end(), delete_text());
121 void TextCache::removeAllWithBuffer(Buffer * buf)