/* Synchronize new -style option with the old one. */ void style_update_new(struct options *oo, const char *name, const char *newname) { int value; struct grid_cell *gc; struct options_entry *o; /* It's a colour or attribute, but with no -style equivalent. */ if (newname == NULL) return; o = options_find1(oo, newname); if (o == NULL) o = options_set_style(oo, newname, "default", 0); gc = &o->style; o = options_find1(oo, name); if (o == NULL) o = options_set_number(oo, name, 8); value = o->num; if (strstr(name, "-bg") != NULL) colour_set_bg(gc, value); else if (strstr(name, "-fg") != NULL) colour_set_fg(gc, value); else if (strstr(name, "-attr") != NULL) gc->attr = value; }
/* Set a style option. */ struct options_entry * cmd_set_option_style(struct cmd *self, struct cmd_q *cmdq, const struct options_table_entry *oe, struct options *oo, const char *value) { struct args *args = self->args; struct options_entry *o; int append; append = args_has(args, 'a'); if ((o = options_set_style(oo, oe->name, value, append)) == NULL) { cmdq_error(cmdq, "bad style: %s", value); return (NULL); } style_update_old(oo, oe->name, &o->style); return (o); }
/* Populate an options tree from a table. */ void options_table_populate_tree( const struct options_table_entry *table, struct options *oo) { const struct options_table_entry *oe; for (oe = table; oe->name != NULL; oe++) { switch (oe->type) { case OPTIONS_TABLE_STRING: options_set_string(oo, oe->name, "%s", oe->default_str); break; case OPTIONS_TABLE_STYLE: options_set_style(oo, oe->name, oe->default_str, 0); break; default: options_set_number(oo, oe->name, oe->default_num); break; } } }
/* Populate an options tree from a table. */ void options_table_populate_tree(enum options_table_scope scope, struct options *oo) { const struct options_table_entry *oe; for (oe = options_table; oe->name != NULL; oe++) { if (oe->scope == OPTIONS_TABLE_NONE) fatalx("no scope for %s", oe->name); if (oe->scope != scope) continue; switch (oe->type) { case OPTIONS_TABLE_STRING: options_set_string(oo, oe->name, "%s", oe->default_str); break; case OPTIONS_TABLE_STYLE: options_set_style(oo, oe->name, oe->default_str, 0); break; default: options_set_number(oo, oe->name, oe->default_num); break; } } }