summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-11-12 14:15:35 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-11-12 14:15:35 +0000
commit0dc8442ca40cc6d914de20be40533382287b0ffd (patch)
tree228bd6e30e755538bbb07e260aef1481d8400875 /src
parenta8b2c4f568e4384e0f52e0c995ad2128ed43a334 (diff)
Completions: add filterid completion for rmfilter
Diffstat (limited to 'src')
-rw-r--r--src/main.cc6
-rw-r--r--src/window.cc14
-rw-r--r--src/window.hh4
3 files changed, 23 insertions, 1 deletions
diff --git a/src/main.cc b/src/main.cc
index d3bfd62f..977e05c2 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -622,7 +622,11 @@ int main(int argc, char* argv[])
PerArgumentCommandCompleter {
std::bind(&FilterRegistry::complete_filter, &filter_registry, _1, _2)
});
- command_manager.register_command(std::vector<std::string>{ "rf", "rmfilter" }, rm_filter);
+ command_manager.register_command(std::vector<std::string>{ "rf", "rmfilter" }, rm_filter,
+ PerArgumentCommandCompleter {
+ [&](const std::string& prefix, size_t cursor_pos)
+ { return current_window->complete_filterid(prefix, cursor_pos); }
+ });
register_filters();
diff --git a/src/window.cc b/src/window.cc
index c0ecdc28..c1792d2d 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -331,6 +331,20 @@ void Window::remove_filter(const std::string& id)
}
}
+CandidateList Window::complete_filterid(const std::string& prefix,
+ size_t cursor_pos)
+{
+ std::string real_prefix = prefix.substr(0, cursor_pos);
+ CandidateList result;
+ for (auto& filter : m_filters)
+ {
+ if (filter.first.substr(0, real_prefix.length()) == real_prefix)
+ result.push_back(filter.first);
+ }
+ return result;
+}
+
+
IncrementalInserter::IncrementalInserter(Window& window, Mode mode)
: m_window(window)
{
diff --git a/src/window.hh b/src/window.hh
index 9d0de609..133d44d1 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -6,6 +6,7 @@
#include "buffer.hh"
#include "dynamic_buffer_iterator.hh"
#include "display_buffer.hh"
+#include "completion.hh"
#include "filter.hh"
namespace Kakoune
@@ -80,6 +81,9 @@ public:
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);
+
private:
friend class Buffer;