Converted all auto completion calls (on pressing tab) to use std::vector<completion_t>, bugs are yet to be fixed

This commit is contained in:
Siteshwar Vashisht
2012-01-16 22:26:47 +05:30
parent f3e2d2f68f
commit 140ead65b6
15 changed files with 622 additions and 244 deletions

View File

@@ -83,6 +83,7 @@ parts of fish.
#include "proc.h"
#include "wildcard.h"
#include "parser.h"
#include "complete.h"
#include "util.cpp"
#include "halloc.cpp"
@@ -155,6 +156,23 @@ wchar_t **list_to_char_arr( array_list_t *l )
return res;
}
wchar_t **completions_to_char_arr( std::vector<completion_t> &l )
{
wchar_t ** res = (wchar_t **)malloc( sizeof(wchar_t *)*( l.size() + 1) );
int i;
if( res == 0 )
{
DIE_MEM();
}
for( i=0; i< l.size(); i++ )
{
res[i] = (wchar_t *)l.at(i).completion.c_str();
}
res[i]='\0';
return res;
}
int fgetws2( wchar_t **b, int *len, FILE *f )
{
int i=0;
@@ -242,6 +260,10 @@ void sort_strings( std::vector<wcstring> &strings)
std::sort(strings.begin(), strings.end(), string_sort_predicate);
}
void sort_completions( std::vector<completion_t> &completions)
{
std::sort(completions.begin(), completions.end());
}
wchar_t *str2wcs( const char *in )
{
wchar_t *out;