2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
6 * Copyright (C) 1995 Matthias Ettrich
8 * This file is Copyleft (C) 1996
11 *======================================================*/
13 #ifndef _BUFFER_LIST_H_
14 #define _BUFFER_LIST_H_
23 /** A class to hold all the buffers in a structure
24 The point of this class is to hide from bufferlist what kind
25 of structure the buffers are stored in. Should be no concern for
26 bufferlist if the buffers is in a array or in a linked list.
28 This class should ideally be enclosed inside class BufferList, but that
29 gave me an "internal gcc error".
38 void release(Buffer* buf);
40 Buffer* newBuffer(LString const &s, LyXRC *, bool =false);
43 /** The max number of buffers there are possible to have
44 loaded at the same time. (this only applies when we use an
47 NUMBER_OF_BUFFERS = 50
50 /** The Bufferlist is currently implemented as a static array.
51 The buffers are new'ed and deleted as reqested.
53 Buffer *buffer[NUMBER_OF_BUFFERS];
55 friend class BufferStorage_Iter;
58 /// An Iterator class for BufferStorage
59 class BufferStorage_Iter {
62 BufferStorage_Iter(const BufferStorage & bs)
65 Buffer* operator() ();
67 Buffer* operator[] (int a);
70 const BufferStorage *cs;
77 /** The class governing all the open buffers
78 This class governs all the currently open buffers. Currently all the buffer
79 are located in a static array, soon this will change and we will have a
98 /// returns the state of the bufferlist
99 list_state getState() { return _state; }
101 /** loads a LyX file or...
102 If the optional argument tolastfiles is false (default is
103 true), the file name will not be added to the last opened
106 Buffer* loadLyXFile(LString const & filename,
107 bool tolastfiles = true);
112 /// Saves buffer. Returns false if unsuccesful.
113 bool write(Buffer *, bool makeBackup = true);
118 /// Close all open buffers.
124 /// Read a file into a buffer readonly or not.
125 Buffer* readFile(LString const &, bool ro);
127 /// Make a new file (buffer) using a template
128 Buffer* newFile(LString const &, LString);
130 /** This one must be moved to some other place.
134 ///** Later with multiple frames this should not be here.
136 //Buffer* switchBuffer(Buffer *from, int);
139 void updateInset(Inset*, bool = true);
142 int unlockInset(UpdatableInset*);
145 void updateIncludedTeXfiles(LString const &);
148 void emergencyWriteAll();
151 Returns false if operation was canceled
153 bool close(Buffer *);
158 /// returns true if the buffer exists already
159 bool exists(LString const &);
161 /// returns a pointer to the buffer with the given name.
162 Buffer* getBuffer(LString const &);
163 /// returns a pointer to the buffer with the given number.
164 Buffer* getBuffer(int);
168 BufferStorage bstore;