]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
Document pasteParagraphList as hinted by Jean-Marc
[lyx.git] / src / bufferlist.h
1 // -*- C++ -*-
2 /**
3  * \file bufferlist.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BUFFER_LIST_H
13 #define BUFFER_LIST_H
14
15 #include <boost/utility.hpp>
16
17 #include <string>
18 #include <vector>
19
20
21 namespace lyx {
22
23 class Buffer;
24 class OutputParams;
25
26 /**
27  * The class holds all all open buffers, and handles construction
28  * and deletions of new ones.
29  */
30 class BufferList : boost::noncopyable {
31 public:
32         BufferList();
33
34         /// write all buffers, asking the user, returns false if cancelled
35         bool quitWriteAll();
36
37         /// create a new buffer
38         Buffer * newBuffer(std::string const & s, bool ronly = false);
39
40         /// delete a buffer
41         void release(Buffer * b);
42
43         /// Close all open buffers.
44         void closeAll();
45
46         /// returns a vector with all the buffers filenames
47         std::vector<std::string> const getFileNames() const;
48
49         /// FIXME
50         void updateIncludedTeXfiles(std::string const &, OutputParams const &);
51
52         /// emergency save for all buffers
53         void emergencyWriteAll();
54
55         /// close buffer. Returns false if cancelled by user
56         bool close(Buffer * buf, bool ask);
57
58         /// return true if no buffers loaded
59         bool empty() const;
60
61         /// return head of buffer list if any
62         Buffer * first();
63
64         /// returns true if the buffer exists already
65         bool exists(std::string const &) const;
66
67         /// returns true if the buffer is loaded
68         bool isLoaded(Buffer const * b) const;
69
70         /// returns a pointer to the buffer with the given name.
71         Buffer * getBuffer(std::string const &);
72         /// returns a pointer to the buffer with the given number.
73         Buffer * getBuffer(unsigned int);
74         /// returns a pointer to the buffer whose temppath matches the string
75         Buffer * getBufferFromTmp(std::string const &);
76
77         /** returns a pointer to the buffer that follows argument in
78          * buffer list. The buffer following the last in list is the
79          * first one.
80          */
81         Buffer * next(Buffer const *) const;
82
83         /** returns a pointer to the buffer that precedes argument in
84          * buffer list. The buffer preceding the first in list is the
85          * last one.
86          */
87         Buffer * previous(Buffer const *) const;
88
89         /// reset current author for all buffers
90         void setCurrentAuthor(std::string const & name, std::string const & email);
91
92 private:
93         /// ask to save a buffer on quit, returns false if should cancel
94         bool quitWriteBuffer(Buffer * buf);
95
96         typedef std::vector<Buffer *> BufferStorage;
97
98         /// storage of all buffers
99         BufferStorage bstore;
100
101         /// save emergency file for the given buffer
102         void emergencyWrite(Buffer * buf);
103 };
104
105 /// Implementation is in lyx_main.C
106 extern BufferList & theBufferList();
107
108
109 } // namespace lyx
110
111 #endif // BUFFERLIST_H