summaryrefslogtreecommitdiff
path: root/src/buffer.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-12-02 14:28:27 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-12-02 14:28:27 +0000
commit94d59cc4dd19a0e45b537ac854bf3fdaa6824679 (patch)
tree3462c3214123f9fc959700e668a34443bdee245a /src/buffer.hh
parent8e06e168d9c699c102bc0ea729a0814411e47660 (diff)
Buffer: add filter support
filters are functions called prior to applying a modification to a buffer. They can manipulate the modification to change the editor behaviour.
Diffstat (limited to 'src/buffer.hh')
-rw-r--r--src/buffer.hh18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
index 5a336f23..0221e46a 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -7,6 +7,10 @@
#include <memory>
#include "line_and_column.hh"
+#include "filter.hh"
+#include "exception.hh"
+#include "completion.hh"
+#include "idvaluemap.hh"
namespace Kakoune
{
@@ -149,6 +153,18 @@ public:
void register_modification_listener(BufferModificationListener* listener);
void unregister_modification_listener(BufferModificationListener* listener);
+ struct filter_id_not_unique : public runtime_error
+ {
+ filter_id_not_unique(const std::string& id)
+ : runtime_error("filter id not unique: " + id) {}
+ };
+
+ void add_filter(FilterAndId&& filter);
+ void remove_filter(const std::string& id);
+
+ CandidateList complete_filterid(const std::string& prefix,
+ size_t cursor_pos = std::string::npos);
+
// returns an iterator pointing to the first character of the line
// iterator is on
BufferIterator iterator_at_line_begin(const BufferIterator& iterator) const;
@@ -190,6 +206,8 @@ private:
size_t m_last_save_undo_index;
std::vector<BufferModificationListener*> m_modification_listeners;
+
+ idvaluemap<std::string, FilterFunc> m_filters;
};
}