#include "ascii.h"
#include "ex.h"
#include "util.h"
+#include "completion.h"
typedef struct {
guint bits; /* the bits identify the events the command applies to */
return true;
}
+gboolean autocmd_fill_group_completion(GtkListStore *store, const char *input)
+{
+ GSList *lg;
+ gboolean found = false;
+ GtkTreeIter iter;
+
+ if (!input || !*input) {
+ for (lg = groups; lg; lg = lg->next) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, ((AuGroup*)lg->data)->name, -1);
+ found = true;
+ }
+ } else {
+ for (lg = groups; lg; lg = lg->next) {
+ char *value = ((AuGroup*)lg->data)->name;
+ if (g_str_has_prefix(value, input)) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, value, -1);
+ found = true;
+ }
+ }
+ }
+
+ return found;
+}
+
+gboolean autocmd_fill_event_completion(GtkListStore *store, const char *input)
+{
+ int i;
+ const char *value;
+ gboolean found = false;
+ GtkTreeIter iter;
+
+ if (!input || !*input) {
+ for (i = 0; i < LENGTH(events); i++) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, events[i].name, -1);
+ found = true;
+ }
+ } else {
+ for (i = 0; i < LENGTH(events); i++) {
+ value = events[i].name;
+ if (g_str_has_prefix(value, input)) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, value, -1);
+ found = true;
+ }
+ }
+ }
+
+ return found;
+}
+
/**
* Get the augroup by it's name.
*/
gboolean autocmd_augroup(char *name, gboolean delete);
gboolean autocmd_add(char *name, gboolean delete);
gboolean autocmd_run(AuEvent event, const char *uri, const char *group);
+gboolean autocmd_fill_group_completion(GtkListStore *store, const char *input);
+gboolean autocmd_fill_event_completion(GtkListStore *store, const char *input);
#endif /* end of include guard: _AUTOCMD_H */
#endif
skip_whitespace(&in);
parse_count(&in, arg);
- /* packup the current pointer so that we can restore the input pointer
- * if tha command name parsing fails */
+ /* Backup the current pointer so that we can restore the input pointer
+ * if tha command name parsing fails. */
before_cmdname = in;
- if (parse_command_name(&in, arg) && VB_IS_SPACE(*in)) {
+ /* Do ex command specific completion if the comman is recognized and
+ * there is a space after the command and the optional '!' bang. */
+ if (parse_command_name(&in, arg) && parse_bang(&in, arg) && VB_IS_SPACE(*in)) {
const char *token;
- /* get only the last word of input string for the completion for
- * bookmark tag completion */
+
+ /* Get only the last word of input string for the completion for
+ * bookmark tag completion. */
if (arg->code == EX_BMA) {
- /* find the end of the input and search for the next
- * whitespace toward the beginning */
+ /* Find the end of the input and search for the next
+ * whitespace toward the beginning. */
token = strrchr(in, '\0');
while (token >= in && !VB_IS_SPACE(*token)) {
token--;
}
} else {
- /* use all input except ot the command itself for the
- * completion */
+ /* Use all input except of the command and it's possible bang
+ * itself for the completion. */
token = in;
}
- /* save the string prefix that will not be part of completion like
- * the ':open ' if ':open something' is completed. this means that
+ /* Save the string prefix that will not be part of completion like
+ * the ':open ' if ':open something' is completed. This means that
* the completion will only the none prefix part of the input */
OVERWRITE_NSTRING(excomp.prefix, input, token - input + 1);
break;
case EX_SET:
- sort = true;
+ sort = true;
found = setting_fill_completion(store, token);
break;
found = handler_fill_completion(store, token);
break;
+#ifdef FEATURE_AUTOCMD
+ case EX_AUTOCMD:
+ sort = true;
+ found = autocmd_fill_event_completion(store, token);
+ break;
+
+ case EX_AUGROUP:
+ sort = true;
+ found = autocmd_fill_group_completion(store, token);
+ break;
+#endif
+
default:
break;
}
/* restore the 'in' pointer after try to parse command name */
in = before_cmdname;
- /* backup the parsed data so we can access them in
- * completion_select function */
+ /* Backup the parsed data so we can access them in
+ * completion_select function. */
excomp.count = arg->count;
if (ex_fill_completion(store, in)) {