diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-04-11 10:31:28 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-04-11 10:31:28 +0200 |
| commit | 3f3125ee103401cf561b38b00f9b34187b8d6a52 (patch) | |
| tree | 5d7ac85675550ee40679a90d1beb9c57c7d0ab67 /vis.c | |
| parent | 9ae7a429320e7db76743448e7f3b216003de8755 (diff) | |
| download | vis-3f3125ee103401cf561b38b00f9b34187b8d6a52.tar.gz vis-3f3125ee103401cf561b38b00f9b34187b8d6a52.tar.xz | |
Eliminate global state for :set options
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -1392,15 +1392,13 @@ static bool cmd_set(Filerange *range, enum CmdOpt cmdopt, const char *argv[]) { [OPTION_NUMBER_RELATIVE] = { { "relativenumbers", "rnu" }, OPTION_TYPE_BOOL }, }; - static Map *optmap = NULL; - - if (!optmap) { - if (!(optmap = map_new())) + if (!vis->options) { + if (!(vis->options = map_new())) return false; for (int i = 0; i < LENGTH(options); i++) { options[i].index = i; for (const char **name = options[i].names; *name; name++) { - if (!map_put(optmap, *name, &options[i])) + if (!map_put(vis->options, *name, &options[i])) return false; } } @@ -1416,7 +1414,7 @@ static bool cmd_set(Filerange *range, enum CmdOpt cmdopt, const char *argv[]) { OptionDef *opt = NULL; if (!strncasecmp(argv[1], "no", 2)) { - opt = map_closest(optmap, argv[1]+2); + opt = map_closest(vis->options, argv[1]+2); if (opt && opt->type == OPTION_TYPE_BOOL) invert = true; else @@ -1424,7 +1422,7 @@ static bool cmd_set(Filerange *range, enum CmdOpt cmdopt, const char *argv[]) { } if (!opt) - opt = map_closest(optmap, argv[1]); + opt = map_closest(vis->options, argv[1]); if (!opt) { editor_info_show(vis, "Unknown option: `%s'", argv[1]); return false; |
