home/src/buffer_manager.hh

42 lines
927 B
C++
Raw Normal View History

#ifndef buffer_manager_hh_INCLUDED
#define buffer_manager_hh_INCLUDED
#include "completion.hh"
#include "utils.hh"
#include <unordered_map>
namespace Kakoune
{
class Buffer;
class BufferManager : public Singleton<BufferManager>
{
public:
2012-08-08 19:36:40 +02:00
using BufferList = std::vector<safe_ptr<Buffer>>;
using iterator = BufferList::const_iterator;
~BufferManager();
2012-08-08 19:36:40 +02:00
void register_buffer(Buffer& buffer);
void unregister_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(); }
size_t count() const { return m_buffers.size(); }
Buffer* get_buffer(const String& name);
void set_last_used_buffer(Buffer& buffer);
CandidateList complete_buffername(const String& prefix,
ByteCount cursor_pos = -1);
private:
2012-08-08 19:36:40 +02:00
BufferList m_buffers;
};
}
#endif // buffer_manager_hh_INCLUDED