diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-07-03 07:42:05 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 21:09:16 -0700 |
commit | ff02ed8ea5e32a1016c710f4625145e3abcc062b (patch) | |
tree | 6253b2227d7ab3a8075a6ae52e51c1240c22510e /src | |
parent | e391cbd1215569ee7654b1d93153fcd14c2a60a7 (diff) |
til: make til_modlue_setup() nested usage aware
When setting up a nested module, the HERMETIC modules shouldn't
be considered as eligible nor should one be the preffered option
(rtv).
This uses the presence of a parent on the settings as a heuristic
for if it's a nested scenario (no parent == root). When nested
the default changes to "compose" from "rtv", and HERMETIC modules
are omitted from the listed values.
Diffstat (limited to 'src')
-rw-r--r-- | src/til.c | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -22,7 +22,8 @@ /* Copyright (C) 2016 Vito Caputo <vcaputo@pengaru.com> */ -#define DEFAULT_MODULE "rtv" +#define TIL_DEFAULT_ROOT_MODULE "rtv" +#define TIL_DEFAULT_NESTED_MODULE "compose" static til_threads_t *til_threads; @@ -468,19 +469,31 @@ int til_module_setup(const til_settings_t *settings, til_setting_t **res_setting name = til_settings_get_value_by_idx(settings, 0, &setting); if (!name || !setting->desc) { - const char *values[nelems(modules) + 1] = {}; - const char *annotations[nelems(modules) + 1] = {}; - int r; + const char *values[nelems(modules) + 1] = {}; + const char *annotations[nelems(modules) + 1] = {}; + const til_settings_t *parent; + int r; + + parent = til_settings_get_parent(settings); for (unsigned i = 0, j = 0; i < nelems(modules); i++) { /* XXX: This only skips experimental modules when no module setting was pre-specified, * which allows accessing the experimental modules via the CLI without showing them * in the interactive setup where the desc provides the displayed list of values before - * the module setting gets added. It seems a big kludge-y and fragile, but works well + * the module setting gets added. It seems a bit kludge-y and fragile, but works well * enough for now to get at the experimental modules during testing/development. + * + * XXX: To enable using this in nested setup scenarios, where HERMETIC modules really + * shouldn't be listed, it now skips hermetic if settings->parent is set. That's + * used to imply this isn't the "root" module setup, hence hermetic is inappropriate. */ - if (!name && (modules[i]->flags & TIL_MODULE_EXPERIMENTAL)) - continue; + if (!name) { + if (modules[i]->flags & TIL_MODULE_EXPERIMENTAL) + continue; + + if (modules[i]->flags & (parent ? TIL_MODULE_HERMETIC : 0)) + continue; + } values[j] = modules[i]->name; annotations[j] = modules[i]->description; @@ -492,7 +505,7 @@ int til_module_setup(const til_settings_t *settings, til_setting_t **res_setting .name = "Renderer module", .key = NULL, .regex = "[a-zA-Z0-9]+", - .preferred = DEFAULT_MODULE, + .preferred = parent ? TIL_DEFAULT_NESTED_MODULE : TIL_DEFAULT_ROOT_MODULE, .values = values, .annotations = annotations, .as_label = 1 |