2011-09-08 04:11:48 +04:00
|
|
|
#ifndef buffer_manager_hh_INCLUDED
|
|
|
|
#define buffer_manager_hh_INCLUDED
|
|
|
|
|
2011-11-12 18:06:49 +04:00
|
|
|
#include "completion.hh"
|
2011-09-23 18:26:53 +04:00
|
|
|
#include "utils.hh"
|
2014-08-12 03:30:13 +04:00
|
|
|
#include "safe_ptr.hh"
|
2011-09-08 04:11:48 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-03-26 18:21:49 +04:00
|
|
|
class Buffer;
|
|
|
|
|
2011-09-23 18:26:53 +04:00
|
|
|
class BufferManager : public Singleton<BufferManager>
|
2011-09-08 04:11:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-01-12 16:58:41 +03:00
|
|
|
using BufferList = Vector<safe_ptr<Buffer>>;
|
2012-08-08 21:36:40 +04:00
|
|
|
using iterator = BufferList::const_iterator;
|
2011-09-22 22:55:23 +04:00
|
|
|
|
2012-06-14 17:15:30 +04:00
|
|
|
~BufferManager();
|
|
|
|
|
2012-08-08 21:36:40 +04:00
|
|
|
void register_buffer(Buffer& buffer);
|
|
|
|
void unregister_buffer(Buffer& buffer);
|
2011-09-08 04:11:48 +04:00
|
|
|
|
2013-04-10 20:54:01 +04:00
|
|
|
void delete_buffer(Buffer& buffer);
|
2014-04-19 12:53:37 +04:00
|
|
|
void delete_buffer_if_exists(StringView name);
|
2013-04-10 20:54:01 +04:00
|
|
|
|
2012-08-08 21:36:40 +04:00
|
|
|
iterator begin() const { return m_buffers.cbegin(); }
|
|
|
|
iterator end() const { return m_buffers.cend(); }
|
2012-05-29 02:51:12 +04:00
|
|
|
size_t count() const { return m_buffers.size(); }
|
2011-11-12 18:06:49 +04:00
|
|
|
|
2014-04-19 12:53:37 +04:00
|
|
|
Buffer* get_buffer_ifp(StringView name);
|
|
|
|
Buffer& get_buffer(StringView name);
|
2012-09-28 16:14:49 +04:00
|
|
|
void set_last_used_buffer(Buffer& buffer);
|
2011-09-08 04:11:48 +04:00
|
|
|
|
2014-10-13 16:38:28 +04:00
|
|
|
void backup_modified_buffers();
|
|
|
|
|
2014-08-12 22:24:09 +04:00
|
|
|
void clear_buffer_trash();
|
2011-09-08 04:11:48 +04:00
|
|
|
private:
|
2012-08-08 21:36:40 +04:00
|
|
|
BufferList m_buffers;
|
2014-08-12 22:24:09 +04:00
|
|
|
BufferList m_buffer_trash;
|
2011-09-08 04:11:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // buffer_manager_hh_INCLUDED
|