blob: 6ccf9da72ac73b988965d3fe961a69e309225841 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH COMPLETE 3
2.SH NAME
rsc058b0112005-01-03 06:40:20 +00003complete, freecompletion \- file name completion
rsccfa37a72004-04-10 18:53:55 +00004.SH SYNOPSIS
5.B #include <u.h>
6.br
7.B #include <libc.h>
8.br
9.B #include <complete.h>
10.PP
11.ft L
12.nf
13.ta \w' 'u +\w' 'u +\w' 'u +\w' 'u +\w' 'u
14typedef struct Completion Completion;
15struct Completion{
16 uchar advance; /* whether forward progress has been made */
17 uchar complete; /* whether the completion now represents a file or directory */
18 char *string; /* the string to advance, suffixed " " or "/" for file or directory */
19 int nmatch; /* number of files that matched */
20 int nfile; /* number of files returned */
21 char **filename; /* their names */
22};
23
24.fi
25.PP
26.B
27.ta \w'\fLchar* 'u
28
29.PP
30.B
31Completion* complete(char *dir, char *s);
32.PP
33.B
34void freecompletion(Completion *c);
35.SH DESCRIPTION
36The
37.I complete
38function implements file name completion.
39Given a directory
40.I dir
41and a string
42.IR s ,
43it returns an analysis of the file names in that directory that begin with the string
44.IR s .
45The fields
46.B nmatch
47and
48.B nfile
49will be set to the number of files that match the prefix and
50.B filename
51will be filled in with their names.
52If the file named is a directory, a slash character will be appended to it.
53.PP
54If no files match the string,
55.B nmatch
56will be zero, but
57.I complete
58will return the full set of files in the directory, with
59.I nfile
60set to their number.
61.PP
62The flag
63.B advance
64reports whether the string
65.I s
66can be extended without changing the set of files that match. If true,
67.B string
68will be set to the extension; that is, the value of
69.B string
70may be appended to
71.I s
72by the caller to extend the embryonic file name unambiguously.
73.PP
74The flag
75.B complete
76reports whether the extended file name uniquely identifies a file.
77If true,
78.B string
79will be suffixed with a blank, or a slash and a blank,
80depending on whether the resulting file name identifies a plain file or a directory.
81.PP
82The
83.I freecompletion
84function frees a
85.B Completion
86structure and its contents.
87.PP
88In
89.IR rio (1)
90and
91.IR acme (1),
92file name completion is triggered by a control-F character or an Insert character.
93.SH SOURCE
rscc3674de2005-01-11 17:37:33 +000094.B \*9/src/libcomplete
rsccfa37a72004-04-10 18:53:55 +000095.SH SEE ALSO
96.IR rio (1),
97.IR acme (1)
98.SH DIAGNOSTICS
99The
100.I complete
101function returns a null pointer and sets
102.I errstr
103if the directory is unreadable or there is some other error.
104.SH BUGS
105The behavior of file name completion should be controlled by the plumber.