commit 1c9df161195d77311909582b44edb5f6701ab34a
parent 02555998c8e7ef28fa18e0365b592fb0cae91a8d
Author: hhvn <dev@hhvn.uk>
Date: Wed, 1 Dec 2021 22:30:56 +0000
ui.c hirc.1.header: implement n- vars
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/hirc.1.header b/hirc.1.header
@@ -70,7 +70,10 @@ Topic of the selected channel, or from the message.
Selected server, or server the message was from.
.It ${n}
Where n is a non-zero positive integer.
-This selects a paramater of a message.
+This selects a parameter of a message.
+.It ${n-}
+Where n is a non-zero positive integer.
+This selects all parameters following n.
.It ${time}
May also be written as ${time:format} where format is passed to
.Xr strftime 3 "."
diff --git a/ui.c b/ui.c
@@ -886,6 +886,16 @@ ui_format(char *format, struct History *hist) {
continue;
}
}
+ /* All are digits except a trailing '-' */
+ if (*p == '-' && *(p+1) == '\0' && hist) {
+ pn = strtol(tmp, NULL, 10) - 1;
+ if (pn >= 0 && param_len(params) >= pn) {
+ for (; *(params+pn) != NULL; pn++)
+ rc += snprintf(&ret[rc], sizeof(ret) - rc, "%s%s", *(params+pn), *(params+pn+1) ? " " : "");
+ format = strchr(format, '}') + 1;
+ continue;
+ }
+ }
if (hist && tmp && strncmp(tmp, "time:", strlen("time:")) == 0 || strcmp(tmp, "time") == 0) {
tmp = strtok(tmp, ":");