2011-11-26 19:32:57 +01:00
|
|
|
#ifndef context_hh_INCLUDED
|
|
|
|
#define context_hh_INCLUDED
|
|
|
|
|
2012-02-13 22:32:54 +01:00
|
|
|
#include "window.hh"
|
|
|
|
|
2011-11-26 19:32:57 +01:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-01-31 14:38:06 +01:00
|
|
|
class Buffer;
|
|
|
|
|
2011-11-26 19:32:57 +01:00
|
|
|
struct Context
|
|
|
|
{
|
|
|
|
Context()
|
2012-01-15 22:33:35 +01:00
|
|
|
: m_window(nullptr), m_buffer(nullptr) {}
|
2011-11-26 19:32:57 +01:00
|
|
|
Context(Window& window)
|
2012-01-15 22:33:35 +01:00
|
|
|
: m_window(&window), m_buffer(&window.buffer()) {}
|
2011-11-26 19:32:57 +01:00
|
|
|
Context(Buffer& buffer)
|
2012-01-15 22:33:35 +01:00
|
|
|
: m_window(nullptr), m_buffer(&buffer) {}
|
|
|
|
|
|
|
|
Buffer& buffer() const
|
|
|
|
{
|
|
|
|
if (not m_buffer)
|
|
|
|
throw runtime_error("no buffer in context");
|
|
|
|
return *m_buffer;
|
|
|
|
}
|
2012-01-31 14:38:06 +01:00
|
|
|
bool has_buffer() const { return m_buffer; }
|
|
|
|
|
2012-01-15 22:33:35 +01:00
|
|
|
Window& window() const
|
|
|
|
{
|
|
|
|
if (not m_window)
|
|
|
|
throw runtime_error("no window in context");
|
|
|
|
return *m_window;
|
|
|
|
}
|
2012-01-31 14:38:06 +01:00
|
|
|
bool has_window() const { return m_window; }
|
2012-01-15 22:33:35 +01:00
|
|
|
public:
|
|
|
|
Window* m_window;
|
|
|
|
Buffer* m_buffer;
|
|
|
|
|
2011-11-26 19:32:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // context_hh_INCLUDED
|