home/src/completion.hh
Maxime Coste 37b4eacdc8 Rework command completion to allow partial token completion
Implement hook completion.

fixes #44
2014-01-27 19:51:58 +00:00

52 lines
1.1 KiB
C++

#ifndef completion_hh_INCLUDED
#define completion_hh_INCLUDED
#include <vector>
#include <functional>
#include "units.hh"
namespace Kakoune
{
class Context;
class String;
using CandidateList = std::vector<String>;
struct Completions
{
CandidateList candidates;
ByteCount start;
ByteCount end;
Completions()
: start(0), end(0) {}
Completions(ByteCount start, ByteCount end)
: start(start), end(end) {}
Completions(ByteCount start, ByteCount end, CandidateList candidates)
: start(start), end(end), candidates(std::move(candidates)) {}
};
enum class CompletionFlags
{
None,
Fast
};
using Completer = std::function<Completions (const Context&, CompletionFlags,
const String&, ByteCount)>;
inline Completions complete_nothing(const Context& context, CompletionFlags,
const String&, ByteCount cursor_pos)
{
return Completions(cursor_pos, cursor_pos);
}
Completions shell_complete(const Context& context, CompletionFlags,
const String&, ByteCount cursor_pos);
}
#endif // completion_hh_INCLUDED