summaryrefslogtreecommitdiff
path: root/src/insert_completer.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-04-28 21:54:00 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-04-28 21:54:00 +0100
commitf68394668174492caa599442e9f7bd344a84d9d8 (patch)
tree6e267fb3c4805c1631e1b1b368af3f7430356f5e /src/insert_completer.hh
parent512bfa0c65f8e089700881a4e6cbfb1d2dc8cb58 (diff)
Extract insert completion code to insert_completer.{cc,hh}
Diffstat (limited to 'src/insert_completer.hh')
-rw-r--r--src/insert_completer.hh53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/insert_completer.hh b/src/insert_completer.hh
new file mode 100644
index 00000000..d05f8c96
--- /dev/null
+++ b/src/insert_completer.hh
@@ -0,0 +1,53 @@
+#ifndef insert_completer_hh_INCLUDED
+#define insert_completer_hh_INCLUDED
+
+#include "buffer.hh"
+#include "option_manager.hh"
+
+namespace Kakoune
+{
+
+struct InsertCompletion
+{
+ BufferCoord begin;
+ BufferCoord end;
+ CandidateList candidates;
+ size_t timestamp;
+
+ bool is_valid() const { return not candidates.empty(); }
+};
+
+class InsertCompleter : public OptionManagerWatcher_AutoRegister
+{
+public:
+ InsertCompleter(const Context& context);
+ InsertCompleter(const InsertCompleter&) = delete;
+ InsertCompleter& operator=(const InsertCompleter&) = delete;
+
+ void select(int offset);
+ void update();
+ void reset();
+
+ void explicit_file_complete();
+ void explicit_word_complete();
+ void explicit_line_complete();
+
+private:
+ bool setup_ifn();
+
+ template<typename CompleteFunc>
+ bool try_complete(CompleteFunc complete_func);
+ void on_option_changed(const Option& opt) override;
+
+ void menu_show();
+
+ const Context& m_context;
+ InsertCompletion m_completions;
+ CandidateList m_matching_candidates;
+ int m_current_candidate = -1;
+};
+
+}
+
+#endif // insert_completer_hh_INCLUDED
+