comparison src/ex_cmds2.c @ 2068:98a2a6e6b966 v7.2.353

updated for version 7.2.353 Problem: No command line completion for ":profile". Solution: Complete the subcommand and file name.
author Bram Moolenaar <bram@zimbu.org>
date Wed, 03 Feb 2010 15:14:22 +0100
parents fb1222c880fc
children 5a84b6388a55
comparison
equal deleted inserted replaced
2067:8e2d14a3e7d2 2068:98a2a6e6b966
1113 /* The rest is similar to ":breakadd". */ 1113 /* The rest is similar to ":breakadd". */
1114 ex_breakadd(eap); 1114 ex_breakadd(eap);
1115 } 1115 }
1116 } 1116 }
1117 1117
1118 /* Command line expansion for :profile. */
1119 static enum
1120 {
1121 PEXP_SUBCMD, /* expand :profile sub-commands */
1122 PEXP_FUNC, /* expand :profile func {funcname} */
1123 } pexpand_what;
1124
1125 static char *pexpand_cmds[] = {
1126 "start",
1127 #define PROFCMD_START 0
1128 "pause",
1129 #define PROFCMD_PAUSE 1
1130 "continue",
1131 #define PROFCMD_CONTINUE 2
1132 "func",
1133 #define PROFCMD_FUNC 3
1134 "file",
1135 #define PROFCMD_FILE 4
1136 NULL
1137 #define PROFCMD_LAST 5
1138 };
1139
1140 /*
1141 * Function given to ExpandGeneric() to obtain the profile command
1142 * specific expansion.
1143 */
1144 char_u *
1145 get_profile_name(xp, idx)
1146 expand_T *xp UNUSED;
1147 int idx;
1148 {
1149 switch (pexpand_what)
1150 {
1151 case PEXP_SUBCMD:
1152 return (char_u *)pexpand_cmds[idx];
1153 /* case PEXP_FUNC: TODO */
1154 default:
1155 return NULL;
1156 }
1157 }
1158
1159 /*
1160 * Handle command line completion for :profile command.
1161 */
1162 void
1163 set_context_in_profile_cmd(xp, arg)
1164 expand_T *xp;
1165 char_u *arg;
1166 {
1167 char_u *end_subcmd;
1168 int len;
1169
1170 /* Default: expand subcommands. */
1171 xp->xp_context = EXPAND_PROFILE;
1172 pexpand_what = PEXP_SUBCMD;
1173 xp->xp_pattern = arg;
1174
1175 end_subcmd = skiptowhite(arg);
1176 if (*end_subcmd == NUL)
1177 return;
1178
1179 len = end_subcmd - arg;
1180 if (len == 5 && STRNCMP(arg, "start", 5) == 0)
1181 {
1182 xp->xp_context = EXPAND_FILES;
1183 xp->xp_pattern = skipwhite(end_subcmd);
1184 return;
1185 }
1186
1187 /* TODO: expand function names after "func" */
1188 xp->xp_context = EXPAND_NOTHING;
1189 }
1190
1118 /* 1191 /*
1119 * Dump the profiling info. 1192 * Dump the profiling info.
1120 */ 1193 */
1121 void 1194 void
1122 profile_dump() 1195 profile_dump()