105 lines · 2.3 KB · Text
RawDownload
.TH COMPLETE 2.SH NAMEcomplete \- file name completion.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.br.B #include <complete.h>.PP.ft L.nf.ta \w'    'u +\w'    'u +\w'    'u +\w'    'u +\w'    'utypedef struct Completion	Completion;struct Completion{	uchar advance;		/* whether forward progress has been made */	uchar complete;	/* whether the completion now represents a file or directory */	char *string;		/* the string to advance, suffixed " " or "/" for file or directory */	int nmatch;		/* number of files that matched */	int nfile;			/* number of files returned */	char **filename;	/* their names */}; .fi.PP.B.ta \w'\fLchar* 'u .PP.BCompletion* complete(char *dir, char *s);.PP.Bvoid freecompletion(Completion *c);.SH DESCRIPTIONThe.I completefunction implements file name completion.Given a directory.I dirand a string.IR s ,it returns an analysis of the file names in that directory that begin with the string.IR s .The fields.B nmatchand.B nfilewill be set to the number of files that match the prefix and.B filenamewill be filled in with their names.If the file named is a directory, a slash character will be appended to it..PPIf no files match the string,.B nmatchwill be zero, but.I completewill return the full set of files in the directory, with.I nfileset to their number..PPThe flag.B advancereports whether the string.I scan be extended without changing the set of files that match.  If true,.B stringwill be set to the extension; that is, the value of.B stringmay be appended to.I sby the caller to extend the embryonic file name unambiguously..PPThe flag.B completereports whether the extended file name uniquely identifies a file.If true,.B stringwill be suffixed with a blank, or a slash and a blank,depending on whether the resulting file name identifies a plain file or a directory..PPThe.I freecompletionfunction frees a.B Completionstructure and its contents..PPIn.IR rio (1)and.IR acme (1),file name completion is triggered by a control-F character or an Insert character..SH SOURCE.B /sys/src/libcomplete.SH SEE ALSO.IR rio (1),.IR acme (1).SH DIAGNOSTICSThe.I completefunction returns a null pointer and sets.I errstrif the directory is unreadable or there is some other error..SH BUGSThe behavior of file name completion should be controlled by the plumber.