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"
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);
59 void release(Buffer * b);
61 /// Release \p child if it really is a child and is not used elsewhere.
62 /// \return true is the file was closed.
63 bool releaseChild(Buffer * parent, Buffer * child);
65 /// Close all open buffers.
68 /// returns a vector with all the buffers filenames
69 support::FileNameList fileNames() const;
71 /// return true if no buffers loaded
74 /// return head of buffer list if any
77 /// return back of buffer list if any
80 /// returns true if the buffer exists already
81 bool exists(support::FileName const &) const;
83 /// returns true if the buffer is loaded
84 bool isLoaded(Buffer const * b) const;
86 /// \return index of named buffer in buffer list
87 int bufferNum(support::FileName const & name) const;
89 /** returns a pointer to the buffer with the given name
92 * If true, the buffer is searched also among internal buffers
94 Buffer * getBuffer(support::FileName const & name, bool internal = false) const;
96 /// \return a pointer to the buffer with the given number
97 Buffer * getBuffer(unsigned int);
99 /// \return a pointer to the buffer whose temppath matches the given path
100 Buffer * getBufferFromTmp(std::string const & path);
102 /** returns a pointer to the buffer that follows argument in
103 * buffer list. The buffer following the last in list is the
106 Buffer * next(Buffer const *) const;
108 /** returns a pointer to the buffer that precedes argument in
109 * buffer list. The buffer preceding the first in list is the
112 Buffer * previous(Buffer const *) const;
114 /// \name Functions that just operate on all buffers
116 /// reset current author for all buffers
117 void recordCurrentAuthor(Author const & author);
118 /// update previews for all buffers, e.g. for Prefs update
119 void updatePreviews();
120 /// Call changed() on all buffers, internal or not
121 void changed(bool update_metrics) const;
122 /// emergency save for all buffers
123 void emergencyWriteAll();
125 void updateIncludedTeXfiles(std::string const &, OutputParams const &);
129 /// create a new buffer
130 /// \return 0 if the Buffer creation is not possible for whatever reason.
131 Buffer * createNewBuffer(std::string const & s);
134 BufferList(BufferList const &);
135 void operator=(BufferList const &);
137 typedef std::vector<Buffer *> BufferStorage;
139 /// storage of all buffers
140 BufferStorage bstore;
141 /// storage of all internal buffers used for cut&paste, etc.
142 BufferStorage binternal;
145 /// Implementation is in LyX.cpp
146 extern BufferList & theBufferList();
151 #endif // BUFFERLIST_H