1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2000 The LyX Team
8 * This file is Copyright 2000
11 * ====================================================== */
16 #pragma implementation
21 #include "TextCache.h"
23 #include "bufferlist.h"
32 extern BufferList bufferlist;
36 text_fits(Buffer * b, int p)
38 bool operator()(TextCache::value_type & vt) {
39 if (vt.first == buf && vt.second.first == pw)
49 LyXText * TextCache::findFit(Buffer * b, int p)
51 Cache::iterator it = find_if(cache.begin(), cache.end(),
53 if (it != cache.end()) {
54 LyXText * tmp = (*it).second.second;
64 show_text(ostream & o) : os(o) {}
65 void operator()(TextCache::value_type const & vt) {
66 os << "\tBuffer: " << vt.first
67 << "\tWidth: " << vt.second.first << endl;
73 void TextCache::show(ostream & os, string const & str)
75 os << "TextCache: " << str << endl;
76 for_each(cache.begin(), cache.end(), show_text(os));
80 void TextCache::show(ostream & os, TextCache::value_type const & vt)
87 void TextCache::add(Buffer *buf, int workwidth, LyXText * text)
89 lyxerr.debug() << "TextCache::add " << text;
90 if (bufferlist.isLoaded(buf)) {
91 cache[buf] = make_pair(workwidth, text);
92 lyxerr.debug() << " added" << endl;
95 lyxerr.debug() << " deleted" << endl;
102 void operator()(TextCache::value_type & vt) {
103 delete vt.second.second;
108 void TextCache::clear()
110 for_each(cache.begin(), cache.end(), delete_text());
117 has_buffer(Buffer * b)
119 bool operator()(TextCache::value_type & vt) {
120 if (vt.first == buf) return true;
128 void TextCache::removeAllWithBuffer(Buffer * buf)