summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2003-07-22 22:13:44 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2003-07-22 22:13:44 +0000
commit3c0daf429a15b39a8e5d521449be4306b14f579a (patch)
tree4abc571db073a984957623de76110ca0a472dbd1
parente13bb8daa87c01c0f5a478a96b7fa822955770cd (diff)
downloadnetsurf-3c0daf429a15b39a8e5d521449be4306b14f579a.tar.gz
netsurf-3c0daf429a15b39a8e5d521449be4306b14f579a.tar.bz2
[project @ 2003-07-22 22:13:44 by jmb]
Enable viewing HTML source when F8 is pressed svn path=/import/netsurf/; revision=241
-rw-r--r--content/content.h2
-rw-r--r--render/html.c8
-rw-r--r--riscos/gui.c12
3 files changed, 22 insertions, 0 deletions
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)