summaryrefslogtreecommitdiff
path: root/src/insert_completer.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-08-19 18:56:11 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-08-19 18:56:11 +0100
commitbea53d09b21de050841dee75fa4cc58e71532afb (patch)
tree57af5993e8023d199e26da863c32727daf7ccf7d /src/insert_completer.hh
parenta36aed94f17a93ac02f3efef35422ec3bcb5aaad (diff)
Remove option checkers, handle that through the type system
Use a specific type for InsertCompleterDesc with checks in the option_{from,to}_string functions
Diffstat (limited to 'src/insert_completer.hh')
-rw-r--r--src/insert_completer.hh32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/insert_completer.hh b/src/insert_completer.hh
index dcbf3ba1..88759edf 100644
--- a/src/insert_completer.hh
+++ b/src/insert_completer.hh
@@ -4,9 +4,41 @@
#include "buffer.hh"
#include "option_manager.hh"
+#include "optional.hh"
+
namespace Kakoune
{
+struct InsertCompleterDesc
+{
+ enum Mode
+ {
+ Word,
+ Option,
+ Filename
+ };
+
+ InsertCompleterDesc(Mode mode = Filename,
+ Optional<String> param = Optional<String>{})
+ : mode{mode}, param{std::move(param)}
+ {}
+
+ bool operator==(const InsertCompleterDesc& other) const
+ { return mode == other.mode && param == other.param; }
+
+ bool operator!=(const InsertCompleterDesc& other) const
+ { return !(*this == other); }
+
+ Mode mode;
+ Optional<String> param;
+};
+
+using InsertCompleterDescList = std::vector<InsertCompleterDesc>;
+
+
+String option_to_string(const InsertCompleterDesc& opt);
+void option_from_string(const String& str, InsertCompleterDesc& opt);
+
struct InsertCompletion
{
ByteCoord begin;