commit 7e021a59b14b0a11cd217202ab639a3e84a8b03f
parent 3df5625ab64036c425ee8687e3e932d898de52af
Author: hhvn <dev@hhvn.uk>
Date: Sat, 12 Mar 2022 18:33:41 +0000
Display multiple settings/commands with /help and /set
Diffstat:
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/commands.c b/src/commands.c
@@ -1307,6 +1307,7 @@ command_alias) {
COMMAND(
command_help) {
int cmdonly = 0;
+ int found = 0;
int i, j;
if (!str) {
@@ -1336,28 +1337,29 @@ command_help) {
}
for (i=0; commands[i].name && commands[i].func; i++) {
- if (strcmp(commands[i].name, str) == 0) {
- hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", str);
+ if (strncmp(commands[i].name, str, strlen(str)) == 0) {
+ found = 1;
+ hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", commands[i].name);
for (j=0; commands[i].description[j]; j++)
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP :%s", commands[i].description[j]);
- hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help");
- return;
}
}
if (!cmdonly) {
for (i=0; config[i].name; i++) {
- if (strcmp(config[i].name, str) == 0) {
- hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", str);
+ if (strncmp(config[i].name, str, strlen(str)) == 0) {
+ found = 1;
+ hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", config[i].name);
for (j=0; config[i].description[j]; j++)
hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI :%s", config[i].description[j]);
- hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help");
- return;
}
}
}
- ui_error("no help on '%s'", str);
+ if (found)
+ hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help");
+ else
+ ui_error("no help on '%s'", str);
}
COMMAND(
diff --git a/src/config.c b/src/config.c
@@ -1241,24 +1241,25 @@ config_getl(char *name) {
void
config_get_print(char *name) {
- int i;
+ int i, found;
- for (i=0; config[i].name; i++) {
- if (strcmp(config[i].name, name) == 0) {
+ for (i = found = 0; config[i].name; i++) {
+ if (strncmp(config[i].name, name, strlen(name)) == 0) {
if (config[i].valtype == Val_string)
hist_format(main_buf, Activity_status, HIST_SHOW, "SELF_UI :%s: %s",
- name, config[i].str);
+ config[i].name, config[i].str);
else if (config[i].valtype == Val_pair || config[i].valtype == Val_colourpair)
hist_format(main_buf, Activity_status, HIST_SHOW, "SELF_UI :%s: {%ld, %ld}",
- name, config[i].pair[0], config[i].pair[1]);
+ config[i].name, config[i].pair[0], config[i].pair[1]);
else
hist_format(main_buf, Activity_status, HIST_SHOW, "SELF_UI :%s: %ld",
- name, config[i].num);
- return;
+ config[i].name, config[i].num);
+ found = 1;
}
}
- ui_error("no such configuration variable: '%s'", name);
+ if (!found)
+ ui_error("no such configuration variable: '%s'", name);
}
char *