void owl_variable_get_help(const owl_variable *v, owl_fmtext *fm) { char *tostring; const char *default_str; owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n"); owl_fmtext_append_normal(fm, OWL_TABSTR); owl_fmtext_append_normal(fm, owl_variable_get_name(v)); owl_fmtext_append_normal(fm, " - "); owl_fmtext_append_normal(fm, owl_variable_get_summary(v)); owl_fmtext_append_normal(fm, "\n\n"); owl_fmtext_append_normal(fm, "Current: "); tostring = owl_variable_get_tostring(v); owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>")); g_free(tostring); owl_fmtext_append_normal(fm, "\n\n"); default_str = owl_variable_get_default_tostring(v); owl_fmtext_append_normal(fm, "Default: "); owl_fmtext_append_normal(fm, (default_str ? default_str : "<null>")); owl_fmtext_append_normal(fm, "\n\n"); owl_fmtext_append_normal(fm, "Valid Settings: "); owl_fmtext_append_normal(fm, owl_variable_get_validsettings(v)); owl_fmtext_append_normal(fm, "\n\n"); if (v->description && *v->description) { owl_fmtext_append_normal(fm, "Description:\n"); owl_fmtext_append_normal(fm, owl_variable_get_description(v)); owl_fmtext_append_normal(fm, "\n\n"); } }
void owl_variable_get_help(owl_vardict *d, char *name, owl_fmtext *fm) { char buff[1024]; int bufflen = 1023; owl_variable *v; if (!name || (v = owl_dict_find_element(d, name)) == NULL || !v->get_fn) { owl_fmtext_append_normal(fm, "No such variable...\n"); return; } owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n"); owl_fmtext_append_normal(fm, OWL_TABSTR); owl_fmtext_append_normal(fm, name); owl_fmtext_append_normal(fm, " - "); owl_fmtext_append_normal(fm, v->summary); owl_fmtext_append_normal(fm, "\n\n"); owl_fmtext_append_normal(fm, "Current: "); owl_variable_get_tostring(d, name, buff, bufflen); owl_fmtext_append_normal(fm, buff); owl_fmtext_append_normal(fm, "\n\n"); if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) { v->get_tostring_fn(v, buff, bufflen, &(v->ival_default)); } else { v->get_tostring_fn(v, buff, bufflen, v->pval_default); } owl_fmtext_append_normal(fm, "Default: "); owl_fmtext_append_normal(fm, buff); owl_fmtext_append_normal(fm, "\n\n"); owl_fmtext_append_normal(fm, "Valid Settings: "); owl_fmtext_append_normal(fm, owl_variable_get_validsettings(v)); owl_fmtext_append_normal(fm, "\n\n"); if (v->description && *v->description) { owl_fmtext_append_normal(fm, "Description:\n"); owl_fmtext_append_normal(fm, owl_variable_get_description(v)); owl_fmtext_append_normal(fm, "\n\n"); } }