MCPcopy Create free account
hub / github.com/NetHack/NetHack / optfn_symset

Function optfn_symset

src/options.c:4166–4236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4164extern const char *const known_restrictions[]; /* symbols.c */
4165
4166staticfn int
4167optfn_symset(
4168 int optidx, int req, boolean negated UNUSED,
4169 char *opts, char *op)
4170{
4171 if (req == do_init) {
4172 return optn_ok;
4173 }
4174 if (req == do_set) {
4175 if (op != empty_optstr) {
4176 if (gs.symset[PRIMARYSET].name)
4177 free((genericptr_t) gs.symset[PRIMARYSET].name),
4178 gs.symset[PRIMARYSET].name = 0;
4179 gs.symset[PRIMARYSET].name = dupstr(op);
4180 if (!read_sym_file(PRIMARYSET)) {
4181 clear_symsetentry(PRIMARYSET, TRUE);
4182 config_error_add(
4183 "Unable to load symbol set \"%s\" from \"%s\"", op,
4184 SYMBOLS);
4185 return optn_err;
4186 } else {
4187 if (gs.symset[PRIMARYSET].handling) {
4188#ifndef ENHANCED_SYMBOLS
4189 if (gs.symset[PRIMARYSET].handling == H_UTF8) {
4190 config_error_add(
4191 "Unavailable symset handler \"%s\" for %s",
4192 known_handling[H_UTF8], op);
4193 load_symset("default", PRIMARYSET);
4194 }
4195#endif
4196 }
4197 switch_symbols(gs.symset[PRIMARYSET].name != (char *) 0);
4198 go.opt_need_redraw = go.opt_need_glyph_reset = TRUE;
4199 go.opt_symset_changed = TRUE;
4200 }
4201 } else
4202 return optn_err;
4203 return optn_ok;
4204 }
4205 if (req == get_val) {
4206 Sprintf(opts, "%s",
4207 gs.symset[PRIMARYSET].name ? gs.symset[PRIMARYSET].name
4208 : "default");
4209 if (gc.currentgraphics == PRIMARYSET && gs.symset[PRIMARYSET].name)
4210 Strcat(opts, ", active");
4211 if (gs.symset[PRIMARYSET].handling) {
4212 Sprintf(eos(opts), ", handler=%s",
4213 known_handling[gs.symset[PRIMARYSET].handling]);
4214 }
4215 return optn_ok;
4216 }
4217 if (req == get_cnf_val) {
4218 Sprintf(opts, "%s",
4219 gs.symset[PRIMARYSET].name ? gs.symset[PRIMARYSET].name
4220 : "default");
4221 return optn_ok;
4222 }
4223 if (req == do_handler) {

Callers

nothing calls this directly

Calls 11

dupstrFunction · 0.85
read_sym_fileFunction · 0.85
clear_symsetentryFunction · 0.85
config_error_addFunction · 0.85
load_symsetFunction · 0.85
switch_symbolsFunction · 0.85
eosFunction · 0.85
glyphid_cache_statusFunction · 0.85
fill_glyphid_cacheFunction · 0.85
handler_symsetFunction · 0.85
free_glyphid_cacheFunction · 0.85

Tested by

no test coverage detected