]> git.lyx.org Git - lyx.git/blob - src/bufferlist.h
(Jo�o Assirati): add the ability to inverse-search a dvi file.
[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 class Buffer;
21 class LatexRunParams;
22
23 /**
24  * The class holds all all open buffers, and handles construction
25  * and deletions of new ones.
26  */
27 class BufferList : boost::noncopyable {
28 public:
29         BufferList();
30
31         /// write all buffers, asking the user, returns false if cancelled
32         bool quitWriteAll();
33
34         /// create a new buffer
35         Buffer * newBuffer(std::string const & s, bool ronly = false);
36
37         /// delete a buffer
38         void release(Buffer * b);
39
40         /// Close all open buffers.
41         void closeAll();
42
43         /// returns a vector with all the buffers filenames
44         std::vector<std::string> const getFileNames() const;
45
46         /// FIXME
47         void updateIncludedTeXfiles(std::string const &, LatexRunParams const &);
48
49         /// emergency save for all buffers
50         void emergencyWriteAll();
51
52         /// close buffer. Returns false if cancelled by user
53         bool close(Buffer * buf, bool ask);
54
55         /// return true if no buffers loaded
56         bool empty() const;
57
58         /// return head of buffer list if any
59         Buffer * first();
60
61         /// returns true if the buffer exists already
62         bool exists(std::string const &) const;
63
64         /// returns true if the buffer is loaded
65         bool isLoaded(Buffer const * b) const;
66
67         /// returns a pointer to the buffer with the given name.
68         Buffer * getBuffer(std::string const &);
69         /// returns a pointer to the buffer with the given number.
70         Buffer * getBuffer(unsigned int);
71         /// returns a pointer to the buffer whose temppath matches the string
72         Buffer * BufferList::getBufferFromTmp(std::string const &);
73
74         /// reset current author for all buffers
75         void setCurrentAuthor(std::string const & name, std::string const & email);
76
77 private:
78         /// ask to save a buffer on quit, returns false if should cancel
79         bool quitWriteBuffer(Buffer * buf);
80
81         typedef std::vector<Buffer *> BufferStorage;
82
83         /// storage of all buffers
84         BufferStorage bstore;
85
86         /// save emergency file for the given buffer
87         void emergencyWrite(Buffer * buf);
88 };
89
90 #endif // BUFFERLIST_H