summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2009-03-18 11:52:53 +0000
committerBram Moolenaar <Bram@vim.org>2009-03-18 11:52:53 +0000
commitf4580d80e21e3299bfc71666942f43a5872782ab (patch)
treeb394e637977407485c14de64c698b7a251e3f337
parent8281f445186de469b9466d119c840d7ccdedfe87 (diff)
downloadvim-git-f4580d80e21e3299bfc71666942f43a5872782ab.tar.gz
updated for version 7.2-143v7.2.143
-rw-r--r--src/ex_docmd.c8
-rw-r--r--src/ex_getln.c3
-rw-r--r--src/if_cscope.c111
-rw-r--r--src/proto/if_cscope.pro2
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h1
6 files changed, 124 insertions, 3 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 66d7fa96c..38acbfeba 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3683,6 +3683,11 @@ set_one_cmd_context(xp, buff)
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,6 +5192,9 @@ static struct
{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"},
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 5cda65a07..3f1ea7180 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4518,6 +4518,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
{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},
diff --git a/src/if_cscope.c b/src/if_cscope.c
index a9a0506b8..57d1984bf 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -93,12 +93,117 @@ cs_usage_msg(x)
(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 the then call the
- * corresponding command function,
- * called from do_cscope and do_scscope
+ * Find the command, print help if invalid, and then call the corresponding
+ * command function.
*/
static void
do_cscope_general(eap, make_split)
diff --git a/src/proto/if_cscope.pro b/src/proto/if_cscope.pro
index 555a0a4b5..06885b2b6 100644
--- a/src/proto/if_cscope.pro
+++ b/src/proto/if_cscope.pro
@@ -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));
diff --git a/src/version.c b/src/version.c
index 8ba2de2ff..9a96e1a92 100644
--- a/src/version.c
+++ b/src/version.c
@@ -677,6 +677,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 143,
+/**/
142,
/**/
141,
diff --git a/src/vim.h b/src/vim.h
index e8a623ea2..7ea947e90 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -708,6 +708,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#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