about summary refs log tree commit diff
path: root/url.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-12 23:44:58 -0400
committerJune McEnroe <june@causal.agency>2018-08-12 23:44:58 -0400
commit19464369c3612ff8f431a2bed62861f4d20cabc4 (patch)
treeea395f5e50b548834fe085bf36b7fff09d1abbcc /url.c
parentAvoid setting mark if switching to the same view (diff)
downloadcatgirl-19464369c3612ff8f431a2bed62861f4d20cabc4.tar.gz
catgirl-19464369c3612ff8f431a2bed62861f4d20cabc4.zip
Fix /open ranges by passing all URLs to open(1)
This is going to be incompatible with xdg-open since it takes only one
URL at a time. Write a wrapper script.
Diffstat (limited to 'url.c')
-rw-r--r--url.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/url.c b/url.c
index b7172ce..3a7628f 100644
--- a/url.c
+++ b/url.c
@@ -72,14 +72,15 @@ void urlList(struct Tag tag) {
 	}
 }
 
-void urlOpen(struct Tag tag, size_t fromEnd) {
-	size_t count = 0;
+void urlOpen(struct Tag tag, size_t at, size_t to) {
+	size_t argc = 1;
+	char *argv[2 + RING_LEN] = { "open" };
+	size_t tagIndex = 0;
 	for (size_t i = 0; i < RING_LEN; ++i) {
 		struct Entry entry = ring.buf[(ring.end - i) & (RING_LEN - 1)];
 		if (!entry.url || entry.tag != tag.id) continue;
-		if (++count != fromEnd) continue;
-		char *argv[] = { "open", entry.url, NULL };
-		spawn(argv);
-		return;
+		if (tagIndex >= at && tagIndex < to) argv[argc++] = entry.url;
+		tagIndex++;
 	}
+	if (argc > 1) spawn(argv);
 }