2011-09-08 02:11:48 +02:00
|
|
|
#ifndef buffer_manager_hh_INCLUDED
|
|
|
|
#define buffer_manager_hh_INCLUDED
|
|
|
|
|
2016-05-14 09:33:50 +02:00
|
|
|
#include "buffer.hh"
|
2011-11-12 15:06:49 +01:00
|
|
|
#include "completion.hh"
|
2011-09-23 16:26:53 +02:00
|
|
|
#include "utils.hh"
|
2014-08-12 01:30:13 +02:00
|
|
|
#include "safe_ptr.hh"
|
2011-09-08 02:11:48 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2011-09-23 16:26:53 +02:00
|
|
|
class BufferManager : public Singleton<BufferManager>
|
2011-09-08 02:11:48 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-05-14 09:33:50 +02:00
|
|
|
using BufferList = Vector<std::unique_ptr<Buffer>>;
|
2012-08-08 19:36:40 +02:00
|
|
|
using iterator = BufferList::const_iterator;
|
2011-09-22 20:55:23 +02:00
|
|
|
|
2012-06-14 15:15:30 +02:00
|
|
|
~BufferManager();
|
|
|
|
|
2016-05-14 09:33:50 +02:00
|
|
|
Buffer* create_buffer(String name, Buffer::Flags flags,
|
|
|
|
StringView data = {},
|
|
|
|
timespec fs_timestamp = InvalidTime);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2013-04-10 18:54:01 +02:00
|
|
|
void delete_buffer(Buffer& buffer);
|
|
|
|
|
2012-08-08 19:36:40 +02:00
|
|
|
iterator begin() const { return m_buffers.cbegin(); }
|
|
|
|
iterator end() const { return m_buffers.cend(); }
|
2012-05-29 00:51:12 +02:00
|
|
|
size_t count() const { return m_buffers.size(); }
|
2011-11-12 15:06:49 +01:00
|
|
|
|
2014-04-19 10:53:37 +02:00
|
|
|
Buffer* get_buffer_ifp(StringView name);
|
|
|
|
Buffer& get_buffer(StringView name);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2016-10-11 01:45:05 +02:00
|
|
|
Buffer& get_first_buffer();
|
|
|
|
|
2014-10-13 14:38:28 +02:00
|
|
|
void backup_modified_buffers();
|
|
|
|
|
2014-08-12 20:24:09 +02:00
|
|
|
void clear_buffer_trash();
|
2011-09-08 02:11:48 +02:00
|
|
|
private:
|
2012-08-08 19:36:40 +02:00
|
|
|
BufferList m_buffers;
|
2014-08-12 20:24:09 +02:00
|
|
|
BufferList m_buffer_trash;
|
2011-09-08 02:11:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // buffer_manager_hh_INCLUDED
|