]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
Point fix, earlier forgotten
[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 "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         /// write all buffers, asking the user, returns false if cancelled
33         bool quitWriteAll();
34
35         /// create a new buffer
36         Buffer * newBuffer(string const & s, bool ronly = false);
37
38         /// delete a buffer
39         void release(Buffer * b);
40
41         /// Close all open buffers.
42         void closeAll();
43
44         /// returns a vector with all the buffers filenames
45         std::vector<string> const getFileNames() const;
46
47         /// FIXME
48         void updateIncludedTeXfiles(string const &, LatexRunParams const &);
49
50         /// emergency save for all buffers
51         void emergencyWriteAll();
52
53         /// close buffer. Returns false if cancelled by user
54         bool close(Buffer * buf, bool ask);
55
56         /// return true if no buffers loaded
57         bool empty() const;
58
59         /// return head of buffer list if any
60         Buffer * first();
61
62         /// returns true if the buffer exists already
63         bool exists(string const &) const;
64
65         /// returns true if the buffer is loaded
66         bool isLoaded(Buffer const * b) const;
67
68         /// returns a pointer to the buffer with the given name.
69         Buffer * getBuffer(string const &);
70         /// returns a pointer to the buffer with the given number.
71         Buffer * getBuffer(unsigned int);
72
73         /// reset current author for all buffers
74         void setCurrentAuthor(string const & name, string const & email);
75
76 private:
77         /// ask to save a buffer on quit, returns false if should cancel
78         bool quitWriteBuffer(Buffer * buf);
79
80         typedef std::vector<Buffer *> BufferStorage;
81
82         /// storage of all buffers
83         BufferStorage bstore;
84
85         /// save emergency file for the given buffer
86         void emergencyWrite(Buffer * buf);
87 };
88
89 #endif // BUFFERLIST_H