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.master
parent
a09df5f697
commit
19464369c3
2
chat.h
2
chat.h
|
@ -141,7 +141,7 @@ void tabReject(void);
|
|||
|
||||
void urlScan(struct Tag tag, const char *str);
|
||||
void urlList(struct Tag tag);
|
||||
void urlOpen(struct Tag tag, size_t fromEnd);
|
||||
void urlOpen(struct Tag tag, size_t at, size_t to);
|
||||
|
||||
void spawn(char *const argv[]);
|
||||
|
||||
|
|
11
input.c
11
input.c
|
@ -90,14 +90,9 @@ static void inputUrl(struct Tag tag, char *params) {
|
|||
urlList(tag);
|
||||
}
|
||||
static void inputOpen(struct Tag tag, char *params) {
|
||||
if (!params) { urlOpen(tag, 1); return; }
|
||||
size_t from = strtoul(strsep(¶ms, "-,"), NULL, 0);
|
||||
if (!params) { urlOpen(tag, from); return; }
|
||||
size_t to = strtoul(strsep(¶ms, "-,"), NULL, 0);
|
||||
if (to < from) to = from;
|
||||
for (size_t i = from; i <= to; ++i) {
|
||||
urlOpen(tag, i);
|
||||
}
|
||||
size_t at = (params ? strtoul(strsep(¶ms, "-,"), NULL, 0) : 1);
|
||||
size_t to = (params ? strtoul(params, NULL, 0) : at);
|
||||
urlOpen(tag, at - 1, to);
|
||||
}
|
||||
|
||||
static void inputView(struct Tag tag, char *params) {
|
||||
|
|
13
url.c
13
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue