diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-10-10 22:38:58 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-10-10 22:38:58 +0000 |
| commit | 219709e472f4f7948d164316c8b24d4fb0505636 (patch) | |
| tree | f154a663585fceed6d9ca4296bc0c2859eb10f06 | |
| parent | fe0e1c79f05cee628b82a2b2f655d873ed922a78 (diff) | |
Completions: move code from main.cc to completion.hh
| -rw-r--r-- | src/completion.hh | 11 | ||||
| -rw-r--r-- | src/main.cc | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/completion.hh b/src/completion.hh index 739c24ea..e4fe8062 100644 --- a/src/completion.hh +++ b/src/completion.hh @@ -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 diff --git a/src/main.cc b/src/main.cc index 7a22b9af..0d78f437 100644 --- a/src/main.cc +++ b/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); |
