autocompletion update

This commit is contained in:
vaclavt
2022-03-01 20:29:18 +01:00
parent 830361050c
commit 9966c961d1
5 changed files with 23 additions and 31 deletions

14
ml.cpp
View File

@@ -2135,7 +2135,7 @@ bool MlEnvironment::has(const std::string &name) const {
std::map <const std::string, Builtin> builtin_funcs
std::map<const std::string, Builtin> builtin_funcs
{
// Special forms
std::make_pair("def", builtin::define),
@@ -2287,14 +2287,12 @@ MlValue MlEnvironment::get(const std::string &name) const {
}
// Get vector of executables in this scope
std::vector<std::string> MlEnvironment::get_lambdas_list() const {
std::vector<std::string> lambdas{128};
std::vector<std::string> MlEnvironment::get_lambdas_list(const std::string &token) const {
std::vector<std::string> lambdas{};
for (auto it = defs.begin(); it != defs.end(); it++) {
if (it->second.get_type_name() == FUNCTION_TYPE) {
for (auto it = defs.begin(); it != defs.end(); it++)
if (it->second.get_type_name() == FUNCTION_TYPE && (token.empty() || it->first.find(token) == 0))
lambdas.push_back(it->first);
}
}
return lambdas;
}
@@ -2306,7 +2304,7 @@ void repl(MlEnvironment &env) {
MlValue tmp;
std::vector<MlValue> parsed;
setup_linenoise(env);
setup_linenoise(env, builtin_funcs);
while (true) {
char *line = linenoise(">>> ");