summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-01-14 16:55:00 +0100
committerBram Moolenaar <Bram@vim.org>2014-01-14 16:55:00 +0100
commit1028f4d75ee04261f1338620c22f388a05098bb0 (patch)
tree46c911fb9aaca60b7caad845dcb8dce1915eaf06 /src/option.c
parent063a46ba77c3251f0b5245e872dcbad003c71024 (diff)
downloadvim-1028f4d75ee04261f1338620c22f388a05098bb0.zip
updated for version 7.4.152
Problem: Python: Cannot iterate over options. Solution: Add options iterator. (ZyX)
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c67
1 files changed, 65 insertions, 2 deletions
diff --git a/src/option.c b/src/option.c
index 4e087a58b..8c72da639 100644
--- a/src/option.c
+++ b/src/option.c
@@ -8861,7 +8861,7 @@ get_option_value(name, numval, stringval, opt_flags)
}
#endif
-#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
+#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
/*
* Returns the option attributes and its value. Unlike the above function it
* will return either global value or local value of the option depending on
@@ -8874,7 +8874,8 @@ get_option_value(name, numval, stringval, opt_flags)
* opt_type). Uses
*
* Returned flags:
- * 0 hidden or unknown option
+ * 0 hidden or unknown option, also option that does not have requested
+ * type (see SREQ_* in vim.h)
* see SOPT_* in vim.h for other flags
*
* Possible opt_type values: see SREQ_* in vim.h
@@ -8997,6 +8998,68 @@ get_option_value_strict(name, numval, stringval, opt_type, from)
return r;
}
+
+/*
+ * Iterate over options. First argument is a pointer to a pointer to a structure
+ * inside options[] array, second is option type like in the above function.
+ *
+ * If first argument points to NULL it is assumed that iteration just started
+ * and caller needs the very first value.
+ * If first argument points to the end marker function returns NULL and sets
+ * first argument to NULL.
+ *
+ * Returns full option name for current option on each call.
+ */
+ char_u *
+option_iter_next(option, opt_type)
+ void **option;
+ int opt_type;
+{
+ struct vimoption *ret = NULL;
+ do
+ {
+ if (*option == NULL)
+ *option = (void *) options;
+ else if (((struct vimoption *) (*option))->fullname == NULL)
+ {
+ *option = NULL;
+ return NULL;
+ }
+ else
+ *option = (void *) (((struct vimoption *) (*option)) + 1);
+
+ ret = ((struct vimoption *) (*option));
+
+ /* Hidden option */
+ if (ret->var == NULL)
+ {
+ ret = NULL;
+ continue;
+ }
+
+ switch (opt_type)
+ {
+ case SREQ_GLOBAL:
+ if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
+ ret = NULL;
+ break;
+ case SREQ_BUF:
+ if (!(ret->indir & PV_BUF))
+ ret = NULL;
+ break;
+ case SREQ_WIN:
+ if (!(ret->indir & PV_WIN))
+ ret = NULL;
+ break;
+ default:
+ EMSG2(_(e_intern2), "option_iter_next()");
+ return NULL;
+ }
+ }
+ while (ret == NULL);
+
+ return (char_u *)ret->fullname;
+}
#endif
/*