diff options
author | Aaron Seigo <aseigo@kde.org> | 2015-12-28 20:20:16 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2015-12-28 20:20:16 +0100 |
commit | 7e48662cf11b5be7d062b082a9a1970419921a08 (patch) | |
tree | 26687262453b15285e963a06cb414faf30ef5f4e | |
parent | 949609b3f19b8a8823a7c62f23617eef05b796dd (diff) | |
download | sink-7e48662cf11b5be7d062b082a9a1970419921a08.tar.gz sink-7e48662cf11b5be7d062b082a9a1970419921a08.zip |
pass the state object into the completer
allows completion to use an eventloop e.g.
-rw-r--r-- | akonadish/repl/replStates.cpp | 2 | ||||
-rw-r--r-- | akonadish/syntax_modules/core_syntax.cpp | 2 | ||||
-rw-r--r-- | akonadish/syntaxtree.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/akonadish/repl/replStates.cpp b/akonadish/repl/replStates.cpp index 62888d0..55fdf39 100644 --- a/akonadish/repl/replStates.cpp +++ b/akonadish/repl/replStates.cpp | |||
@@ -156,7 +156,7 @@ static char *akonadi2_cli_next_tab_complete_match(const char *text, int state) | |||
156 | if (nearest.isEmpty()) { | 156 | if (nearest.isEmpty()) { |
157 | SyntaxTree::Command command = SyntaxTree::self()->match(tab_completion_full_state); | 157 | SyntaxTree::Command command = SyntaxTree::self()->match(tab_completion_full_state); |
158 | if (command.first && command.first->completer) { | 158 | if (command.first && command.first->completer) { |
159 | QStringList commandCompletions = command.first->completer(tab_completion_full_state, fragment); | 159 | QStringList commandCompletions = command.first->completer(tab_completion_full_state, fragment, SyntaxTree::self()->state()); |
160 | if (commandCompletions.size() > state) { | 160 | if (commandCompletions.size() > state) { |
161 | return qstrdup(commandCompletions[state].toUtf8()); | 161 | return qstrdup(commandCompletions[state].toUtf8()); |
162 | } | 162 | } |
diff --git a/akonadish/syntax_modules/core_syntax.cpp b/akonadish/syntax_modules/core_syntax.cpp index 31b824a..b4812df 100644 --- a/akonadish/syntax_modules/core_syntax.cpp +++ b/akonadish/syntax_modules/core_syntax.cpp | |||
@@ -76,7 +76,7 @@ bool showHelp(const QStringList &commands, State &state) | |||
76 | return true; | 76 | return true; |
77 | } | 77 | } |
78 | 78 | ||
79 | QStringList showHelpCompleter(const QStringList &commands, const QString &fragment) | 79 | QStringList showHelpCompleter(const QStringList &commands, const QString &fragment, State &) |
80 | { | 80 | { |
81 | QStringList items; | 81 | QStringList items; |
82 | 82 | ||
diff --git a/akonadish/syntaxtree.h b/akonadish/syntaxtree.h index ee06d28..468aad3 100644 --- a/akonadish/syntaxtree.h +++ b/akonadish/syntaxtree.h | |||
@@ -47,7 +47,7 @@ public: | |||
47 | QString help; | 47 | QString help; |
48 | Interactivity interactivity; | 48 | Interactivity interactivity; |
49 | std::function<bool(const QStringList &, State &)> lambda; | 49 | std::function<bool(const QStringList &, State &)> lambda; |
50 | std::function<QStringList(const QStringList &, const QString &)> completer; | 50 | std::function<QStringList(const QStringList &, const QString &, State &state)> completer; |
51 | 51 | ||
52 | QVector<Syntax> children; | 52 | QVector<Syntax> children; |
53 | }; | 53 | }; |