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 {
|
|
|
|
|
2010-10-29 19:27:55 +00:00
|
|
|
class Author;
|
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
|
|
|
/// 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
|
|
|
|
2010-10-29 19:00:06 +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;
|
2011-02-07 20:31:09 +00:00
|
|
|
|
|
|
|
/** returns a pointer to the buffer with the given name
|
|
|
|
*
|
|
|
|
* \param internal
|
|
|
|
* If true, the buffer is searched also among internal buffers
|
|
|
|
*/
|
|
|
|
Buffer * getBuffer(support::FileName const & name, bool internal = false) const;
|
|
|
|
|
2010-10-29 19:00:06 +00:00
|
|
|
/// \return a pointer to the buffer with the given number
|
2000-10-11 21:06:43 +00:00
|
|
|
Buffer * getBuffer(unsigned int);
|
2011-02-07 20:31:09 +00:00
|
|
|
|
2010-10-29 19:00:06 +00:00
|
|
|
/// \return a pointer to the buffer whose temppath matches the given path
|
|
|
|
Buffer * getBufferFromTmp(std::string const & path);
|
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;
|
|
|
|
|
2010-10-29 19:00:06 +00:00
|
|
|
/// \name Functions that just operate on all buffers
|
|
|
|
//@{
|
2003-02-08 19:18:01 +00:00
|
|
|
/// reset current author for all buffers
|
2010-10-29 19:27:55 +00:00
|
|
|
void recordCurrentAuthor(Author const & author);
|
2010-01-06 18:36:13 +00:00
|
|
|
/// Call changed() on all buffers, internal or not
|
2010-01-08 02:03:54 +00:00
|
|
|
void changed(bool update_metrics) const;
|
2010-10-29 19:00:06 +00:00
|
|
|
/// emergency save for all buffers
|
|
|
|
void emergencyWriteAll();
|
|
|
|
/// FIXME
|
|
|
|
void updateIncludedTeXfiles(std::string const &, OutputParams const &);
|
|
|
|
//@}
|
2010-01-06 18:36:13 +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
|