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-04-14 03:17:09 +02:00
|
|
|
typedef std::unordered_map<String, Buffer*> BufferMap;
|
2011-09-22 20:55:23 +02:00
|
|
|
|
|
|
|
struct iterator : public BufferMap::const_iterator
|
|
|
|
{
|
|
|
|
typedef BufferMap::const_iterator parent_type;
|
|
|
|
|
|
|
|
iterator() {}
|
|
|
|
iterator(const parent_type& other) : parent_type(other) {}
|
|
|
|
Buffer& operator*() const { return *(parent_type::operator*().second); }
|
2012-03-26 16:21:49 +02:00
|
|
|
Buffer* operator->() const { return parent_type::operator*().second; }
|
2011-09-22 20:55:23 +02:00
|
|
|
};
|
|
|
|
|
2011-09-08 02:11:48 +02:00
|
|
|
void register_buffer(Buffer* buffer);
|
2012-03-26 16:21:49 +02:00
|
|
|
void unregister_buffer(Buffer* buffer);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2011-11-12 15:06:49 +01:00
|
|
|
iterator begin() const { return iterator(m_buffers.begin()); }
|
|
|
|
iterator end() const { return iterator(m_buffers.end()); }
|
|
|
|
|
2012-04-14 03:17:09 +02:00
|
|
|
Buffer* get_buffer(const String& name);
|
2011-09-08 02:11:48 +02:00
|
|
|
|
2012-04-14 03:17:09 +02:00
|
|
|
CandidateList complete_buffername(const String& prefix,
|
|
|
|
size_t cursor_pos = String::npos);
|
2011-11-12 15:06:49 +01:00
|
|
|
|
2011-09-08 02:11:48 +02:00
|
|
|
private:
|
2011-09-22 20:55:23 +02:00
|
|
|
BufferMap m_buffers;
|
2011-09-08 02:11:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // buffer_manager_hh_INCLUDED
|