mirror of https://github.com/PatrickLipka/tt.git
tt_name_completion rewritten in a more C++ conformant way
This commit is contained in:
parent
7ebe1c5fb4
commit
12376d3e4b
23
src/ui.cpp
23
src/ui.cpp
|
@ -6,6 +6,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iterator>
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
@ -36,18 +37,16 @@ char **tt_name_completion(const char* text, int start, int end){
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tt_name_generator(const char *text, int state){
|
char *tt_name_generator(const char *text, int state){
|
||||||
static int idx, len;
|
static std::vector<std::string>::const_iterator it;
|
||||||
const char *name;
|
if (state == 0) it=begin(autocomplete_names);
|
||||||
if (!state){
|
while(it != end(autocomplete_names)){
|
||||||
idx = 0;
|
std::string result = *it;
|
||||||
len = strlen(text);
|
++it;
|
||||||
}
|
if (result.find(text) != std::string::npos){
|
||||||
while ((name = autocomplete_names[idx++].c_str())){
|
return strdup(result.c_str());
|
||||||
if (strncmp(name, text, len) == 0){
|
}
|
||||||
return strdup(name);
|
}
|
||||||
}
|
return NULL;
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_autocomplete(ProjectList *proj_list){
|
void init_autocomplete(ProjectList *proj_list){
|
||||||
|
|
Loading…
Reference in New Issue