Completions: move code from main.cc to completion.hh
This commit is contained in:
parent
fe0e1c79f0
commit
219709e472
|
@ -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
|
||||
|
|
11
src/main.cc
11
src/main.cc
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user