summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.143
blob: 905f15995f3b8951f96fd9384b27e44cdf63dd8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
To: vim-dev@vim.org
Subject: Patch 7.2.143
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.143
Problem:    No command line completion for ":cscope" command.
Solution:   Add the completion for ":cscope". (Dominique Pelle)
Files:	    src/ex_docmd.c, src/ex_getln.c, src/if_cscope.c,
	    src/proto/if_cscope.pro, src/vim.h


*** ../vim-7.2.142/src/ex_docmd.c	Wed Mar 11 15:36:01 2009
--- src/ex_docmd.c	Wed Mar 11 15:45:04 2009
***************
*** 3683,3688 ****
--- 3683,3693 ----
  	case CMD_highlight:
  	    set_context_in_highlight_cmd(xp, arg);
  	    break;
+ #ifdef FEAT_CSCOPE
+ 	case CMD_cscope:
+ 	    set_context_in_cscope_cmd(xp, arg);
+ 	    break;
+ #endif
  #ifdef FEAT_LISTCMDS
  	case CMD_bdelete:
  	case CMD_bwipeout:
***************
*** 5187,5192 ****
--- 5192,5200 ----
      {EXPAND_AUGROUP, "augroup"},
      {EXPAND_BUFFERS, "buffer"},
      {EXPAND_COMMANDS, "command"},
+ #if defined(FEAT_CSCOPE)
+     {EXPAND_CSCOPE, "cscope"},
+ #endif
  #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
      {EXPAND_USER_DEFINED, "custom"},
      {EXPAND_USER_LIST, "customlist"},
*** ../vim-7.2.142/src/ex_getln.c	Thu Mar  5 03:13:51 2009
--- src/ex_getln.c	Wed Mar 11 15:45:04 2009
***************
*** 4518,4523 ****
--- 4518,4526 ----
  	    {EXPAND_EVENTS, get_event_name, TRUE},
  	    {EXPAND_AUGROUP, get_augroup_name, TRUE},
  #endif
+ #ifdef FEAT_CSCOPE
+ 	    {EXPAND_CSCOPE, get_cscope_name, TRUE},
+ #endif
  #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
  	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
  	    {EXPAND_LANGUAGE, get_lang_arg, TRUE},
*** ../vim-7.2.142/src/if_cscope.c	Wed Jan 28 16:03:51 2009
--- src/if_cscope.c	Wed Mar 11 15:56:07 2009
***************
*** 93,104 ****
      (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
  }
  
  /*
   * PRIVATE: do_cscope_general
   *
!  * find the command, print help if invalid, and the then call the
!  * corresponding command function,
!  * called from do_cscope and do_scscope
   */
      static void
  do_cscope_general(eap, make_split)
--- 93,209 ----
      (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
  }
  
+ #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+ 
+ static enum
+ {
+     EXP_CSCOPE_SUBCMD,	/* expand ":cscope" sub-commands */
+     EXP_CSCOPE_FIND,	/* expand ":cscope find" arguments */
+     EXP_CSCOPE_KILL	/* expand ":cscope kill" arguments */
+ } expand_what;
+ 
+ /*
+  * Function given to ExpandGeneric() to obtain the cscope command
+  * expansion.
+  */
+ /*ARGSUSED*/
+     char_u *
+ get_cscope_name(xp, idx)
+     expand_T	*xp;
+     int		idx;
+ {
+     switch (expand_what)
+     {
+     case EXP_CSCOPE_SUBCMD:
+ 	/* Complete with sub-commands of ":cscope":
+ 	 * add, find, help, kill, reset, show */
+ 	return (char_u *)cs_cmds[idx].name;
+     case EXP_CSCOPE_FIND:
+ 	{
+ 	    const char *query_type[] =
+ 	    {
+ 		"c", "d", "e", "f", "g", "i", "s", "t", NULL
+ 	    };
+ 
+ 	    /* Complete with query type of ":cscope find {query_type}".
+ 	     * {query_type} can be letters (c, d, ... t) or numbers (0, 1,
+ 	     * ..., 8) but only complete with letters, since numbers are
+ 	     * redundant. */
+ 	    return (char_u *)query_type[idx];
+ 	}
+     case EXP_CSCOPE_KILL:
+ 	{
+ 	    int			i;
+ 	    int			current_idx = 0;
+ 	    static char_u	connection[2];
+ 
+ 	    /* ":cscope kill" accepts connection numbers or partial names of
+ 	     * the pathname of the cscope database as argument.  Only complete
+ 	     * with connection numbers. -1 can also be used to kill all
+ 	     * connections. */
+ 	    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+ 	    {
+ 		if (csinfo[i].fname == NULL)
+ 		    continue;
+ 		if (current_idx++ == idx)
+ 		{
+ 		    /* Connection number fits in one character since
+ 		     * CSCOPE_MAX_CONNECTIONS is < 10 */
+ 		    connection[0] = i + '0';
+ 		    connection[1] = NUL;
+ 		    return connection;
+ 		}
+ 	    }
+ 	    return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
+ 	}
+     default:
+ 	return NULL;
+     }
+ }
+ 
+ /*
+  * Handle command line completion for :cscope command.
+  */
+     void
+ set_context_in_cscope_cmd(xp, arg)
+     expand_T	*xp;
+     char_u	*arg;
+ {
+     char_u	*p;
+ 
+     /* Default: expand subcommands */
+     xp->xp_context = EXPAND_CSCOPE;
+     expand_what = EXP_CSCOPE_SUBCMD;
+     xp->xp_pattern = arg;
+ 
+     /* (part of) subcommand already typed */
+     if (*arg != NUL)
+     {
+ 	p = skiptowhite(arg);
+ 	if (*p != NUL)		    /* past first word */
+ 	{
+ 	    xp->xp_pattern = skipwhite(p);
+ 	    if (*skiptowhite(xp->xp_pattern) != NUL)
+ 		xp->xp_context = EXPAND_NOTHING;
+ 	    else if (STRNICMP(arg, "add", p - arg) == 0)
+ 		xp->xp_context = EXPAND_FILES;
+ 	    else if (STRNICMP(arg, "kill", p - arg) == 0)
+ 		expand_what = EXP_CSCOPE_KILL;
+ 	    else if (STRNICMP(arg, "find", p - arg) == 0)
+ 		expand_what = EXP_CSCOPE_FIND;
+ 	    else
+ 		xp->xp_context = EXPAND_NOTHING;
+ 	}
+     }
+ }
+ 
+ #endif /* FEAT_CMDL_COMPL */
+ 
  /*
   * PRIVATE: do_cscope_general
   *
!  * Find the command, print help if invalid, and then call the corresponding
!  * command function.
   */
      static void
  do_cscope_general(eap, make_split)
*** ../vim-7.2.142/src/proto/if_cscope.pro	Thu Sep  6 17:38:21 2007
--- src/proto/if_cscope.pro	Wed Mar 11 15:57:03 2009
***************
*** 1,4 ****
--- 1,6 ----
  /* if_cscope.c */
+ char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
+ void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg));
  void do_cscope __ARGS((exarg_T *eap));
  void do_scscope __ARGS((exarg_T *eap));
  void do_cstag __ARGS((exarg_T *eap));
*** ../vim-7.2.142/src/vim.h	Sun Feb 22 02:36:36 2009
--- src/vim.h	Wed Mar 11 15:45:04 2009
***************
*** 708,713 ****
--- 708,714 ----
  #define EXPAND_USER_DEFINED	30
  #define EXPAND_USER_LIST	31
  #define EXPAND_SHELLCMD		32
+ #define EXPAND_CSCOPE		33
  
  /* Values for exmode_active (0 is no exmode) */
  #define EXMODE_NORMAL		1
*** ../vim-7.2.142/src/version.c	Wed Mar 18 12:20:35 2009
--- src/version.c	Wed Mar 18 12:48:08 2009
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     143,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
234. You started college as a chemistry major, and walk out four years
     later as an Internet provider.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///