]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
"Inter-word Space"
[lyx.git] / src / bufferlist.h
1 // -*- C++ -*-
2 /**
3  * \file bufferlist.C
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 "LString.h"
16
17 #include <boost/utility.hpp>
18
19 #include <vector>
20
21 class Buffer;
22 class LatexRunParams;
23
24 /**
25  * The class holds all all open buffers, and handles construction
26  * and deletions of new ones.
27  */
28 class BufferList : boost::noncopyable {
29 public:
30         BufferList();
31
32         /**
33            Loads a LyX file or...
34
35            \param filename The filename to read from.
36            \param tolastfiles Wether the file should be put in the
37            last opened files list or not.
38            \return The newly loaded LyX file.
39         */
40         Buffer * loadLyXFile(string const & filename,
41                              bool tolastfiles = true);
42
43         /// write all buffers, asking the user, returns false if cancelled
44         bool quitWriteAll();
45
46         /// create a new buffer
47         Buffer * newBuffer(string const & s, bool ronly = false);
48
49         /// delete a buffer
50         void release(Buffer * b);
51
52         /// Close all open buffers.
53         void closeAll();
54
55         /// read the given file
56         Buffer * readFile(string const &, bool ro);
57
58         /// Make a new file (buffer) using a template
59         Buffer * newFile(string const &, string, bool isNamed = false);
60         /// returns a vector with all the buffers filenames
61         std::vector<string> const getFileNames() const;
62
63         /// FIXME
64         void updateIncludedTeXfiles(string const &, LatexRunParams const &);
65
66         /// emergency save for all buffers
67         void emergencyWriteAll();
68
69         /// close buffer. Returns false if cancelled by user
70         bool close(Buffer * buf, bool ask);
71
72         /// return true if no buffers loaded
73         bool empty() const;
74
75         /// return head of buffer list if any
76         Buffer * first();
77
78         /// returns true if the buffer exists already
79         bool exists(string const &) const;
80
81         /// returns true if the buffer is loaded
82         bool isLoaded(Buffer const * b) const;
83
84         /// returns a pointer to the buffer with the given name.
85         Buffer * getBuffer(string const &);
86         /// returns a pointer to the buffer with the given number.
87         Buffer * getBuffer(unsigned int);
88
89         /// reset current author for all buffers
90         void setCurrentAuthor(string const & name, 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 #endif // BUFFERLIST_H