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"
17 #include <boost/utility.hpp>
28 * The class holds all all open buffers, and handles construction
29 * and deletions of new ones.
31 class BufferList : boost::noncopyable {
33 typedef std::vector<Buffer *>::iterator iterator;
34 typedef std::vector<Buffer *>::const_iterator const_iterator;
40 const_iterator begin() const;
43 const_iterator end() const;
45 /// write all buffers, asking the user, returns false if cancelled
48 /// create a new buffer
49 Buffer * newBuffer(std::string const & s, bool ronly = false);
52 void release(Buffer * b);
54 /// Close all open buffers.
57 /// returns a vector with all the buffers filenames
58 std::vector<std::string> const getFileNames() const;
61 void updateIncludedTeXfiles(std::string const &, OutputParams const &);
63 /// emergency save for all buffers
64 void emergencyWriteAll();
66 /// close buffer. Returns false if cancelled by user
67 bool close(Buffer * buf, bool ask);
69 /// return true if no buffers loaded
72 /// return head of buffer list if any
75 /// return back of buffer list if any
78 /// returns true if the buffer exists already
79 bool exists(std::string const &) const;
81 /// returns true if the buffer is loaded
82 bool isLoaded(Buffer const * b) const;
84 /// returns a pointer to the buffer with the given name.
85 Buffer * getBuffer(std::string const &);
86 /// returns a pointer to the buffer with the given number.
87 Buffer * getBuffer(unsigned int);
88 /// returns a pointer to the buffer whose temppath matches the string
89 Buffer * getBufferFromTmp(std::string const &);
91 /** returns a pointer to the buffer that follows argument in
92 * buffer list. The buffer following the last in list is the
95 Buffer * next(Buffer const *) const;
97 /** returns a pointer to the buffer that precedes argument in
98 * buffer list. The buffer preceding the first in list is the
101 Buffer * previous(Buffer const *) const;
103 /// reset current author for all buffers
104 void setCurrentAuthor(docstring const & name, docstring const & email);
107 /// ask to save a buffer on quit, returns false if should cancel
108 bool quitWriteBuffer(Buffer * buf);
110 typedef std::vector<Buffer *> BufferStorage;
112 /// storage of all buffers
113 BufferStorage bstore;
115 /// save emergency file for the given buffer
116 void emergencyWrite(Buffer * buf);
119 /// Implementation is in LyX.cpp
120 extern BufferList & theBufferList();
125 #endif // BUFFERLIST_H