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);
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 /// \return index of named buffer in buffer list
88 int bufferNum(support::FileName const & name) const;
90 /** returns a pointer to the buffer with the given name
93 * If true, the buffer is searched also among internal buffers
95 Buffer * getBuffer(support::FileName const & name, bool internal = false) const;
97 /// \return a pointer to the buffer with the given number
98 Buffer * getBuffer(unsigned int);
100 /// \return a pointer to the buffer whose temppath matches the given path
101 Buffer * getBufferFromTmp(std::string const & path);
103 /** returns a pointer to the buffer that follows argument in
104 * buffer list. The buffer following the last in list is the
107 Buffer * next(Buffer const *) const;
109 /** returns a pointer to the buffer that precedes argument in
110 * buffer list. The buffer preceding the first in list is the
113 Buffer * previous(Buffer const *) const;
115 /// \name Functions that just operate on all buffers
117 /// reset current author for all buffers
118 void recordCurrentAuthor(Author const & author);
119 /// update previews for all buffers, e.g. for Prefs update
120 void updatePreviews();
121 /// Call changed() on all buffers, internal or not
122 void changed(bool update_metrics) const;
123 /// emergency save for all buffers
124 void emergencyWriteAll();
126 void updateIncludedTeXfiles(std::string const &, OutputParams const &);
128 void invalidateConverterCache() const;
132 /// create a new buffer
133 /// \return 0 if the Buffer creation is not possible for whatever reason.
134 Buffer * createNewBuffer(std::string const & s);
137 BufferList(BufferList const &);
138 void operator=(BufferList const &);
140 typedef std::vector<Buffer *> BufferStorage;
142 /// storage of all buffers
143 BufferStorage bstore;
144 /// storage of all internal buffers used for cut&paste, etc.
145 BufferStorage binternal;
148 /// Implementation is in LyX.cpp
149 extern BufferList & theBufferList();
154 #endif // BUFFERLIST_H