2011-09-08 04:11:48 +04:00
|
|
|
#ifndef buffer_manager_hh_INCLUDED
|
|
|
|
#define buffer_manager_hh_INCLUDED
|
|
|
|
|
2016-05-14 10:33:50 +03:00
|
|
|
#include "buffer.hh"
|
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
|
|
|
|
{
|
|
|
|
|
2011-09-23 18:26:53 +04:00
|
|
|
class BufferManager : public Singleton<BufferManager>
|
2011-09-08 04:11:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-05-14 10:33:50 +03:00
|
|
|
using BufferList = Vector<std::unique_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();
|
|
|
|
|
2016-05-14 10:33:50 +03:00
|
|
|
Buffer* create_buffer(String name, Buffer::Flags flags,
|
|
|
|
StringView data = {},
|
|
|
|
timespec fs_timestamp = InvalidTime);
|
2011-09-08 04:11:48 +04:00
|
|
|
|
2013-04-10 20:54:01 +04:00
|
|
|
void delete_buffer(Buffer& buffer);
|
|
|
|
|
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);
|
2011-09-08 04:11:48 +04:00
|
|
|
|
2016-10-11 02:45:05 +03:00
|
|
|
Buffer& get_first_buffer();
|
|
|
|
|
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
|