Completions: move code from main.cc to completion.hh

This commit is contained in:
Maxime Coste 2011-10-10 22:38:58 +00:00
parent fe0e1c79f0
commit 219709e472
2 changed files with 12 additions and 10 deletions

View File

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <functional>
namespace Kakoune
{
@ -28,5 +29,15 @@ CandidateList complete_filename(const std::string& prefix,
CandidateList complete_buffername(const std::string& prefix,
size_t cursor_pos = std::string::npos);
typedef std::function<Completions (const std::string&, size_t)> Completer;
struct NullCompletion
{
Completions operator() (const std::string&, size_t cursor_pos)
{
return Completions(cursor_pos, cursor_pos);
}
};
}
#endif // completion_hh_INCLUDED

View File

@ -163,16 +163,7 @@ void deinit_ncurses()
struct prompt_aborted {};
struct NullCompletion
{
Completions operator() (const std::string&, size_t cursor_pos)
{
return Completions(cursor_pos, cursor_pos);
}
};
std::string prompt(const std::string& text,
std::function<Completions (const std::string&, size_t)> completer = NullCompletion())
std::string prompt(const std::string& text, Completer completer = NullCompletion())
{
int max_x, max_y;
getmaxyx(stdscr, max_y, max_x);