diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-05-12 21:25:08 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-05-17 19:52:22 +1000 |
| commit | c972dfd2d7875dd3780d4abd4ef0df0c09be421a (patch) | |
| tree | e726e886af03dff4989d20d3e5af54da286980e9 /src/completion.hh | |
| parent | 4916471029dfa9853473679823bf557bad2c4a52 (diff) | |
Introduce Menu completion flags to auto select best candidate
Diffstat (limited to 'src/completion.hh')
| -rw-r--r-- | src/completion.hh | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/completion.hh b/src/completion.hh index 1cfd1f22..370aec1b 100644 --- a/src/completion.hh +++ b/src/completion.hh @@ -18,10 +18,19 @@ using CandidateList = Vector<String, MemoryDomain::Completion>; struct Completions { + enum class Flags + { + None = 0, + Quoted = 0b1, + Menu = 0b10 + }; + + constexpr friend bool with_bit_ops(Meta::Type<Flags>) { return true; } + CandidateList candidates; ByteCount start; ByteCount end; - bool quoted = false; + Flags flags = Flags::None; Completions() : start(0), end(0) {} @@ -29,8 +38,8 @@ struct Completions Completions(ByteCount start, ByteCount end) : start(start), end(end) {} - Completions(ByteCount start, ByteCount end, CandidateList candidates, bool quoted = false) - : candidates(std::move(candidates)), start(start), end(end), quoted{quoted} {} + Completions(ByteCount start, ByteCount end, CandidateList candidates, Flags flags = Flags::None) + : candidates(std::move(candidates)), start(start), end(end), flags{flags} {} }; enum class CompletionFlags @@ -53,8 +62,8 @@ Completions shell_complete(const Context& context, CompletionFlags, inline Completions offset_pos(Completions completion, ByteCount offset) { - return { completion.start + offset, completion.end + offset, - std::move(completion.candidates), completion.quoted }; + return {completion.start + offset, completion.end + offset, + std::move(completion.candidates), completion.flags}; } template<typename Container> |
