commit 73c6a2635434c4eab1372498c43ce59e3f1cc7e1
parent 9015bd315a48c3f79232ec5993e26ddb2ef79173
Author: hhvn <dev@hhvn.uk>
Date: Wed, 9 Feb 2022 20:30:15 +0000
H command - display history links
Diffstat:
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/zygo.1 b/zygo.1
@@ -136,6 +136,8 @@ Print uri of link where the bar normally is.
Yank URI of link.
.It Y
Yank current URI.
+.It H
+View all links in history.
.El
.Sh SEE OTHER
.Xr cgo 1
diff --git a/zygo.c b/zygo.c
@@ -378,9 +378,9 @@ Elem *
list_idget(List **l, size_t id) {
int i;
- if (!l || !(*l) || (*l)->len == 0 || id >= (*l)->len)
+ if (!l || !(*l) || (*l)->len == 0 || id > (*l)->len)
return NULL;
- for (i = 0; i < (*l)->len; i++)
+ for (i = 0; i <= (*l)->len; i++)
if ((*((*l)->elems + i))->id == id)
return *((*l)->elems + i);
return NULL;
@@ -943,7 +943,7 @@ idgo(size_t id) {
void
run(void) {
wint_t c;
- int ret;
+ int ret, i;
size_t il;
Elem *e;
char tmperror[BUFLEN];
@@ -1104,6 +1104,25 @@ run(void) {
case 'h':
manpage();
break;
+ case 'H':
+ if (history) {
+ list_append(&history, current);
+ elem_free(current);
+ current = NULL;
+ list_free(&page);
+ for (i = list_len(&history) - 2; i >= 0; i--) {
+ e = list_get(&history, i);
+ free(e->desc);
+ e->desc = elemtouri(e);
+ list_append(&page, e);
+ }
+ list_append(&page, e);
+ draw_bar();
+ draw_page();
+ } else {
+ error("no history");
+ }
+ break;
case 'Y':
checkcurrent();
yank(current);
@@ -1130,7 +1149,7 @@ run(void) {
case '/':
case 'a':
case 'y':
- if (c == 'a' || c == '+' || c == 'y') {
+ if (c == 'a' || c == 'y') {
checkcurrent();
}
ui.cmd = (char)c;