]> git.lyx.org Git - lyx.git/blob - src/BufferList.h
Update cursor and scrollbar after resize.
[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 "support/docstring.h"
16
17 #include <vector>
18
19
20 namespace lyx {
21
22 class Buffer;
23 class OutputParams;
24
25 /**
26  * The class holds all all open buffers, and handles construction
27  * and deletions of new ones.
28  */
29 class BufferList {
30 public:
31         typedef std::vector<Buffer *>::iterator iterator;
32         typedef std::vector<Buffer *>::const_iterator const_iterator;
33
34 public:
35         BufferList();
36
37         iterator begin();
38         const_iterator begin() const;
39
40         iterator end();
41         const_iterator end() const;
42
43         /// create a new buffer
44         /// \return 0 if the Buffer creation is not possible for whatever reason.
45         Buffer * newBuffer(std::string const & s, bool ronly = false);
46
47         /// delete a buffer
48         void release(Buffer * b);
49
50         /// Close all open buffers.
51         void closeAll();
52
53         /// returns a vector with all the buffers filenames
54         std::vector<std::string> const getFileNames() const;
55
56         /// FIXME
57         void updateIncludedTeXfiles(std::string const &, OutputParams const &);
58
59         /// emergency save for all buffers
60         void emergencyWriteAll();
61
62         /// return true if no buffers loaded
63         bool empty() const;
64
65         /// return head of buffer list if any
66         Buffer * first();
67
68         /// return back of buffer list if any
69         Buffer * last();
70
71         /// returns true if the buffer exists already
72         bool exists(std::string const &) const;
73
74         /// returns true if the buffer is loaded
75         bool isLoaded(Buffer const * b) const;
76
77         /// return index of named buffer in buffer list
78         int bufferNum(std::string const & name) const;
79         /// returns a pointer to the buffer with the given name.
80         Buffer * getBuffer(std::string const &);
81         /// returns a pointer to the buffer with the given number.
82         Buffer * getBuffer(unsigned int);
83         /// returns a pointer to the buffer whose temppath matches the string
84         Buffer * getBufferFromTmp(std::string const &);
85
86         /** returns a pointer to the buffer that follows argument in
87          * buffer list. The buffer following the last in list is the
88          * first one.
89          */
90         Buffer * next(Buffer const *) const;
91
92         /** returns a pointer to the buffer that precedes argument in
93          * buffer list. The buffer preceding the first in list is the
94          * last one.
95          */
96         Buffer * previous(Buffer const *) const;
97
98         /// reset current author for all buffers
99         void setCurrentAuthor(docstring const & name, docstring const & email);
100
101 private:
102         /// noncopiable
103         BufferList(BufferList const &);
104         void operator=(BufferList const &);
105
106         typedef std::vector<Buffer *> BufferStorage;
107
108         /// storage of all buffers
109         BufferStorage bstore;
110
111         /// save emergency file for the given buffer
112         void emergencyWrite(Buffer * buf);
113 };
114
115 /// Implementation is in LyX.cpp
116 extern BufferList & theBufferList();
117
118
119 } // namespace lyx
120
121 #endif // BUFFERLIST_H