> But it doesn't work for set xyz :-(
> > > set ftp:pass<tab> == set ftp:passive-mode
> > > etc?
Here's a patch I submit that add this functionnality. Since I've
translated a new message to french, there's also a patch against the file
po/fr.po. Sorry for that.
However, there is no "second word" completion. It means you won't be able
to do something like:
set ftp:passive-mode <tab>
to get "on" or "off".
For alexander:
I've added a new method to the class ResMgr. It's called 'Generator' and
generate a char** that is the array of all the variables of lftp. This
method is called only once in complete.cc and then, when the 'set' command
is matched, it will look into this array, using your array_generator
function. The 'Generator' method is a kind of cut'n'paste from the
'Format' method. I didn't tried to get out all the unneeded stuff, but I
think it's quite empty of dumb things.
Cheers,
-- Nicolas Noble
diff -ur lftp-2.3.11/po/fr.po lftp-2.3.11-work/po/fr.po
--- lftp-2.3.11/po/fr.po Thu May 24 12:48:57 2001
+++ lftp-2.3.11-work/po/fr.po Fri May 25 01:23:14 2001
@@ -1047,8 +1047,8 @@
" -d list only default values, not necessary current ones\n"
msgstr ""
"D�finit la variable � la valeur indiqu�e. Si la valeur est omise, cela\n"
-"va effacer la variable. Le format d'un nom de variable est ``nom/"
-"restriction''\n"
+"va effacer la variable. Le format d'un nom de variable est "
+"``nom/restriction''\n"
"o� la restriction permet de sp�cifier l'application exacte de la "
"d�finition.\n"
"Regardez lftp(1) pour les d�tails.\n"
@@ -1449,7 +1449,7 @@
#: src/ftpclass.cc:379
msgid "Server reply matched ftp:retry-530[-anonymous], retrying"
-msgstr ""
+msgstr "La r�ponse du serveur est de la forme ftp:retry-530[-anonymous], recommence"
#: src/ftpclass.cc:419
msgid "ftp:skey-force is set and server does not support OPIE nor S/KEY"
@@ -1997,6 +1997,3 @@
#: src/module.cc:201
msgid "modules are not supported on this system"
msgstr "les modules ne sont pas support�s sur ce syst�me"
-
-#~ msgid "Saw `Login incorrect', assume failed login"
-#~ msgstr "`Login incorrect' d�tect�, �chec de la connexion"
diff -ur lftp-2.3.11/src/ResMgr.cc lftp-2.3.11-work/src/ResMgr.cc
--- lftp-2.3.11/src/ResMgr.cc Tue May 15 17:23:52 2001
+++ lftp-2.3.11-work/src/ResMgr.cc Mon May 28 16:55:07 2001
@@ -316,6 +316,57 @@
return res;
}
+char **ResMgr::Generator(void)
+{
+ char **res;
+
+ Resource *scan;
+ ResDecl *dscan;
+
+ int n=0;
+ int dn=0;
+ for(scan=chain; scan; scan=scan->next)
+ n++;
+ for(dscan=type_chain; dscan; dscan=dscan->next)
+ dn++;
+
+ res=(char**)xmalloc((n + dn + 1) * sizeof(char *));
+ char **store = res;
+
+ Resource **created=(Resource**)alloca((dn+1)*sizeof(Resource*));
+ Resource **c_store=created;
+ dn=0;
+ for(dscan=type_chain; dscan; dscan=dscan->next)
+ {
+ if(SimpleQuery(dscan->name,0)==0)
+ {
+ dn++;
+ *c_store++=new Resource(0,dscan,
+ 0,xstrdup(dscan->defvalue?dscan->defvalue:"(nil)"));
+ }
+ }
+
+ Resource **arr=(Resource**)alloca((n+dn)*sizeof(Resource*));
+ n=0;
+ for(scan=chain; scan; scan=scan->next)
+ arr[n++]=scan;
+
+ int i;
+ for(i=0; i<dn; i++)
+ arr[n++]=created[i];
+
+ qsort(arr,n,sizeof(*arr),&ResMgr::VResourceCompare);
+
+ for(i=0; i<n; i++)
+ *(store++) = xstrdup(arr[i]->type->name);
+
+ *store=0;
+
+ for(i=0; i<dn; i++)
+ delete created[i];
+ return res;
+}
+
const char *ResMgr::BoolValidate(char **value)
{
char *v=*value;
diff -ur lftp-2.3.11/src/ResMgr.h lftp-2.3.11-work/src/ResMgr.h
--- lftp-2.3.11/src/ResMgr.h Tue May 15 17:23:52 2001
+++ lftp-2.3.11-work/src/ResMgr.h Mon May 28 16:44:07 2001
@@ -87,6 +87,7 @@
static void Print(FILE *);
static char *Format(bool with_defaults,bool only_defaults);
+ static char **Generator(void);
static const char *BoolValidate(char **value);
static const char *NumberValidate(char **value);
diff -ur lftp-2.3.11/src/complete.cc lftp-2.3.11-work/src/complete.cc
--- lftp-2.3.11/src/complete.cc Tue Apr 17 17:33:00 2001
+++ lftp-2.3.11-work/src/complete.cc Mon May 28 17:03:12 2001
@@ -37,6 +37,7 @@
#include "complete.h"
#include "lftp_rl.h"
#include "url.h"
+#include "ResMgr.h"
CDECL_BEGIN
#include "readline/readline.h"
@@ -48,6 +49,7 @@
static int len; // lenght of the word to complete
static int cindex; // index in completion array
static const char *const *array;
+static const char *const *vars = NULL;
static FileSet *glob_res=NULL;
static bool shell_cmd;
@@ -425,6 +427,19 @@
}
else
return NO_COMPLETION;
+ }
+
+ if(!strcmp(buf,"set"))
+ {
+ if(second)
+ {
+ if(!vars)
+ vars=ResMgr::Generator();
+ array=vars;
+ return STRING_ARRAY;
+ }
+ else
+ return NO_COMPLETION;
}
if(!strcmp(buf,"lcd"))