From 35cd2a86ed8ec3c053d10152799725dbba2ff44b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 11 Jul 2020 14:37:12 -0400 Subject: Preserve search query when clicking network or context columns --- html.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/html.c b/html.c index 562f909..49b65e9 100644 --- a/html.c +++ b/html.c @@ -203,11 +203,13 @@ static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) { return error; } -static enum kcgi_err eventNetwork(struct khtmlreq *html, struct Event event) { - if (!event.network) return KCGI_OK; +static enum kcgi_err +eventNetwork(struct khtmlreq *html, struct Scope scope, struct Event event) { + if (scope.network || !scope.query || !event.network) return KCGI_OK; char *href = khttp_urlpart( - NULL, NULL, Pages[Contexts], + NULL, NULL, Pages[Search], Keys[Network].name, event.network, + Keys[Query].name, scope.query, NULL ); if (!href) err(EX_OSERR, "khttp_urlpart"); @@ -220,12 +222,16 @@ static enum kcgi_err eventNetwork(struct khtmlreq *html, struct Event event) { return error; } -static enum kcgi_err eventContext(struct khtmlreq *html, struct Event event) { - if (!event.network || !event.context) return KCGI_OK; +static enum kcgi_err +eventContext(struct khtmlreq *html, struct Scope scope, struct Event event) { + if (scope.context || !scope.query || !event.network || !event.context) { + return KCGI_OK; + } char *href = khttp_urlpart( - NULL, NULL, Pages[Events], + NULL, NULL, Pages[Search], Keys[Network].name, event.network, Keys[Context].name, event.context, + Keys[Query].name, scope.query, NULL ); if (!href) err(EX_OSERR, "khttp_urlpart"); @@ -297,8 +303,8 @@ htmlEvent(struct khtmlreq *html, struct Scope scope, struct Event event) { KATTR__MAX ) || eventTime(html, event) - || (scope.network ? 0 : eventNetwork(html, event)) - || (scope.context ? 0 : eventContext(html, event)) + || eventNetwork(html, scope, event) + || eventContext(html, scope, event) || eventNick(html, event) || eventMessage(html, event) || khtml_closeelem(html, 1); -- cgit 1.4.1