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 * ====================================================== */
15 #include "TextCache.h"
18 #include "bufferlist.h"
30 extern BufferList bufferlist;
36 text_fits(Buffer * b, int p)
38 bool operator()(TextCache::value_type const & vt) const {
39 if (vt.first == buf && vt.second.first == pw)
51 show_text(ostream & o) : os(o) {}
52 void operator()(TextCache::value_type const & vt) {
53 os << "\tBuffer: " << vt.first
54 << "\tWidth: " << vt.second.first << endl;
63 void operator()(TextCache::value_type & vt) {
64 delete vt.second.second;
71 LyXText * TextCache::findFit(Buffer * b, int p)
73 Cache::iterator it = find_if(cache.begin(), cache.end(),
75 if (it != cache.end()) {
76 LyXText * tmp = it->second.second;
84 void TextCache::show(ostream & os, string const & str)
86 os << "TextCache: " << str << endl;
87 for_each(cache.begin(), cache.end(), show_text(os));
91 void TextCache::show(ostream & os, TextCache::value_type const & vt)
98 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
100 lyxerr[Debug::INFO] << "TextCache::add " << text;
101 if (bufferlist.isLoaded(buf)) {
102 cache[buf] = make_pair(workwidth, text);
103 lyxerr[Debug::INFO] << " added" << endl;
106 lyxerr[Debug::INFO] << " deleted" << endl;
111 void TextCache::clear()
113 for_each(cache.begin(), cache.end(), delete_text());
118 void TextCache::removeAllWithBuffer(Buffer * buf)