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 const & vt) const {
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;
74 void TextCache::show(ostream & os, string const & str)
76 os << "TextCache: " << str << endl;
77 for_each(cache.begin(), cache.end(), show_text(os));
81 void TextCache::show(ostream & os, TextCache::value_type const & vt)
88 void TextCache::add(Buffer * buf, int workwidth, LyXText * text)
90 lyxerr.debug() << "TextCache::add " << text;
91 if (bufferlist.isLoaded(buf)) {
92 cache[buf] = make_pair(workwidth, text);
93 lyxerr.debug() << " added" << endl;
96 lyxerr.debug() << " deleted" << endl;
103 void operator()(TextCache::value_type & vt) {
104 delete vt.second.second;
109 void TextCache::clear()
111 for_each(cache.begin(), cache.end(), delete_text());
118 has_buffer(Buffer * b)
120 bool operator()(TextCache::value_type const & vt) const{
121 if (vt.first == buf) return true;
129 void TextCache::removeAllWithBuffer(Buffer * buf)