aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-05-15 10:33:20 +0000
committerbloodstalker <thabogre@gmail.com>2017-05-15 10:33:20 +0000
commitcfa98492c7174f0f0f41b2687274b79160122a71 (patch)
tree7fea927acc524b26c07838b0d6fef9efc7de32fb
parentmerely updated (diff)
downloadmutator-cfa98492c7174f0f0f41b2687274b79160122a71.tar.gz
mutator-cfa98492c7174f0f0f41b2687274b79160122a71.zip
new source. holds the completion and suggestion functions
-rw-r--r--bruiser/CompletionHints.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/bruiser/CompletionHints.cpp b/bruiser/CompletionHints.cpp
new file mode 100644
index 0000000..ed0eb2e
--- /dev/null
+++ b/bruiser/CompletionHints.cpp
@@ -0,0 +1,99 @@
+
+/***************************************************Project Mutator****************************************************/
+//-*-c++-*-
+/*first line intentionally left blank.*/
+/*the source code for bruiser's auto-completion and suggestions.*/
+/*Copyright (C) 2017 Farzad Sadeghi
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
+/**********************************************************************************************************************/
+/*included modules*/
+#include "bruiser-extra.h"
+/*project headers*/
+/*standard headers*/
+#include <iostream>
+#include <string>
+/*LLVM headers*/
+/*other*/
+#include "linenoise/linenoise.h"
+/**********************************************************************************************************************/
+/*used namespaces*/
+/**********************************************************************************************************************/
+/*macros*/
+
+/**********************************************************************************************************************/
+namespace bruiser
+{
+ void ShellCompletion(const char* __buf, linenoiseCompletions* __lc)
+ {
+ if (__buf != NULL)
+ {
+ for(auto &iter : LUA_FUNCS)
+ {
+ if (iter.find(__buf) == 0U)
+ {
+ linenoiseAddCompletion(__lc, iter.c_str());
+ }
+ }
+ }
+ }
+
+ char* ShellHints(const char* __buf, int* __color, int* __bold)
+ {
+ if (__buf != NULL)
+ {
+ auto dummy = std::string(__buf);
+
+ for(auto &iter : LUA_FUNCS)
+ {
+ if (dummy == "")
+ {
+ break;
+ }
+
+ if (iter.find(dummy) == 0U)
+ {
+ *__color = 35;
+ *__bold = 0;
+ int sizet = dummy.length();
+
+ std::string dummy2 = iter.substr(sizet, iter.length() - sizet + 1);
+
+ /*LEAKS MEMORY*/
+ char* returnchar = new char[dummy2.size() + 1];
+ std::copy(dummy2.begin(), dummy2.end(), returnchar);
+ returnchar[dummy2.size()] = '\0';
+
+#if 0
+ std::vector<char> retchar(dummy2.begin(), dummy2.end());
+ retchar.push_back('\0');
+ //std::cout << "\n" << retchar.data() << "\n";
+ char* c = (char*)retchar.data();
+ //std::cout << "\n" << c << "\n";
+#endif
+
+ return returnchar;
+ //return c;
+ //return &*retchar.data();
+ }
+ }
+ }
+
+ return NULL;
+ }
+} //end of namespace bruiser
+/**********************************************************************************************************************/
+/*last line intentionally left blank*/
+