From 3c0daf429a15b39a8e5d521449be4306b14f579a Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 22 Jul 2003 22:13:44 +0000 Subject: [project @ 2003-07-22 22:13:44 by jmb] Enable viewing HTML source when F8 is pressed svn path=/import/netsurf/; revision=241 --- content/content.h | 2 ++ render/html.c | 8 ++++++++ riscos/gui.c | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/content/content.h b/content/content.h index 1903730c5..bc189c1dd 100644 --- a/content/content.h +++ b/content/content.h @@ -100,6 +100,8 @@ struct content struct { htmlParserCtxt* parser; + char* source; + int length; struct box* layout; unsigned int stylesheet_count; struct content **stylesheet_content; diff --git a/render/html.c b/render/html.c index be0044fce..a6e6d9e7d 100644 --- a/render/html.c +++ b/render/html.c @@ -35,6 +35,8 @@ void html_create(struct content *c) c->data.html.layout = NULL; c->data.html.style = NULL; c->data.html.fonts = NULL; + c->data.html.length = 0; + c->data.html.source = xcalloc(0, 1); } @@ -45,6 +47,10 @@ void html_process_data(struct content *c, char *data, unsigned long size) unsigned long x; LOG(("content %s, size %lu", c->url, size)); cache_dump(); + c->data.html.source = xrealloc(c->data.html.source, c->data.html.length + size); + memcpy(c->data.html.source + c->data.html.length, data, size); + c->data.html.length += size; + c->size += size; for (x = 0; x + CHUNK <= size; x += CHUNK) { htmlParseChunk(c->data.html.parser, data + x, CHUNK, 0); gui_multitask(); @@ -571,5 +577,7 @@ void html_destroy(struct content *c) LOG(("title %p", c->title)); if (c->title != 0) xfree(c->title); + if (c->data.html.source != 0) + xfree(c->data.html.source); } diff --git a/riscos/gui.c b/riscos/gui.c index 4c46efdff..b4bad929f 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2065,6 +2065,18 @@ void ro_gui_keypress(wimp_key* key) browser_window_open_location(g->data.browser.bw, g->url); return; } + else if (key->c == wimp_KEY_F8) + { + /* TODO: use some protocol so it's type as HTML not Text. */ + if(g->data.browser.bw->current_content->type == CONTENT_HTML || + g->data.browser.bw->current_content->type == CONTENT_TEXTPLAIN) + xosfile_save_stamped("Pipe:$.Source", osfile_TYPE_TEXT, + g->data.browser.bw->current_content->data.html.source, + (g->data.browser.bw->current_content->data.html.source + + g->data.browser.bw->current_content->data.html.length)); + xosfile_set_type("Pipe:$.Source", osfile_TYPE_TEXT); + xos_cli("Filer_Run Pipe:$.Source"); + } else if (key->c == wimp_KEY_F9) { if (g->data.browser.bw->current_content->type == CONTENT_HTML) -- cgit v1.2.3