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"
17 #include "bufferlist.h"
29 extern BufferList bufferlist;
35 text_fits(Buffer * b, int p)
37 bool operator()(TextCache::value_type const & vt) const {
38 if (vt.first == buf && vt.second.first == pw)
50 show_text(ostream & o) : os(o) {}
51 void operator()(TextCache::value_type const & vt) {
52 os << "\tBuffer: " << vt.first
53 << "\tWidth: " << vt.second.first << endl;
62 void operator()(TextCache::value_type & vt) {
63 delete vt.second.second;
70 LyXText * TextCache::findFit(Buffer * b, int p)
72 Cache::iterator it = find_if(cache.begin(), cache.end(),
74 if (it != cache.end()) {
75 LyXText * tmp = it->second.second;
83 void TextCache::show(ostream & os, string const & str)
85 os << "TextCache: " << str << endl;
86 for_each(cache.begin(), cache.end(), show_text(os));
90 void TextCache::show(ostream & os, TextCache::value_type const & vt)
97 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
99 lyxerr[Debug::INFO] << "TextCache::add " << text;
100 if (bufferlist.isLoaded(buf)) {
101 cache[buf] = make_pair(workwidth, text);
102 lyxerr[Debug::INFO] << " added" << endl;
105 lyxerr[Debug::INFO] << " deleted" << endl;
110 void TextCache::clear()
112 for_each(cache.begin(), cache.end(), delete_text());
117 void TextCache::removeAllWithBuffer(Buffer * buf)