4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
15 #include "support/docstring.h"
29 } // namespace support
32 * The class holds all all open buffers, and handles construction
33 * and deletions of new ones.
37 typedef std::vector<Buffer *>::iterator iterator;
38 typedef std::vector<Buffer *>::const_iterator const_iterator;
45 const_iterator begin() const;
48 const_iterator end() const;
50 /// create a new buffer and add it to the buffer list
51 /// \return 0 if the Buffer creation is not possible for whatever reason.
52 Buffer * newBuffer(std::string const & s);
54 /// create an internal buffer and add it to the internal buffer list
55 /// \return 0 if the Buffer creation is not possible for whatever reason.
56 Buffer * newInternalBuffer(std::string const & s);
58 /// Is child a child of some Buffer other than parent?
59 /// NOTE: child must be a child of parent, and both must be non-null.
60 /// Otherwise we assert.
61 bool isOthersChild(Buffer * parent, Buffer * child);
64 void release(Buffer * b);
66 /// Close all open buffers.
69 /// returns a vector with all the buffers filenames
70 support::FileNameList fileNames() const;
72 /// return true if no buffers loaded
75 /// return head of buffer list if any
78 /// return back of buffer list if any
81 /// returns true if the buffer exists already
82 bool exists(support::FileName const &) const;
84 /// returns true if the buffer is loaded
85 bool isLoaded(Buffer const * b) const;
87 /// returns true if the buffer is known as internal buffer
88 bool isInternal(Buffer const * b) const;
90 /// \return index of named buffer in buffer list
91 int bufferNum(support::FileName const & name) const;
93 /** returns a pointer to the buffer with the given name
96 * If true, the buffer is searched also among internal buffers
98 Buffer * getBuffer(support::FileName const & name, bool internal = false) const;
100 /// \return a pointer to the buffer with the given number
101 Buffer * getBuffer(unsigned int);
103 /// \return a pointer to the buffer whose temppath matches the given path
104 Buffer * getBufferFromTmp(std::string const & path);
106 /** returns a pointer to the buffer that follows argument in
107 * buffer list. The buffer following the last in list is the
110 Buffer * next(Buffer const *) const;
112 /** returns a pointer to the buffer that precedes argument in
113 * buffer list. The buffer preceding the first in list is the
116 Buffer * previous(Buffer const *) const;
118 /// \name Functions that just operate on all buffers
120 /// reset current author for all buffers
121 void recordCurrentAuthor(Author const & author);
122 /// update previews for all buffers, e.g. for Prefs update
123 void updatePreviews();
124 /// Call changed() on all buffers, internal or not
125 void changed(bool update_metrics) const;
126 /// emergency save for all buffers
127 void emergencyWriteAll();
129 void updateIncludedTeXfiles(std::string const &, OutputParams const &);
131 void invalidateConverterCache() const;
135 /// create a new buffer
136 /// \return 0 if the Buffer creation is not possible for whatever reason.
137 Buffer * createNewBuffer(std::string const & s);
140 BufferList(BufferList const &);
141 void operator=(BufferList const &);
143 typedef std::vector<Buffer *> BufferStorage;
145 /// storage of all buffers
146 BufferStorage bstore;
147 /// storage of all internal buffers used for cut&paste, etc.
148 BufferStorage binternal;
151 /// Implementation is in LyX.cpp
152 extern BufferList & theBufferList();
157 #endif // BUFFERLIST_H