This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / bufferlist.h
blob093871714caa16a2ad2a0da7d32b452e9184c29f
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4 *
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-1999 The LyX Team
9 * This file is Copyright 1996
10 * Lars Gullik Bjønnes
12 * ======================================================*/
14 #ifndef BUFFER_LIST_H
15 #define BUFFER_LIST_H
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
21 #include "buffer.h"
22 #include "debug.h"
24 /** A class to hold all the buffers in a structure
25 The point of this class is to hide from bufferlist what kind
26 of structure the buffers are stored in. Should be no concern for
27 bufferlist if the buffers is in a array or in a linked list.
29 This class should ideally be enclosed inside class BufferList, but that
30 gave me an "internal gcc error".
32 class BufferStorage {
33 public:
34 ///
35 BufferStorage();
36 ///
37 bool isEmpty();
38 ///
39 void release(Buffer* buf);
40 ///
41 Buffer* newBuffer(string const &s, LyXRC *, bool =false);
42 private:
43 enum {
44 /** The max number of buffers there are possible to have
45 loaded at the same time. (this only applies when we use an
46 array)
48 NUMBER_OF_BUFFERS = 50
51 /** The Bufferlist is currently implemented as a static array.
52 The buffers are new'ed and deleted as reqested.
54 Buffer *buffer[NUMBER_OF_BUFFERS];
55 ///
56 friend class BufferStorage_Iter;
59 /// An Iterator class for BufferStorage
60 class BufferStorage_Iter {
61 public:
62 ///
63 BufferStorage_Iter(BufferStorage const & bs)
64 { cs =& bs; index = 0;}
65 /// next
66 Buffer* operator() ();
67 ///
68 Buffer* operator[] (int a);
69 private:
70 ///
71 const BufferStorage *cs;
72 ///
73 unsigned char index;
78 /** The class governing all the open buffers
79 This class governs all the currently open buffers. Currently all the buffer
80 are located in a static array, soon this will change and we will have a
81 linked list instead.
83 class BufferList {
84 public:
85 ///
86 BufferList();
88 ///
89 ~BufferList();
91 /// state info
92 enum list_state {
93 ///
94 OK,
95 ///
96 CLOSING
99 /// returns the state of the bufferlist
100 list_state getState() { return _state; }
102 /** loads a LyX file or...
103 If the optional argument tolastfiles is false (default is
104 true), the file name will not be added to the last opened
105 files list
107 Buffer* loadLyXFile(string const & filename,
108 bool tolastfiles = true);
111 bool isEmpty();
113 /// Saves buffer. Returns false if unsuccesful.
114 bool write(Buffer *, bool makeBackup = true);
117 bool QwriteAll();
119 /// Close all open buffers.
120 void closeAll();
123 void resize();
125 /// Read a file into a buffer readonly or not.
126 Buffer* readFile(string const &, bool ro);
128 /// Make a new file (buffer) using a template
129 Buffer* newFile(string const &, string);
131 /** This one must be moved to some other place.
133 void makePup(int);
135 ///** Later with multiple frames this should not be here.
136 // */
137 //Buffer* switchBuffer(Buffer *from, int);
140 void updateInset(Inset*, bool = true);
143 int unlockInset(UpdatableInset*);
146 void updateIncludedTeXfiles(string const &);
149 void emergencyWriteAll();
151 /** closes buffer
152 Returns false if operation was canceled
154 bool close(Buffer *);
157 Buffer* first();
159 /// returns true if the buffer exists already
160 bool exists(string const &);
162 /// returns a pointer to the buffer with the given name.
163 Buffer* getBuffer(string const &);
164 /// returns a pointer to the buffer with the given number.
165 Buffer* getBuffer(int);
167 private:
169 BufferStorage bstore;
172 list_state _state;
175 #endif