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"
16 #include "bufferlist.h"
28 extern BufferList bufferlist;
34 text_fits(Buffer * b, int p)
36 bool operator()(TextCache::value_type const & vt) const {
37 if (vt.first == buf && vt.second.first == pw)
49 show_text(ostream & o) : os(o) {}
50 void operator()(TextCache::value_type const & vt) {
51 os << "\tBuffer: " << vt.first
52 << "\tWidth: " << vt.second.first << endl;
61 void operator()(TextCache::value_type & vt) {
62 delete vt.second.second;
69 LyXText * TextCache::findFit(Buffer * b, int p)
71 Cache::iterator it = find_if(cache.begin(), cache.end(),
73 if (it != cache.end()) {
74 LyXText * tmp = it->second.second;
82 void TextCache::show(ostream & os, string const & str)
84 os << "TextCache: " << str << endl;
85 for_each(cache.begin(), cache.end(), show_text(os));
89 void TextCache::show(ostream & os, TextCache::value_type const & vt)
96 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
98 lyxerr[Debug::INFO] << "TextCache::add " << text;
99 if (bufferlist.isLoaded(buf)) {
100 cache[buf] = make_pair(workwidth, text);
101 lyxerr[Debug::INFO] << " added" << endl;
104 lyxerr[Debug::INFO] << " deleted" << endl;
109 void TextCache::clear()
111 for_each(cache.begin(), cache.end(), delete_text());
116 void TextCache::removeAllWithBuffer(Buffer * buf)