diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-08-10 19:12:43 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-08-10 19:12:43 +0200 |
| commit | 759319ca448b054f28e6b7348a31646cb71afa98 (patch) | |
| tree | 078a0ae6d75e9fcf6d404d9fc0703ba9ff2a9036 /src/buffer.hh | |
| parent | 44621bff1158300fc61486024b6c9ddad2508e29 (diff) | |
Buffer: move back Modification as an implementation detail
* Filters now only works on insertion and take directly the
iterator and content
* use Buffer::insert and Buffer::erase to modify a buffer
Diffstat (limited to 'src/buffer.hh')
| -rw-r--r-- | src/buffer.hh | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/src/buffer.hh b/src/buffer.hh index afa64110..53523fae 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -14,7 +14,6 @@ namespace Kakoune { class Buffer; -class Modification; class Window; typedef int BufferPos; @@ -82,24 +81,6 @@ private: friend class Buffer; }; -// A Modification holds a single atomic modification to Buffer -struct Modification -{ - enum Type { Insert, Erase }; - - Type type; - BufferIterator position; - String content; - - Modification(Type type, BufferIterator position, String content) - : type(type), position(position), content(std::move(content)) {} - - Modification inverse() const; - - static Modification make_erase(BufferIterator begin, BufferIterator end); - static Modification make_insert(BufferIterator position, String content); -}; - class BufferChangeListener { public: @@ -130,8 +111,8 @@ public: Type type() const { return m_type; } - // apply given modification to buffer. - void modify(Modification&& modification); + void insert(const BufferIterator& pos, const String& content); + void erase(const BufferIterator& begin, const BufferIterator& end); void begin_undo_group(); void end_undo_group(); @@ -198,8 +179,8 @@ private: }; std::vector<Line> m_lines; - void insert(const BufferIterator& pos, const String& content); - void erase(const BufferIterator& pos, BufferSize length); + void do_insert(const BufferIterator& pos, const String& content); + void do_erase(const BufferIterator& pos, BufferSize length); BufferPos line_at(const BufferIterator& iterator) const; BufferSize line_length(BufferPos line) const; @@ -207,6 +188,7 @@ private: String m_name; const Type m_type; + struct Modification; typedef std::vector<Modification> UndoGroup; std::vector<UndoGroup> m_history; @@ -226,18 +208,6 @@ private: HookManager m_hook_manager; }; -inline Modification Modification::make_erase(BufferIterator begin, - BufferIterator end) -{ - return Modification(Erase, begin, begin.buffer().string(begin, end)); -} - -inline Modification Modification::make_insert(BufferIterator position, - String content) -{ - return Modification(Insert, position, std::move(content)); -} - } #include "buffer_iterator.inl.hh" |
