1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-03-29 07:09:13 +00:00
|
|
|
|
/**
|
2003-06-28 01:23:11 +00:00
|
|
|
|
* \file bufferlist.h
|
2003-03-29 07:09:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
1999-10-07 18:44:17 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-29 07:09:13 +00:00
|
|
|
|
*/
|
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
|
|
|
|
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-07 06:45:25 +00:00
|
|
|
|
#include <string>
|
2002-03-12 17:15:44 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2002-03-12 17:15:44 +00:00
|
|
|
|
class Buffer;
|
2003-11-05 12:06:20 +00:00
|
|
|
|
class OutputParams;
|
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
|
|
|
|
|
2003-03-29 07:09:13 +00:00
|
|
|
|
/// write all buffers, asking the user, returns false if cancelled
|
|
|
|
|
bool quitWriteAll();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// create a new buffer
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Buffer * newBuffer(std::string const & s, bool ronly = false);
|
2003-02-15 19:21:11 +00:00
|
|
|
|
|
|
|
|
|
/// delete a buffer
|
|
|
|
|
void release(Buffer * b);
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// Close all open buffers.
|
|
|
|
|
void closeAll();
|
|
|
|
|
|
2000-01-20 01:41:55 +00:00
|
|
|
|
/// returns a vector with all the buffers filenames
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::vector<std::string> const getFileNames() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// FIXME
|
2003-11-05 12:06:20 +00:00
|
|
|
|
void updateIncludedTeXfiles(std::string const &, OutputParams 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
|
2003-03-29 07:09:13 +00:00
|
|
|
|
bool close(Buffer * buf, bool ask);
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool exists(std::string const &) const;
|
2000-02-03 17:09:33 +00:00
|
|
|
|
|
|
|
|
|
/// 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.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Buffer * getBuffer(std::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-10-14 11:35:50 +00:00
|
|
|
|
/// returns a pointer to the buffer whose temppath matches the string
|
2006-01-01 20:28:05 +00:00
|
|
|
|
Buffer * getBufferFromTmp(std::string const &);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2004-10-22 10:24:55 +00:00
|
|
|
|
/** returns a pointer to the buffer that follows argument in
|
|
|
|
|
* buffer list. The buffer following the last in list is the
|
|
|
|
|
* first one.
|
|
|
|
|
*/
|
|
|
|
|
Buffer * next(Buffer const *) const;
|
|
|
|
|
|
|
|
|
|
/** returns a pointer to the buffer that precedes argument in
|
|
|
|
|
* buffer list. The buffer preceding the first in list is the
|
|
|
|
|
* last one.
|
|
|
|
|
*/
|
|
|
|
|
Buffer * previous(Buffer const *) const;
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// reset current author for all buffers
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void setCurrentAuthor(std::string const & name, std::string const & email);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2003-03-29 07:09:13 +00:00
|
|
|
|
/// ask to save a buffer on quit, returns false if should cancel
|
|
|
|
|
bool quitWriteBuffer(Buffer * buf);
|
2001-11-26 10:19:58 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
typedef std::vector<Buffer *> BufferStorage;
|
2003-03-02 12:16:00 +00:00
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
/// 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
|
|
|
|
};
|
|
|
|
|
|
2006-10-14 19:58:42 +00:00
|
|
|
|
/// Implementation is in lyx_main.C
|
2006-10-11 17:24:46 +00:00
|
|
|
|
extern BufferList & theBufferList();
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
|
#endif // BUFFERLIST_H
|