diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-02-07 23:41:10 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-02-07 23:41:10 +0000 |
| commit | 04a37d8895a5e2e1a59e71d447c07e9aefcee64d (patch) | |
| tree | 0126c5431e5ccfeb03fa1a96ec1c3e26c2e3737d /src/editor.hh | |
| parent | 333e87dedd453673485faf8d0cbedb02502453fe (diff) | |
Editor refactoring, merge undo and batch management
Diffstat (limited to 'src/editor.hh')
| -rw-r--r-- | src/editor.hh | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/editor.hh b/src/editor.hh index 3ad15b50..bd08801a 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -55,31 +55,40 @@ public: CandidateList complete_filterid(const std::string& prefix, size_t cursor_pos = std::string::npos); - void begin_batch(); - void end_batch(); - bool is_in_batch() const { return m_batch_level != 0; } + bool is_editing() const { return m_edition_level!= 0; } private: - void erase_noundo(); - void insert_noundo(const String& string); - void append_noundo(const String& string); + friend class scoped_edition; + void begin_edition(); + void end_edition(); + + int m_edition_level; SelectionList& selections() { return m_selections.back(); } void check_invariant() const; friend class IncrementalInserter; - int m_batch_level; - - virtual void on_begin_batch() {} - virtual void on_end_batch() {} - + virtual void on_incremental_insertion_begin() {} + virtual void on_incremental_insertion_end() {} Buffer& m_buffer; std::vector<SelectionList> m_selections; idvaluemap<std::string, FilterFunc> m_filters; }; +struct scoped_edition +{ + scoped_edition(Editor& editor) + : m_editor(editor) + { m_editor.begin_edition(); } + + ~scoped_edition() + { m_editor.end_edition(); } +private: + Editor& m_editor; +}; + // An IncrementalInserter manage insert mode class IncrementalInserter { @@ -109,6 +118,7 @@ private: void apply(Modification&& modification) const; Editor& m_editor; + scoped_edition m_edition; }; } |
