diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-12-15 18:07:51 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-12-15 20:23:02 +0000 |
| commit | 7267b8281fbcc21d96bb8cb760d2a4e881b4d5e5 (patch) | |
| tree | 74891181f3d7b078bb6e1f4424e0449d843ac626 /src/context.hh | |
| parent | e369b60258ba48eeeb53a91d15e6ae1a9bb6f10f (diff) | |
Move insert and erase to normal.cc, and move edition management to context
Diffstat (limited to 'src/context.hh')
| -rw-r--r-- | src/context.hh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/context.hh b/src/context.hh index cda7a812..58e7380c 100644 --- a/src/context.hh +++ b/src/context.hh @@ -70,7 +70,15 @@ public: const String& name() const { return m_name; } void set_name(String name) { m_name = std::move(name); } + bool is_editing() const { return m_edition_level!= 0; } + void disable_undo_handling() { ++m_edition_level; } private: + void begin_edition(); + void end_edition(); + int m_edition_level = 0; + + friend struct ScopedEdition; + safe_ptr<Editor> m_editor; safe_ptr<InputHandler> m_input_handler; safe_ptr<Client> m_client; @@ -82,5 +90,19 @@ private: JumpList::iterator m_current_jump = m_jump_list.begin(); }; +struct ScopedEdition +{ + ScopedEdition(Context& context) + : m_context(context) + { m_context.begin_edition(); } + + ~ScopedEdition() + { m_context.end_edition(); } + + Context& context() const { return m_context; } +private: + Context& m_context; +}; + } #endif // context_hh_INCLUDED |
