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.weechat-hashes
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 urlScan(struct Tag tag, const char *str);
|
||||||
void urlList(struct Tag tag);
|
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[]);
|
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);
|
urlList(tag);
|
||||||
}
|
}
|
||||||
static void inputOpen(struct Tag tag, char *params) {
|
static void inputOpen(struct Tag tag, char *params) {
|
||||||
if (!params) { urlOpen(tag, 1); return; }
|
size_t at = (params ? strtoul(strsep(¶ms, "-,"), NULL, 0) : 1);
|
||||||
size_t from = strtoul(strsep(¶ms, "-,"), NULL, 0);
|
size_t to = (params ? strtoul(params, NULL, 0) : at);
|
||||||
if (!params) { urlOpen(tag, from); return; }
|
urlOpen(tag, at - 1, to);
|
||||||
size_t to = strtoul(strsep(¶ms, "-,"), NULL, 0);
|
|
||||||
if (to < from) to = from;
|
|
||||||
for (size_t i = from; i <= to; ++i) {
|
|
||||||
urlOpen(tag, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inputView(struct Tag tag, char *params) {
|
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) {
|
void urlOpen(struct Tag tag, size_t at, size_t to) {
|
||||||
size_t count = 0;
|
size_t argc = 1;
|
||||||
|
char *argv[2 + RING_LEN] = { "open" };
|
||||||
|
size_t tagIndex = 0;
|
||||||
for (size_t i = 0; i < RING_LEN; ++i) {
|
for (size_t i = 0; i < RING_LEN; ++i) {
|
||||||
struct Entry entry = ring.buf[(ring.end - i) & (RING_LEN - 1)];
|
struct Entry entry = ring.buf[(ring.end - i) & (RING_LEN - 1)];
|
||||||
if (!entry.url || entry.tag != tag.id) continue;
|
if (!entry.url || entry.tag != tag.id) continue;
|
||||||
if (++count != fromEnd) continue;
|
if (tagIndex >= at && tagIndex < to) argv[argc++] = entry.url;
|
||||||
char *argv[] = { "open", entry.url, NULL };
|
tagIndex++;
|
||||||
spawn(argv);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (argc > 1) spawn(argv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue