2011-09-08 02:11:48 +02:00
|
|
|
#ifndef buffer_manager_hh_INCLUDED
|
|
|
|
#define buffer_manager_hh_INCLUDED
|
|
|
|
|
2011-11-12 15:06:49 +01:00
|
|
|
#include "completion.hh"
|
2011-09-23 16:26:53 +02:00
|
|
|
#include "utils.hh"
|
2011-09-08 02:11:48 +02:00
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-03-26 16:21:49 +02:00
|
|
|
class Buffer;
|
|
|
|
|
2011-09-23 16:26:53 +02:00
|
|
|
class BufferManager : public Singleton<BufferManager>
|
2011-09-08 02:11:48 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-08-08 19:36:40 +02:00
|
|
|
using BufferList = std::vector<safe_ptr<Buffer>>;
|
|
|
|
using iterator = BufferList::const_iterator;
|
2011-09-22 20:55:23 +02:00
|
|
|
|
2012-06-14 15:15:30 +02:00
|
|
|
~BufferManager();
|
|
|
|
|
2012-08-08 19:36:40 +02:00
|
|
|
void register_buffer(Buffer& buffer);
|
|
|
|
void unregister_buffer(Buffer& buffer);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2013-04-10 18:54:01 +02:00
|
|
|
void delete_buffer(Buffer& buffer);
|
|
|
|
void delete_buffer_if_exists(const String& name);
|
|
|
|
|
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
|
|
|
|
2013-03-21 19:09:31 +01:00
|
|
|
Buffer* get_buffer_ifp(const String& name);
|
|
|
|
Buffer& get_buffer(const String& name);
|
2012-09-28 14:14:49 +02:00
|
|
|
void set_last_used_buffer(Buffer& buffer);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2014-04-18 15:02:14 +02:00
|
|
|
CandidateList complete_buffer_name(StringView prefix,
|
2014-04-07 22:43:23 +02:00
|
|
|
ByteCount cursor_pos = -1);
|
2011-11-12 15:06:49 +01:00
|
|
|
|
2011-09-08 02:11:48 +02:00
|
|
|
private:
|
2012-08-08 19:36:40 +02:00
|
|
|
BufferList m_buffers;
|
2011-09-08 02:11:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // buffer_manager_hh_INCLUDED
|