diff -ur links-0.92/intl/english.lng links-unhistory/intl/english.lng
--- links-0.92/intl/english.lng Mon Jun 12 05:31:10 2000
+++ links-unhistory/intl/english.lng Fri Sep 1 22:55:00 2000
@@ -77,6 +77,7 @@
T_GOTO_URL, "Go to URL",
T_GO_BACK, "Go back",
T_HISTORY, "History",
+T_UNHISTORY, "Unhistory",
T_RELOAD, "Reload",
T_SAVE_AS, "Save as",
T_SAVE_URL_AS, "Save URL as",
@@ -291,6 +292,7 @@
T_HK_GOTO_URL, "G",
T_HK_GO_BACK, "B",
T_HK_HISTORY, "H",
+T_HK_UNHISTORY, "T",
T_HK_RELOAD, "R",
T_HK_SAVE_AS, "V",
T_HK_SAVE_URL_AS, "U",
diff -ur links-0.92/links.h links-unhistory/links.h
--- links-0.92/links.h Mon Jun 19 02:36:55 2000
+++ links-unhistory/links.h Sat Sep 2 02:49:49 2000
@@ -1352,6 +1352,7 @@
#define WTD_IMGMAP 2
#define WTD_RELOAD 3
#define WTD_BACK 4
+#define WTD_UNBACK 5
#define cur_loc(x) ((struct location *)((x)->history.next))
@@ -1395,6 +1396,7 @@
struct session *next;
struct session *prev;
struct list_head history;
+ struct list_head unhistory;
struct terminal *term;
struct window *win;
int id;
@@ -1450,6 +1452,7 @@
void abort_loading(struct session *);
void goto_imgmap(struct session *, unsigned char *, unsigned char *, unsigned char *);
void go_back(struct session *);
+void go_unback(struct session *);
void reload(struct session*, int);
struct frame *ses_find_frame(struct session *, unsigned char *);
struct frame *ses_change_frame_url(struct session *, unsigned char *, unsigned char *);
diff -ur links-0.92/menu.c links-unhistory/menu.c
--- links-0.92/menu.c Fri Jun 23 07:20:20 2000
+++ links-unhistory/menu.c Sat Sep 2 10:20:51 2000
@@ -259,9 +259,8 @@
while (steps > 1) {
struct location *loc = ses->history.next;
if ((void *) loc == &ses->history) return;
- loc = loc->next;
- if ((void *) loc == &ses->history) return;
- destroy_location(loc);
+ del_from_list(loc);
+ add_to_list(ses->unhistory, loc);
--steps;
}
@@ -270,6 +269,22 @@
go_back(ses);
}
+void go_unbackwards(struct terminal *term, void *psteps, struct session *ses)
+{
+ int steps = (int) psteps;
+
+ abort_loading(ses);
+
+ while (steps--) {
+ struct location *loc = ses->unhistory.next;
+ if ((void *) loc == &ses->unhistory) return;
+ del_from_list(loc);
+ add_to_list(ses->history, loc);
+ }
+
+ go_unback(ses);
+}
+
struct menu_item no_hist_menu[] = {
TEXT(T_NO_HISTORY), "", M_BAR, NULL, NULL, 0, 0,
NULL, NULL, 0, NULL, NULL, 0, 0
@@ -291,6 +306,20 @@
else do_menu(term, mi, ses);
}
+void unhistory_menu(struct terminal *term, void *ddd, struct session *ses)
+{
+ struct location *l;
+ struct menu_item *mi = NULL;
+ int n = 0;
+ foreach(l, ses->unhistory) {
+ if (!mi && !(mi = new_menu(3))) return;
+ add_to_menu(&mi, stracpy(l->vs.url), "", "", MENU_FUNC go_unbackwards, (void *) n, 0);
+ n++;
+ }
+ if (!n) do_menu(term, no_hist_menu, ses);
+ else do_menu(term, mi, ses);
+}
+
struct menu_item no_downloads_menu[] = {
TEXT(T_NO_DOWNLOADS), "", M_BAR, NULL, NULL, 0, 0,
NULL, NULL, 0, NULL, NULL, 0, 0
@@ -959,6 +988,7 @@
TEXT(T_GOTO_URL), "g", TEXT(T_HK_GOTO_URL), MENU_FUNC menu_goto_url, (void *)0, 0, 0,
TEXT(T_GO_BACK), "<-", TEXT(T_HK_GO_BACK), MENU_FUNC menu_go_back, (void *)0, 0, 0,
TEXT(T_HISTORY), ">", TEXT(T_HK_HISTORY), MENU_FUNC history_menu, (void *)0, 1, 0,
+ TEXT(T_UNHISTORY), ">", TEXT(T_HK_UNHISTORY), MENU_FUNC unhistory_menu, (void *)0, 1, 0,
TEXT(T_RELOAD), "Ctrl-R", TEXT(T_HK_RELOAD), MENU_FUNC menu_reload, (void *)0, 0, 0,
};
diff -ur links-0.92/session.c links-unhistory/session.c
--- links-0.92/session.c Wed Jun 28 20:19:25 2000
+++ links-unhistory/session.c Sat Sep 2 09:57:04 2000
@@ -276,7 +276,8 @@
loc = ses->history.next;
if (ses->search_word) mem_free(ses->search_word), ses->search_word = NULL;
if ((void *)loc == &ses->history) return;
- destroy_location(loc);
+ del_from_list(loc);
+ add_to_list(ses->unhistory, loc);
loc = ses->history.next;
if ((void *)loc == &ses->history) return;
if (!strcmp(loc->vs.url, ses->loading_url)) return;
@@ -284,6 +285,17 @@
ses_forward(ses);
}
+void ses_unback(struct session *ses)
+{
+ struct location *loc;
+ free_files(ses);
+ loc = ses->unhistory.next;
+ if (ses->search_word) mem_free(ses->search_word), ses->search_word = NULL;
+ if ((void *)loc == &ses->unhistory) return;
+ del_from_list(loc);
+ add_to_list(ses->history, loc);
+}
+
void end_load(struct status *, struct session *);
void doc_end_load(struct status *, struct session *);
void file_end_load(struct status *, struct file_to_load *);
@@ -920,7 +932,7 @@
return 2;
}
if (gp) mem_free(gp);
- if (w == WTD_BACK) {
+ if (w == WTD_BACK || w == WTD_UNBACK) {
ses_goto(ses, u, NULL, PRI_MAIN, NC_CACHE, WTD_RELOAD, NULL, end_load, 1);
return 2;
}
@@ -940,6 +952,7 @@
}
if (ses->wtd == WTD_IMGMAP) ses_imgmap(ses);
if (ses->wtd == WTD_BACK) ses_back(ses);
+ if (ses->wtd == WTD_UNBACK) ses_unback(ses);
if (ses->wtd == WTD_RELOAD) ses_back(ses), ses_forward(ses);
if ((*stat)->state >= 0) change_connection(&ses->loading, *stat = &cur_loc(ses)->stat, PRI_MAIN);
else cur_loc(ses)->stat.state = ses->loading.state;
@@ -1135,6 +1148,7 @@
if ((ses = mem_alloc(sizeof(struct session)))) {
memset(ses, 0, sizeof(struct session));
init_list(ses->history);
+ init_list(ses->unhistory);
init_list(ses->scrn_frames);
init_list(ses->more_files);
ses->term = term;
@@ -1287,18 +1301,8 @@
if (ses->screen) detach_formatted(ses->screen), mem_free(ses->screen);
foreach(fdc, ses->scrn_frames) detach_formatted(fdc);
free_list(ses->scrn_frames);
- while ((void *)(l = ses->history.next) != &ses->history) {
- struct frame *frm;
- while ((void *)(frm = l->frames.next) != &l->frames) {
- destroy_vs(&frm->vs);
- mem_free(frm->name);
- del_from_list(frm);
- mem_free(frm);
- }
- destroy_vs(&l->vs);
- del_from_list(l);
- mem_free(l);
- }
+ foreach(l, ses->history) destroy_location(l);
+ foreach(l, ses->unhistory) destroy_location(l);
if (ses->loading_url) mem_free(ses->loading_url);
if (ses->display_timer != -1) kill_timer(ses->display_timer);
if (ses->goto_position) mem_free(ses->goto_position);
@@ -1380,6 +1384,18 @@
if (!(url = stracpy(((struct location *)ses->history.next)->next->vs.url)))
return;
ses_goto(ses, url, NULL, PRI_MAIN, NC_ALWAYS_CACHE, WTD_BACK, NULL, end_load, 0);
+}
+
+void go_unback(struct session *ses)
+{
+ unsigned char *url;
+ ses->reloadlevel = NC_CACHE;
+ if (ses->unhistory.next == &ses->unhistory)
+ return;
+ abort_loading(ses);
+ if (!(url = stracpy(((struct location *)ses->unhistory.next)->vs.url)))
+ return;
+ ses_goto(ses, url, NULL, PRI_MAIN, NC_ALWAYS_CACHE, WTD_UNBACK, NULL, end_load, 1);
}
void goto_url_w(struct session *ses, unsigned char *url, unsigned char *target, int wtd)
diff -ur links-0.92/view.c links-unhistory/view.c
--- links-0.92/view.c Sun Jun 18 19:56:17 2000
+++ links-unhistory/view.c Sat Sep 2 03:04:40 2000
@@ -1399,6 +1399,11 @@
go_back(ses);
}
+void unback(struct session *ses, struct f_data_c *f, int a)
+{
+ go_unback(ses);
+}
+
void selected_item(struct terminal *term, void *pitem, struct session *ses)
{
int item = (int)pitem;
@@ -1959,6 +1964,10 @@
if (ev->x == KBD_LEFT) {
back(ses, NULL, 0);
goto x;
+ }
+ if (upcase(ev->x) == 'U') {
+ unback(ses, NULL, 0);
+ goto x;
}
if (upcase(ev->x) == 'R' && ev->y == KBD_CTRL) {
reload(ses, -1);