From 219709e472f4f7948d164316c8b24d4fb0505636 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 10 Oct 2011 22:38:58 +0000 Subject: [PATCH] Completions: move code from main.cc to completion.hh --- src/completion.hh | 11 +++++++++++ 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 #include +#include 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 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 completer = NullCompletion()) +std::string prompt(const std::string& text, Completer completer = NullCompletion()) { int max_x, max_y; getmaxyx(stdscr, max_y, max_x);