Lua: set and get config options

Still needs more work, especially the error handling.
This commit is contained in:
Pasi Kallinen
2021-02-06 18:57:41 +02:00
parent c4d9ceda9d
commit d817564a6a
5 changed files with 276 additions and 126 deletions

View File

@@ -7102,6 +7102,34 @@ optfn_o_status_hilites(int optidx UNUSED, int req, boolean negated UNUSED,
}
#endif /*STATUS_HILITES*/
/* Get string value of configuration option.
* Currently handles only boolean and compound options.
*/
char *
get_option_value(const char *optname)
{
static char retbuf[BUFSZ];
boolean *bool_p;
int i;
for (i = 0; allopt[i].name != 0; i++)
if (!strcmp(optname, allopt[i].name)) {
if (allopt[i].opttyp == BoolOpt && (bool_p = allopt[i].addr) != 0) {
Sprintf(retbuf, "%s", *bool_p ? "true" : "false");
return retbuf;
} else if (allopt[i].opttyp == CompOpt && allopt[i].optfn) {
int reslt = optn_err;
reslt = (*allopt[i].optfn)(allopt[i].idx, get_val,
FALSE, retbuf, empty_optstr);
if (reslt == optn_ok && retbuf[0])
return retbuf;
return (char *) 0;
}
}
return (char *) 0;
}
/* the 'O' command */
int
doset(void) /* changing options via menu by Per Liboriussen */