1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-03-12 17:15:44 +00:00
|
|
|
|
/** \file
|
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
1999-10-07 18:44:17 +00:00
|
|
|
|
*
|
2002-03-12 17:15:44 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#ifndef BUFFER_LIST_H
|
|
|
|
|
#define BUFFER_LIST_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-12 17:15:44 +00:00
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-12 17:15:44 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
class Buffer;
|
1999-11-05 06:02:34 +00:00
|
|
|
|
|
2002-03-12 17:15:44 +00:00
|
|
|
|
/**
|
2003-02-15 19:21:11 +00:00
|
|
|
|
* The class holds all all open buffers, and handles construction
|
|
|
|
|
* and deletions of new ones.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
2001-04-17 15:15:59 +00:00
|
|
|
|
class BufferList : boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
BufferList();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-12 17:15:44 +00:00
|
|
|
|
/**
|
|
|
|
|
Loads a LyX file or...
|
|
|
|
|
|
|
|
|
|
\param filename The filename to read from.
|
|
|
|
|
\param tolastfiles Wether the file should be put in the
|
|
|
|
|
last opened files list or not.
|
|
|
|
|
\return The newly loaded LyX file.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
|
|
|
|
Buffer * loadLyXFile(string const & filename,
|
1999-11-05 06:02:34 +00:00
|
|
|
|
bool tolastfiles = true);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// write all buffers, asking the user
|
2002-03-21 17:27:08 +00:00
|
|
|
|
bool qwriteAll();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// create a new buffer
|
|
|
|
|
Buffer * newBuffer(string const & s, bool ronly = false);
|
|
|
|
|
|
|
|
|
|
/// delete a buffer
|
|
|
|
|
void release(Buffer * b);
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// Close all open buffers.
|
|
|
|
|
void closeAll();
|
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// read the given file
|
1999-11-05 06:02:34 +00:00
|
|
|
|
Buffer * readFile(string const &, bool ro);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// Make a new file (buffer) using a template
|
2001-04-24 15:25:26 +00:00
|
|
|
|
Buffer * newFile(string const &, string, bool isNamed = false);
|
2000-01-20 01:41:55 +00:00
|
|
|
|
/// returns a vector with all the buffers filenames
|
2000-09-14 17:53:12 +00:00
|
|
|
|
std::vector<string> const getFileNames() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// FIXME
|
1999-10-02 16:21:10 +00:00
|
|
|
|
void updateIncludedTeXfiles(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// emergency save for all buffers
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void emergencyWriteAll();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// close buffer. Returns false if cancelled by user
|
2000-08-07 20:58:24 +00:00
|
|
|
|
bool close(Buffer * buf);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// return true if no buffers loaded
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
|
|
|
|
/// return head of buffer list if any
|
1999-11-05 06:02:34 +00:00
|
|
|
|
Buffer * first();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// returns true if the buffer exists already
|
2000-02-03 17:09:33 +00:00
|
|
|
|
bool exists(string const &) const;
|
|
|
|
|
|
|
|
|
|
/// returns true if the buffer is loaded
|
|
|
|
|
bool isLoaded(Buffer const * b) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// returns a pointer to the buffer with the given name.
|
1999-11-05 06:02:34 +00:00
|
|
|
|
Buffer * getBuffer(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// returns a pointer to the buffer with the given number.
|
2000-10-11 21:06:43 +00:00
|
|
|
|
Buffer * getBuffer(unsigned int);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
|
|
|
|
/// reset current author for all buffers
|
|
|
|
|
void setCurrentAuthor(string const & name, string const & email);
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2001-11-26 10:19:58 +00:00
|
|
|
|
/// ask to save a buffer on quit
|
2002-03-12 17:15:44 +00:00
|
|
|
|
bool qwriteOne(Buffer * buf, string const & fname,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
string & unsaved_list);
|
2001-11-26 10:19:58 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
typedef std::vector<Buffer *> BufferStorage;
|
|
|
|
|
|
|
|
|
|
/// storage of all buffers
|
1999-09-27 18:44:28 +00:00
|
|
|
|
BufferStorage bstore;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// save emergency file for the given buffer
|
2000-10-11 21:06:43 +00:00
|
|
|
|
void emergencyWrite(Buffer * buf);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
#endif // BUFFERLIST_H
|