1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-03-29 07:09:13 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjø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
|
|
|
|
2006-12-21 13:58:28 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
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
|
|
|
|
2008-07-29 07:53:08 +00:00
|
|
|
namespace support {
|
|
|
|
class FileName;
|
2008-07-29 08:52:25 +00:00
|
|
|
class FileNameList;
|
2008-07-29 07:53:08 +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
|
|
|
*/
|
2007-11-03 17:37:37 +00:00
|
|
|
class BufferList {
|
2006-11-26 16:39:39 +00:00
|
|
|
public:
|
|
|
|
typedef std::vector<Buffer *>::iterator iterator;
|
|
|
|
typedef std::vector<Buffer *>::const_iterator const_iterator;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2002-03-21 17:27:08 +00:00
|
|
|
BufferList();
|
2008-10-13 20:40:58 +00:00
|
|
|
~BufferList();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2006-11-26 16:39:39 +00:00
|
|
|
iterator begin();
|
|
|
|
const_iterator begin() const;
|
|
|
|
|
|
|
|
iterator end();
|
|
|
|
const_iterator end() const;
|
|
|
|
|
2003-02-15 19:21:11 +00:00
|
|
|
/// create a new buffer
|
2007-12-17 18:37:13 +00:00
|
|
|
/// \return 0 if the Buffer creation is not possible for whatever reason.
|
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
|
|
|
|
2008-07-20 17:52:55 +00:00
|
|
|
/// Release \p child if it really is a child and is not used elsewhere.
|
|
|
|
/// \return true is the file was closed.
|
|
|
|
bool releaseChild(Buffer * parent, Buffer * child);
|
|
|
|
|
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
|
2008-07-29 08:52:25 +00:00
|
|
|
support::FileNameList const & fileNames() 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
|
|
|
|
2008-02-29 08:10:51 +00:00
|
|
|
/// save emergency file for the given buffer
|
|
|
|
/**
|
|
|
|
* \return a status message towards the user.
|
|
|
|
*/
|
|
|
|
docstring emergencyWrite(Buffer * buf);
|
|
|
|
|
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
|
|
|
|
2006-11-26 15:47:45 +00:00
|
|
|
/// return back of buffer list if any
|
|
|
|
Buffer * last();
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// returns true if the buffer exists already
|
2008-07-29 07:53:08 +00:00
|
|
|
bool exists(support::FileName 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
|
|
|
|
2007-10-20 10:03:45 +00:00
|
|
|
/// return index of named buffer in buffer list
|
2008-07-29 08:52:25 +00:00
|
|
|
int bufferNum(support::FileName const & name) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// returns a pointer to the buffer with the given name.
|
2008-07-29 08:16:09 +00:00
|
|
|
Buffer * getBuffer(support::FileName const &) 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
|
2006-12-21 13:58:28 +00:00
|
|
|
void setCurrentAuthor(docstring const & name, docstring const & email);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
2007-11-03 17:37:37 +00:00
|
|
|
/// noncopiable
|
|
|
|
BufferList(BufferList const &);
|
|
|
|
void operator=(BufferList const &);
|
|
|
|
|
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;
|
2008-10-13 20:40:58 +00:00
|
|
|
/// storage of all internal buffers used for cut&paste, etc.
|
|
|
|
BufferStorage binternal;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
/// Implementation is in LyX.cpp
|
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
|