1
0
forked from aniani/vim

updated for version 7.4.152

Problem:    Python: Cannot iterate over options.
Solution:   Add options iterator. (ZyX)
This commit is contained in:
Bram Moolenaar
2014-01-14 16:55:00 +01:00
parent 063a46ba77
commit 1028f4d75e
9 changed files with 261 additions and 6 deletions

View File

@@ -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
/*