summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NetSurf/Resources/en/Templates,fecbin4200 -> 4312 bytes
-rw-r--r--desktop/browser.c6
-rw-r--r--desktop/browser.h7
-rw-r--r--makefile2
-rw-r--r--riscos/dialog.c1
-rw-r--r--riscos/gui.c8
-rw-r--r--riscos/gui.h10
-rw-r--r--riscos/history.c280
-rw-r--r--riscos/window.c6
9 files changed, 316 insertions, 4 deletions
diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec
index 7ba6c3f83..85d89d1b7 100644
--- a/!NetSurf/Resources/en/Templates,fec
+++ b/!NetSurf/Resources/en/Templates,fec
Binary files differ
diff --git a/desktop/browser.c b/desktop/browser.c
index 67c0f93e5..846d915b3 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -265,6 +265,7 @@ void browser_window_open_location_historical(struct browser_window* bw,
browser_window_set_status(bw, "Opening page...");
browser_window_start_throbber(bw);
bw->time0 = clock();
+ bw->history_add = false;
bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0,
gui_window_get_width(bw->window), 0, false,
post_urlenc, post_multipart);
@@ -294,6 +295,7 @@ void browser_window_open_location_post(struct browser_window* bw,
assert(bw != 0 && url0 != 0);
url = url_join(url0, bw->url);
browser_window_open_location_historical(bw, url, post_urlenc, post_multipart);
+ bw->history_add = true;
/* TODO: move this to somewhere below CONTENT_MSG_READY below */
if (bw->history == NULL)
bw->history = history_create(NULL, url);
@@ -359,6 +361,10 @@ void browser_window_callback(content_msg msg, struct content *c,
bw->current_content = c;
bw->loading_content = 0;
bw->caret_callback = 0;
+ if (bw->history_add)
+ bw->history_entry = history_add(bw->history_entry, bw->url,
+ bw->current_content->title);
+ bw->history_add = false;
}
gui_window_set_redraw_safety(bw->window, previous_safety);
if (bw->current_content->status == CONTENT_STATUS_DONE) {
diff --git a/desktop/browser.h b/desktop/browser.h
index 2afbd83bb..e25472631 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -9,6 +9,7 @@
#ifndef _NETSURF_DESKTOP_BROWSER_H_
#define _NETSURF_DESKTOP_BROWSER_H_
+#include <stdbool.h>
#include <time.h>
#include "netsurf/content/content.h"
#include "netsurf/desktop/gui.h"
@@ -40,6 +41,7 @@ struct history
struct history* history_create(char* desc, char* url);
void history_remember(struct history* current, char* desc, char* url);
+struct history_entry;
struct browser_window
{
@@ -51,6 +53,8 @@ struct browser_window
void *current_content_state;
struct content* loading_content;
struct history* history;
+ struct history_entry *history_entry;
+ bool history_add;
clock_t time0;
char* url;
@@ -123,4 +127,7 @@ void browser_window_reformat(struct browser_window* bw, int scroll_to_top);
void browser_window_key_press(struct browser_window *bw, char key);
+struct history_entry * history_add(struct history_entry *current,
+ char *url, char *title);
+
#endif
diff --git a/makefile b/makefile
index e0b7569f2..619cd92d3 100644
--- a/makefile
+++ b/makefile
@@ -17,7 +17,7 @@ OBJECTS = $(OBJECTS_COMMON) \
menus.o mouseactions.o \
options.o textselection.o theme.o window.o \
draw.o gif.o jpeg.o plugin.o png.o sprite.o \
- about.o filetype.o font.o uri.o
+ about.o filetype.o font.o uri.o history.o
OBJECTS_DEBUG = $(OBJECTS_COMMON) \
netsurfd.o \
optionsd.o filetyped.o fontd.o
diff --git a/riscos/dialog.c b/riscos/dialog.c
index ac0474a88..a3022a7a5 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -36,7 +36,6 @@ static struct proxy_choices proxy_choices;
static struct theme_choices theme_choices;
-static wimp_w ro_gui_dialog_create(const char *template_name);
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
diff --git a/riscos/gui.c b/riscos/gui.c
index fa96860b7..e0d9ae8de 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -132,6 +132,7 @@ void gui_init(int argc, char** argv)
ro_gui_download_init();
ro_gui_menus_init();
ro_gui_401login_init();
+ ro_gui_history_init();
wimp_close_template();
ro_gui_icon_bar_create();
}
@@ -159,6 +160,7 @@ void ro_gui_icon_bar_create(void)
void gui_quit(void)
{
+ ro_gui_history_quit();
wimp_close_down(task_handle);
}
@@ -222,6 +224,8 @@ void gui_poll(bool active)
case wimp_REDRAW_WINDOW_REQUEST :
if (block.redraw.w == dialog_config_th)
ro_gui_redraw_config_th(&block.redraw);
+ else if (block.redraw.w == history_window)
+ ro_gui_history_redraw(&block.redraw);
else {
g = ro_lookup_gui_from_w(block.redraw.w);
if (g != NULL)
@@ -268,6 +272,8 @@ void gui_poll(bool active)
case wimp_MOUSE_CLICK :
if (block.pointer.w == wimp_ICON_BAR)
ro_gui_icon_bar_click(&(block.pointer));
+ else if (block.pointer.w == history_window)
+ ro_gui_history_click(&(block.pointer));
else
{
g = ro_lookup_gui_from_w(block.pointer.w);
@@ -398,6 +404,8 @@ void gui_multitask(void)
case wimp_REDRAW_WINDOW_REQUEST :
if (block.redraw.w == dialog_config_th)
ro_gui_redraw_config_th(&block.redraw);
+ else if (block.redraw.w == history_window)
+ ro_gui_history_redraw(&block.redraw);
else {
g = ro_lookup_gui_from_w(block.redraw.w);
if (g)
diff --git a/riscos/gui.h b/riscos/gui.h
index 967631032..e831d9f07 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -19,6 +19,7 @@
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th;
+extern wimp_w history_window;
extern wimp_menu *current_menu, *iconbar_menu, *browser_menu,
*combo_menu, *theme_menu;
extern int current_menu_x, current_menu_y, iconbar_menu_height;
@@ -101,6 +102,7 @@ void ro_gui_menu_selection(wimp_selection* selection);
/* in dialog.c */
void ro_gui_dialog_init(void);
+wimp_w ro_gui_dialog_create(const char *template_name);
void ro_gui_dialog_open(wimp_w w);
void ro_gui_dialog_click(wimp_pointer *pointer);
void ro_gui_dialog_close(wimp_w close);
@@ -138,6 +140,14 @@ void ro_gui_throb(void);
gui_window* ro_lookup_gui_from_w(wimp_w window);
gui_window* ro_lookup_gui_toolbar_from_w(wimp_w window);
+/* in history.c */
+void ro_gui_history_init(void);
+void ro_gui_history_quit(void);
+void ro_gui_history_open(struct browser_window *bw,
+ struct history_entry *entry, int wx, int wy);
+void ro_gui_history_redraw(wimp_draw *redraw);
+void ro_gui_history_click(wimp_pointer *pointer);
+
/* icon numbers */
#define ICON_CONFIG_SAVE 0
#define ICON_CONFIG_CANCEL 1
diff --git a/riscos/history.c b/riscos/history.c
new file mode 100644
index 000000000..0e9ea8545
--- /dev/null
+++ b/riscos/history.c
@@ -0,0 +1,280 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include "oslib/font.h"
+#include "oslib/wimp.h"
+#include "netsurf/riscos/gui.h"
+#include "netsurf/utils/log.h"
+#include "netsurf/utils/utils.h"
+
+#define SIZE 10
+#define WIDTH 300
+#define HEIGHT 100
+#define MARGIN 32
+
+/** A node in the history tree. */
+struct history_entry {
+ char *url; /**< Page URL. */
+ char *title; /**< Page title. */
+ struct history_entry *back;
+ struct history_entry *forward, *forward_pref, *forward_last;
+ struct history_entry *prev, *next;
+ unsigned int children;
+ int x, y, width;
+};
+
+static struct browser_window *history_bw;
+static struct history_entry *history_start;
+static struct history_entry *history_current;
+wimp_w history_window;
+font_f history_font;
+
+static void ro_gui_history_redraw_tree(struct history_entry *he,
+ int x0, int y0);
+static struct history_entry * ro_gui_history_click_find(struct history_entry *he,
+ int x, int y);
+
+
+/**
+ * Insert a url into the history tree.
+ *
+ * Takes a copy of the url and title and inserts an entry into the tree forward
+ * from current, returning the new entry. current may be 0 to start a new tree.
+ */
+
+struct history_entry * history_add(struct history_entry *current,
+ char *url, char *title)
+{
+ struct history_entry *entry = xcalloc(1, sizeof(*entry));
+ char *split;
+ int width;
+
+ font_scan_string(history_font, title, font_GIVEN_FONT | font_KERN,
+ (WIDTH - MARGIN - MARGIN) * 400, 0x7fffffff,
+ 0, 0, 0, &split, &width, 0, 0);
+
+ entry->url = xstrdup(url);
+ entry->title = xstrdup(title);
+ if (entry->title[split - title]) {
+ entry->title[split - title - 2] = 0x8c; /* ellipsis */
+ entry->title[split - title - 1] = 0;
+ }
+ entry->back = current;
+ entry->forward = entry->forward_pref = entry->forward_last = 0;
+ entry->next = 0;
+ entry->children = 0;
+ entry->width = width / 400;
+ if (current) {
+ entry->prev = current->forward_last;
+ if (current->forward_last)
+ current->forward_last->next = entry;
+ else
+ current->forward = entry;
+ current->forward_pref = current->forward_last = entry;
+ current->children++;
+ } else {
+ entry->prev = 0;
+ }
+ return entry;
+}
+
+
+/**
+ * Create history window.
+ */
+
+void ro_gui_history_init(void)
+{
+ history_window = ro_gui_dialog_create("history");
+ history_font = font_find_font("Homerton.Medium", 128, 128, 0, 0, 0, 0);
+}
+
+
+/**
+ * Free history window resources.
+ */
+
+void ro_gui_history_quit(void)
+{
+ font_lose_font(history_font);
+}
+
+
+/**
+ * Open history window at a specified entry.
+ */
+
+void ro_gui_history_open(struct browser_window *bw,
+ struct history_entry *entry, int wx, int wy)
+{
+ bool done = false;
+ unsigned int i, j;
+ int x, max_y = 0;
+ struct history_entry *row[SIZE], *row2[SIZE];
+ struct history_entry *he;
+ os_box box = {0, 0, 0, 0};
+
+ history_bw = bw;
+ history_current = entry;
+ for (history_start = entry;
+ history_start->back;
+ history_start = history_start->back)
+ ;
+
+ /* calculate layout */
+ for (i = 0; i != SIZE; i++)
+ row[i] = row2[i] = 0;
+ row[0] = history_start;
+ history_start->x = 0;
+ history_start->y = 0;
+ for (x = 1; !done; x++) {
+ for (i = 0; i != SIZE; i++) {
+ if (row[i]) {
+ for (j = i; j != SIZE && row2[j]; j++)
+ ;
+ if (j == SIZE) {
+ if (row[i]->forward)
+ row[i]->forward->x = -1;
+ break;
+ }
+ for (he = row[i]->forward; he; he = he->next) {
+ row2[j++] = he;
+ if (j == SIZE) {
+ if (he->next)
+ he->next->x = -1;
+ break;
+ }
+ }
+ if (j == SIZE)
+ break;
+ }
+ }
+ done = true;
+ for (i = 0; i != SIZE; i++) {
+ row[i] = row2[i];
+ if (row[i]) {
+ row[i]->x = x;
+ row[i]->y = i;
+ if (max_y < i)
+ max_y = i;
+ done = false;
+ }
+ row2[i] = 0;
+ }
+ }
+
+ box.x1 = WIDTH * (x - 1);
+ box.y0 = -HEIGHT * (max_y + 1);
+ wimp_set_extent(history_window, &box);
+ wimp_create_menu((wimp_menu *) history_window, wx, wy);
+}
+
+
+/**
+ * Redraw history window.
+ */
+
+void ro_gui_history_redraw(wimp_draw *redraw)
+{
+ osbool more;
+
+ more = wimp_redraw_window(redraw);
+ colourtrans_set_gcol(os_COLOUR_WHITE, 0, os_ACTION_OVERWRITE, 0);
+
+ while (more) {
+ ro_gui_history_redraw_tree(history_start,
+ redraw->box.x0 - redraw->xscroll,
+ redraw->box.y1 - redraw->yscroll);
+ more = wimp_get_rectangle(redraw);
+ }
+}
+
+
+/**
+ * Redraw history tree recursively.
+ */
+
+void ro_gui_history_redraw_tree(struct history_entry *he,
+ int x0, int y0)
+{
+ struct history_entry *c;
+
+ os_plot(os_MOVE_TO, x0 + he->x * WIDTH + MARGIN,
+ y0 - he->y * HEIGHT - MARGIN);
+ os_plot(os_PLOT_RECTANGLE | os_PLOT_BY, WIDTH - MARGIN - MARGIN,
+ -(HEIGHT - MARGIN - MARGIN));
+
+ if (he == history_current)
+ wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_RED);
+ else
+ wimp_set_font_colours(wimp_COLOUR_WHITE, wimp_COLOUR_BLACK);
+
+ font_paint(history_font, he->title,
+ font_OS_UNITS | font_GIVEN_FONT | font_KERN,
+ x0 + he->x * WIDTH + (WIDTH - he->width) / 2,
+ y0 - he->y * HEIGHT - MARGIN - 24,
+ 0, 0, 0);
+
+ for (c = he->forward; c; c = c->next) {
+ if (c->x == -1)
+ continue;
+ os_plot(os_MOVE_TO, x0 + c->x * WIDTH - MARGIN,
+ y0 - he->y * HEIGHT - HEIGHT / 2);
+ os_plot(os_PLOT_SOLID | os_PLOT_TO,
+ x0 + c->x * WIDTH + MARGIN,
+ y0 - c->y * HEIGHT - HEIGHT / 2);
+ ro_gui_history_redraw_tree(c, x0, y0);
+ }
+}
+
+
+/**
+ * Handle mouse clicks in the history window.
+ */
+
+void ro_gui_history_click(wimp_pointer *pointer)
+{
+ int x, y;
+ struct history_entry *he;
+ wimp_window_state state;
+
+ state.w = history_window;
+ wimp_get_window_state(&state);
+
+ x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / WIDTH;
+ y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / HEIGHT;
+ LOG(("x = %i, y = %i", x, y));
+ he = ro_gui_history_click_find(history_start, x, y);
+ if (he) {
+ history_bw->history_entry = he;
+ wimp_create_menu(wimp_CLOSE_MENU, 0, 0);
+ browser_window_open_location_historical(history_bw,
+ he->url, 0, 0);
+ }
+}
+
+
+/**
+ * Search for an entry with the specified coordinates.
+ */
+
+struct history_entry * ro_gui_history_click_find(struct history_entry *he,
+ int x, int y)
+{
+ struct history_entry *c, *d;
+ if (he->x == x && he->y == y)
+ return he;
+ for (c = he->forward; c; c = c->next) {
+ d = ro_gui_history_click_find(c, x, y);
+ if (d)
+ return d;
+ }
+ return 0;
+}
+
diff --git a/riscos/window.c b/riscos/window.c
index 5f437c2c1..322295995 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -499,11 +499,13 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer)
{
if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_BACK"))
{
- browser_window_back(g->data.browser.bw);
+ ro_gui_history_open(g->data.browser.bw, g->data.browser.bw->history_entry,
+ pointer->pos.x - 200, pointer->pos.y + 100);
}
else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_FORWARD"))
{
- browser_window_forward(g->data.browser.bw);
+ ro_gui_history_open(g->data.browser.bw, g->data.browser.bw->history_entry,
+ pointer->pos.x - 200, pointer->pos.y + 100);
}
else if (pointer->i == ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_RELOAD"))
{