1 /* 2 * compctl.h - header file for completion 3 * 4 * This file is part of zsh, the Z shell. 5 * 6 * Copyright (c) 1992-1997 Paul Falstad 7 * All rights reserved. 8 * 9 * Permission is hereby granted, without written agreement and without 10 * license or royalty fees, to use, copy, modify, and distribute this 11 * software and to distribute modified versions of this software for any 12 * purpose, provided that the above copyright notice and the following 13 * two paragraphs appear in all copies of this software. 14 * 15 * In no event shall Paul Falstad or the Zsh Development Group be liable 16 * to any party for direct, indirect, special, incidental, or consequential 17 * damages arising out of the use of this software and its documentation, 18 * even if Paul Falstad and the Zsh Development Group have been advised of 19 * the possibility of such damage. 20 * 21 * Paul Falstad and the Zsh Development Group specifically disclaim any 22 * warranties, including, but not limited to, the implied warranties of 23 * merchantability and fitness for a particular purpose. The software 24 * provided hereunder is on an "as is" basis, and Paul Falstad and the 25 * Zsh Development Group have no obligation to provide maintenance, 26 * support, updates, enhancements, or modifications. 27 * 28 */ 29 30 #undef compctlread 31 32 typedef struct compctlp *Compctlp; 33 typedef struct compctl *Compctl; 34 typedef struct compcond *Compcond; 35 typedef struct patcomp *Patcomp; 36 37 /* node for compctl hash table (compctltab) */ 38 39 struct compctlp { 40 struct hashnode node; 41 Compctl cc; /* pointer to the compctl desc. */ 42 }; 43 44 /* for the list of pattern compctls */ 45 46 struct patcomp { 47 Patcomp next; 48 char *pat; 49 Compctl cc; 50 }; 51 52 /* compctl -x condition */ 53 54 struct compcond { 55 Compcond and, or; /* the next or'ed/and'ed conditions */ 56 int type; /* the type (CCT_*) */ 57 int n; /* the array length */ 58 union { /* these structs hold the data used to */ 59 struct { /* test this condition */ 60 int *a, *b; /* CCT_POS, CCT_NUMWORDS */ 61 } 62 r; 63 struct { /* CCT_CURSTR, CCT_CURPAT,... */ 64 int *p; 65 char **s; 66 } 67 s; 68 struct { /* CCT_RANGESTR,... */ 69 char **a, **b; 70 } 71 l; 72 } 73 u; 74 }; 75 76 #define CCT_UNUSED 0 77 #define CCT_POS 1 78 #define CCT_CURSTR 2 79 #define CCT_CURPAT 3 80 #define CCT_WORDSTR 4 81 #define CCT_WORDPAT 5 82 #define CCT_CURSUF 6 83 #define CCT_CURPRE 7 84 #define CCT_CURSUB 8 85 #define CCT_CURSUBC 9 86 #define CCT_NUMWORDS 10 87 #define CCT_RANGESTR 11 88 #define CCT_RANGEPAT 12 89 #define CCT_QUOTE 13 90 91 /* Contains the real description for compctls */ 92 93 struct compctl { 94 int refc; /* reference count */ 95 Compctl next; /* next compctl for -x */ 96 unsigned long mask, mask2; /* masks of things to complete (CC_*) */ 97 char *keyvar; /* for -k (variable) */ 98 char *glob; /* for -g (globbing) */ 99 char *str; /* for -s (expansion) */ 100 char *func; /* for -K (function) */ 101 char *explain; /* for -X (explanation) */ 102 char *ylist; /* for -y (user-defined desc. for listing) */ 103 char *prefix, *suffix; /* for -P and -S (prefix, suffix) */ 104 char *subcmd; /* for -l (command name to use) */ 105 char *substr; /* for -1 (command name to use) */ 106 char *withd; /* for -w (with directory */ 107 char *hpat; /* for -H (history pattern) */ 108 int hnum; /* for -H (number of events to search) */ 109 char *gname; /* for -J and -V (group name) */ 110 Compctl ext; /* for -x (first of the compctls after -x) */ 111 Compcond cond; /* for -x (condition for this compctl) */ 112 Compctl xor; /* for + (next of the xor'ed compctls) */ 113 Cmatcher matcher; /* matcher control (-M) */ 114 char *mstr; /* matcher string */ 115 }; 116 117 /* objects to complete (mask) */ 118 #define CC_FILES (1<<0) 119 #define CC_COMMPATH (1<<1) 120 #define CC_REMOVE (1<<2) 121 #define CC_OPTIONS (1<<3) 122 #define CC_VARS (1<<4) 123 #define CC_BINDINGS (1<<5) 124 #define CC_ARRAYS (1<<6) 125 #define CC_INTVARS (1<<7) 126 #define CC_SHFUNCS (1<<8) 127 #define CC_PARAMS (1<<9) 128 #define CC_ENVVARS (1<<10) 129 #define CC_JOBS (1<<11) 130 #define CC_RUNNING (1<<12) 131 #define CC_STOPPED (1<<13) 132 #define CC_BUILTINS (1<<14) 133 #define CC_ALREG (1<<15) 134 #define CC_ALGLOB (1<<16) 135 #define CC_USERS (1<<17) 136 #define CC_DISCMDS (1<<18) 137 #define CC_EXCMDS (1<<19) 138 #define CC_SCALARS (1<<20) 139 #define CC_READONLYS (1<<21) 140 #define CC_SPECIALS (1<<22) 141 #define CC_DELETE (1<<23) 142 #define CC_NAMED (1<<24) 143 #define CC_QUOTEFLAG (1<<25) 144 #define CC_EXTCMDS (1<<26) 145 #define CC_RESWDS (1<<27) 146 #define CC_DIRS (1<<28) 147 148 #define CC_EXPANDEXPL (1<<30) 149 #define CC_RESERVED (1<<31) 150 151 /* objects to complete (mask2) */ 152 #define CC_NOSORT (1<<0) 153 #define CC_XORCONT (1<<1) 154 #define CC_CCCONT (1<<2) 155 #define CC_PATCONT (1<<3) 156 #define CC_DEFCONT (1<<4) 157 #define CC_UNIQCON (1<<5) 158 #define CC_UNIQALL (1<<6) 159