comparison src/if_cscope.c @ 1858:ff5a4a71a761 v7.2.156

updated for version 7.2-156
author vimboss
date Wed, 22 Apr 2009 14:25:01 +0000
parents 44fe912b5a1b
children 6ed4a82fcfc6
comparison
equal deleted inserted replaced
1857:b88f0420148e 1858:ff5a4a71a761
96 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 96 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
97 97
98 static enum 98 static enum
99 { 99 {
100 EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */ 100 EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
101 EXP_SCSCOPE_SUBCMD, /* expand ":scscope" sub-commands */
101 EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */ 102 EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
102 EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */ 103 EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
103 } expand_what; 104 } expand_what;
104 105
105 /* 106 /*
110 char_u * 111 char_u *
111 get_cscope_name(xp, idx) 112 get_cscope_name(xp, idx)
112 expand_T *xp; 113 expand_T *xp;
113 int idx; 114 int idx;
114 { 115 {
116 int current_idx;
117 int i;
118
115 switch (expand_what) 119 switch (expand_what)
116 { 120 {
117 case EXP_CSCOPE_SUBCMD: 121 case EXP_CSCOPE_SUBCMD:
118 /* Complete with sub-commands of ":cscope": 122 /* Complete with sub-commands of ":cscope":
119 * add, find, help, kill, reset, show */ 123 * add, find, help, kill, reset, show */
120 return (char_u *)cs_cmds[idx].name; 124 return (char_u *)cs_cmds[idx].name;
125 case EXP_SCSCOPE_SUBCMD:
126 /* Complete with sub-commands of ":scscope": same sub-commands as
127 * ":cscope" but skip commands which don't support split windows */
128 for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
129 if (cs_cmds[i].cansplit)
130 if (current_idx++ == idx)
131 break;
132 return (char_u *)cs_cmds[i].name;
121 case EXP_CSCOPE_FIND: 133 case EXP_CSCOPE_FIND:
122 { 134 {
123 const char *query_type[] = 135 const char *query_type[] =
124 { 136 {
125 "c", "d", "e", "f", "g", "i", "s", "t", NULL 137 "c", "d", "e", "f", "g", "i", "s", "t", NULL
131 * redundant. */ 143 * redundant. */
132 return (char_u *)query_type[idx]; 144 return (char_u *)query_type[idx];
133 } 145 }
134 case EXP_CSCOPE_KILL: 146 case EXP_CSCOPE_KILL:
135 { 147 {
136 int i;
137 int current_idx = 0;
138 static char_u connection[2]; 148 static char_u connection[2];
139 149
140 /* ":cscope kill" accepts connection numbers or partial names of 150 /* ":cscope kill" accepts connection numbers or partial names of
141 * the pathname of the cscope database as argument. Only complete 151 * the pathname of the cscope database as argument. Only complete
142 * with connection numbers. -1 can also be used to kill all 152 * with connection numbers. -1 can also be used to kill all
143 * connections. */ 153 * connections. */
144 for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++) 154 for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
145 { 155 {
146 if (csinfo[i].fname == NULL) 156 if (csinfo[i].fname == NULL)
147 continue; 157 continue;
148 if (current_idx++ == idx) 158 if (current_idx++ == idx)
149 { 159 {
163 173
164 /* 174 /*
165 * Handle command line completion for :cscope command. 175 * Handle command line completion for :cscope command.
166 */ 176 */
167 void 177 void
168 set_context_in_cscope_cmd(xp, arg) 178 set_context_in_cscope_cmd(xp, arg, cmdidx)
169 expand_T *xp; 179 expand_T *xp;
170 char_u *arg; 180 char_u *arg;
181 cmdidx_T cmdidx;
171 { 182 {
172 char_u *p; 183 char_u *p;
173 184
174 /* Default: expand subcommands */ 185 /* Default: expand subcommands */
175 xp->xp_context = EXPAND_CSCOPE; 186 xp->xp_context = EXPAND_CSCOPE;
176 expand_what = EXP_CSCOPE_SUBCMD;
177 xp->xp_pattern = arg; 187 xp->xp_pattern = arg;
188 expand_what = (cmdidx == CMD_scscope)
189 ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
178 190
179 /* (part of) subcommand already typed */ 191 /* (part of) subcommand already typed */
180 if (*arg != NUL) 192 if (*arg != NUL)
181 { 193 {
182 p = skiptowhite(arg); 194 p = skiptowhite(arg);