Lua: set and get config options
Still needs more work, especially the error handling.
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user