kakoune/src/context.hh

38 lines
732 B
C++
Raw Normal View History

2011-11-26 19:32:57 +01:00
#ifndef context_hh_INCLUDED
#define context_hh_INCLUDED
#include "window.hh"
namespace Kakoune
{
struct Context
{
Context()
: m_window(nullptr), m_buffer(nullptr) {}
2011-11-26 19:32:57 +01:00
Context(Window& window)
: m_window(&window), m_buffer(&window.buffer()) {}
2011-11-26 19:32:57 +01:00
Context(Buffer& buffer)
: m_window(nullptr), m_buffer(&buffer) {}
Buffer& buffer() const
{
if (not m_buffer)
throw runtime_error("no buffer in context");
return *m_buffer;
}
Window& window() const
{
if (not m_window)
throw runtime_error("no window in context");
return *m_window;
}
public:
Window* m_window;
Buffer* m_buffer;
2011-11-26 19:32:57 +01:00
};
}
#endif // context_hh_INCLUDED