3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "TextCache.h"
15 #include "bufferlist.h"
27 extern BufferList bufferlist;
33 text_fits(Buffer * b, int p)
35 bool operator()(TextCache::value_type const & vt) const {
36 if (vt.first == buf && vt.second.first == pw)
48 show_text(ostream & o) : os(o) {}
49 void operator()(TextCache::value_type const & vt) {
50 os << "\tBuffer: " << vt.first
51 << "\tWidth: " << vt.second.first << endl;
60 void operator()(TextCache::value_type & vt) {
61 delete vt.second.second;
68 LyXText * TextCache::findFit(Buffer * b, int p)
70 Cache::iterator it = find_if(cache.begin(), cache.end(),
72 if (it != cache.end()) {
73 LyXText * tmp = it->second.second;
81 void TextCache::show(ostream & os, string const & str)
83 os << "TextCache: " << str << endl;
84 for_each(cache.begin(), cache.end(), show_text(os));
88 void TextCache::show(ostream & os, TextCache::value_type const & vt)
95 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
97 lyxerr[Debug::INFO] << "TextCache::add " << text;
98 if (bufferlist.isLoaded(buf)) {
99 cache[buf] = make_pair(workwidth, text);
100 lyxerr[Debug::INFO] << " added" << endl;
103 lyxerr[Debug::INFO] << " deleted" << endl;
108 void TextCache::clear()
110 for_each(cache.begin(), cache.end(), delete_text());
115 void TextCache::removeAllWithBuffer(Buffer * buf)