complete 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .TH COMPLETE 2
  2. .SH NAME
  3. complete \- file name completion
  4. .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
  14. typedef struct Completion Completion;
  15. struct 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 nfile; /* number of files that matched */
  20. char **filename; /* their names */
  21. };
  22. .fi
  23. .PP
  24. .B
  25. .ta \w'\fLchar* 'u
  26. .PP
  27. .B
  28. Completion* complete(char *dir, char *s);
  29. .PP
  30. .B
  31. void freecompletion(Completion *c);
  32. .SH DESCRIPTION
  33. The
  34. .I complete
  35. function implements file name completion.
  36. Given a directory
  37. .I dir
  38. and a string
  39. .IR s ,
  40. it returns an analysis of the file names in that directory that begin with the string
  41. .IR s .
  42. The field
  43. .B nfile
  44. will be set to the number of files that match the prefix and
  45. .B filename
  46. will be filled in with their names.
  47. If the file named is a directory, a slash character will be appended to it.
  48. .PP
  49. The flag
  50. .B advance
  51. reports whether the string
  52. .I s
  53. can be extended without changing the set of files that match. If true,
  54. .B string
  55. will be set to the extension; that is, the value of
  56. .B string
  57. may be appended to
  58. .I s
  59. by the caller to extend the embryonic file name unambiguously.
  60. .PP
  61. The flag
  62. .B complete
  63. reports whether the extended file name uniquely identifies a file.
  64. If true,
  65. .B string
  66. will be suffixed with a blank, or a slash and a blank,
  67. depending on whether the resulting file name identifies a plain file or a directory.
  68. .PP
  69. The
  70. .I freecompletion
  71. function frees a
  72. .B Completion
  73. structure and its contents.
  74. .PP
  75. In
  76. .IR rio (1)
  77. and
  78. .IR acme (1),
  79. file name completion is triggered by a control-F character or an Insert character.
  80. .SH SOURCE
  81. .B /sys/src/libcomplete
  82. .SH SEE ALSO
  83. .IR rio (1),
  84. .IR acme (1)
  85. .SH DIAGNOSTICS
  86. The
  87. .I complete
  88. function returns a null pointer and sets
  89. .I errstr
  90. if the directory is unreadable or there is some other error.
  91. .SH BUGS
  92. The behavior of file name completion should be controlled by the plumber.