2011-11-26 22:32:57 +04:00
|
|
|
#ifndef context_hh_INCLUDED
|
|
|
|
#define context_hh_INCLUDED
|
|
|
|
|
2012-02-14 01:32:54 +04:00
|
|
|
#include "window.hh"
|
|
|
|
|
2011-11-26 22:32:57 +04:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-01-31 17:38:06 +04:00
|
|
|
class Buffer;
|
|
|
|
|
2011-11-26 22:32:57 +04:00
|
|
|
struct Context
|
|
|
|
{
|
|
|
|
Context()
|
2012-01-16 01:33:35 +04:00
|
|
|
: m_window(nullptr), m_buffer(nullptr) {}
|
2011-11-26 22:32:57 +04:00
|
|
|
Context(Window& window)
|
2012-01-16 01:33:35 +04:00
|
|
|
: m_window(&window), m_buffer(&window.buffer()) {}
|
2011-11-26 22:32:57 +04:00
|
|
|
Context(Buffer& buffer)
|
2012-01-16 01:33:35 +04: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 17:38:06 +04:00
|
|
|
bool has_buffer() const { return m_buffer; }
|
|
|
|
|
2012-01-16 01:33:35 +04:00
|
|
|
Window& window() const
|
|
|
|
{
|
|
|
|
if (not m_window)
|
|
|
|
throw runtime_error("no window in context");
|
|
|
|
return *m_window;
|
|
|
|
}
|
2012-01-31 17:38:06 +04:00
|
|
|
bool has_window() const { return m_window; }
|
2012-06-28 16:01:37 +04:00
|
|
|
|
|
|
|
OptionManager& option_manager() const
|
|
|
|
{
|
|
|
|
if (m_window)
|
|
|
|
return m_window->option_manager();
|
|
|
|
if (m_buffer)
|
|
|
|
return m_buffer->option_manager();
|
|
|
|
return GlobalOptionManager::instance();
|
|
|
|
}
|
|
|
|
|
2012-08-05 18:46:10 +04:00
|
|
|
int numeric_param() const { return m_numeric_param; }
|
|
|
|
void numeric_param(int param) { m_numeric_param = param; }
|
|
|
|
|
|
|
|
|
2012-01-16 01:33:35 +04:00
|
|
|
public:
|
2012-06-28 15:46:14 +04:00
|
|
|
safe_ptr<Window> m_window;
|
|
|
|
safe_ptr<Buffer> m_buffer;
|
2012-01-16 01:33:35 +04:00
|
|
|
|
2012-08-05 18:46:10 +04:00
|
|
|
int m_numeric_param = 0;
|
2011-11-26 22:32:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // context_hh_INCLUDED
|