about summary refs log tree commit diff
path: root/Src/Zle/comp.h
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-26 15:36:10 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-26 15:36:10 +0000
commite0b26186f1d3c1a3a580eb7e8a8199c25536f4e6 (patch)
treee4247c2507fa1a135740a3cd02e7405cbdbfa69a /Src/Zle/comp.h
parent56f338eb8bfd4bcdbf14b495ff8a34425c3527d4 (diff)
downloadzsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.tar.gz
zsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.tar.xz
zsh-e0b26186f1d3c1a3a580eb7e8a8199c25536f4e6.zip
manual/8424
Diffstat (limited to 'Src/Zle/comp.h')
-rw-r--r--Src/Zle/comp.h202
1 files changed, 62 insertions, 140 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 8b31d97fa..68575cff4 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -1,5 +1,5 @@
 /*
- * comp.h - header file for completion
+ * complete.h - header file for completion
  *
  * This file is part of zsh, the Z shell.
  *
@@ -27,143 +27,10 @@
  *
  */
 
-#undef compctlread
-
-typedef struct compctlp  *Compctlp;
-typedef struct compctl   *Compctl;
-typedef struct compcond  *Compcond;
-typedef struct patcomp   *Patcomp;
 typedef struct cmatcher  *Cmatcher;
 typedef struct cmlist    *Cmlist;
 typedef struct cpattern  *Cpattern;
 typedef struct menuinfo  *Menuinfo;
-
-/* node for compctl hash table (compctltab) */
-
-struct compctlp {
-    HashNode next;		/* next in hash chain               */
-    char *nam;			/* command name                     */
-    int flags;			/* CURRENTLY UNUSED                 */
-    Compctl cc;			/* pointer to the compctl desc.     */
-};
-
-/* for the list of pattern compctls */
-
-struct patcomp {
-    Patcomp next;
-    char *pat;
-    Compctl cc;
-};
-
-/* compctl -x condition */
-
-struct compcond {
-    Compcond and, or;		/* the next or'ed/and'ed conditions    */
-    int type;			/* the type (CCT_*)                    */
-    int n;			/* the array length                    */
-    union {			/* these structs hold the data used to */
-	struct {		/* test this condition                 */
-	    int *a, *b;		/* CCT_POS, CCT_NUMWORDS               */
-	}
-	r;
-	struct {		/* CCT_CURSTR, CCT_CURPAT,... */
-	    int *p;
-	    char **s;
-	}
-	s;
-	struct {		/* CCT_RANGESTR,... */
-	    char **a, **b;
-	}
-	l;
-    }
-    u;
-};
-
-#define CCT_UNUSED     0
-#define CCT_POS        1
-#define CCT_CURSTR     2
-#define CCT_CURPAT     3
-#define CCT_WORDSTR    4
-#define CCT_WORDPAT    5
-#define CCT_CURSUF     6
-#define CCT_CURPRE     7
-#define CCT_CURSUB     8
-#define CCT_CURSUBC    9
-#define CCT_NUMWORDS  10
-#define CCT_RANGESTR  11
-#define CCT_RANGEPAT  12
-#define CCT_QUOTE     13
-
-/* Contains the real description for compctls */
-
-struct compctl {
-    int refc;			/* reference count                         */
-    Compctl next;		/* next compctl for -x                     */
-    unsigned long mask, mask2;	/* masks of things to complete (CC_*)      */
-    char *keyvar;		/* for -k (variable)                       */
-    char *glob;			/* for -g (globbing)                       */
-    char *str;			/* for -s (expansion)                      */
-    char *func;			/* for -K (function)                       */
-    char *widget;		/* for -i (function)                       */
-    char *explain;		/* for -X (explanation)                    */
-    char *ylist;		/* for -y (user-defined desc. for listing) */
-    char *prefix, *suffix;	/* for -P and -S (prefix, suffix)          */
-    char *subcmd;		/* for -l (command name to use)            */
-    char *substr;		/* for -1 (command name to use)            */
-    char *withd;		/* for -w (with directory                  */
-    char *hpat;			/* for -H (history pattern)                */
-    int hnum;			/* for -H (number of events to search)     */
-    char *gname;		/* for -J and -V (group name)              */
-    Compctl ext;		/* for -x (first of the compctls after -x) */
-    Compcond cond;		/* for -x (condition for this compctl)     */
-    Compctl xor;		/* for + (next of the xor'ed compctls)     */
-    Cmatcher matcher;		/* matcher control (-M) */
-    char *mstr;			/* matcher string */
-};
-
-/* objects to complete (mask) */
-#define CC_FILES	(1<<0)
-#define CC_COMMPATH	(1<<1)
-#define CC_REMOVE	(1<<2)
-#define CC_OPTIONS	(1<<3)
-#define CC_VARS		(1<<4)
-#define CC_BINDINGS	(1<<5)
-#define CC_ARRAYS	(1<<6)
-#define CC_INTVARS	(1<<7)
-#define CC_SHFUNCS	(1<<8)
-#define CC_PARAMS	(1<<9)
-#define CC_ENVVARS	(1<<10)
-#define CC_JOBS		(1<<11)
-#define CC_RUNNING	(1<<12)
-#define CC_STOPPED	(1<<13)
-#define CC_BUILTINS	(1<<14)
-#define CC_ALREG	(1<<15)
-#define CC_ALGLOB	(1<<16)
-#define CC_USERS	(1<<17)
-#define CC_DISCMDS	(1<<18)
-#define CC_EXCMDS	(1<<19)
-#define CC_SCALARS	(1<<20)
-#define CC_READONLYS	(1<<21)
-#define CC_SPECIALS	(1<<22)
-#define CC_DELETE	(1<<23)
-#define CC_NAMED	(1<<24)
-#define CC_QUOTEFLAG	(1<<25)
-#define CC_EXTCMDS	(1<<26)
-#define CC_RESWDS	(1<<27)
-#define CC_DIRS		(1<<28)
-
-#define CC_EXPANDEXPL	(1<<30)
-#define CC_RESERVED	(1<<31)
-
-/* objects to complete (mask2) */
-#define CC_NOSORT	(1<<0)
-#define CC_XORCONT	(1<<1)
-#define CC_CCCONT	(1<<2)
-#define CC_PATCONT	(1<<3)
-#define CC_DEFCONT	(1<<4)
-#define CC_UNIQCON      (1<<5)
-#define CC_UNIQALL      (1<<6)
-
 typedef struct cexpl *Cexpl;
 typedef struct cmgroup *Cmgroup;
 typedef struct cmatch *Cmatch;
@@ -191,7 +58,6 @@ struct cmgroup {
     int ecount;			/* number of explanation string */
     Cexpl *expls;		/* explanation strings */
     int ccount;			/* number of compctls used */
-    Compctl *ccs;		/* the compctls used */
     LinkList lexpls;		/* list of explanation string while building */
     LinkList lmatches;		/* list of matches */
     LinkList lfmatches;		/* list of matches without fignore */
@@ -272,22 +138,68 @@ struct cmatcher {
     int ralen;			/* length of right anchor */
 };
 
-
 #define CMF_LINE  1
 #define CMF_LEFT  2
 #define CMF_RIGHT 4
 
-
 struct cpattern {
     Cpattern next;		/* next sub-pattern */
     unsigned char tab[256];	/* table of matched characters */
     int equiv;			/* if this is a {...} class */
 };
 
-/* Flags for makecomplist*(). Things not to do. */
+/* This is a special return value for parse_cmatcher(), *
+ * signalling an error. */
+
+#define pcm_err ((Cmatcher) 1)
+
+/* Information about what to put on the line as the unambiguous string.
+ * The code always keeps lists of these structs up to date while
+ * matches are added (in the aminfo structs below).
+ * The lists have two levels: in the first one we have one struct per
+ * word-part, where parts are separated by the anchors of `*' patterns.
+ * These structs have pointers (in the prefix and suffix fields) to
+ * lists of cline structs describing the strings before or after the
+ * the anchor. */
+
+typedef struct cline *Cline;
+typedef struct clsub Clsub;
+
+struct cline {
+    Cline next;
+    int flags;
+    char *line;
+    int llen;
+    char *word;
+    int wlen;
+    char *orig;
+    int olen;
+    int slen;
+    Cline prefix, suffix;
+    int min, max;
+};
 
-#define CFN_FIRST   1
-#define CFN_DEFAULT 2
+#define CLF_MISS      1
+#define CLF_DIFF      2
+#define CLF_SUF       4
+#define CLF_MID       8
+#define CLF_NEW      16
+#define CLF_LINE     32
+#define CLF_JOIN     64
+#define CLF_MATCHED 128
+
+/* Information for ambiguous completions. One for fignore ignored and   *
+ * one for normal completion. */
+
+typedef struct aminfo *Aminfo;
+
+struct aminfo {
+    Cmatch firstm;		/* the first match                        */
+    int exact;			/* if there was an exact match            */
+    Cmatch exactm;		/* the exact match (if any)               */
+    int count;			/* number of matches                      */
+    Cline line;			/* unambiguous line string                */
+};
 
 /* Information about menucompletion stuff. */
 
@@ -463,3 +375,13 @@ struct chdata {
 
 #define CP_KEYPARAMS   27
 #define CP_ALLKEYS     ((unsigned int) 0x7ffffff)
+
+/* Types of completion. */
+
+#define COMP_COMPLETE        0
+#define COMP_LIST_COMPLETE   1
+#define COMP_SPELL           2
+#define COMP_EXPAND          3
+#define COMP_EXPAND_COMPLETE 4
+#define COMP_LIST_EXPAND     5
+#define COMP_ISEXPAND(X) ((X) >= COMP_EXPAND)