From 073f8a91054a0b84fc2a3c6feaada832d2818bf7 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Fri, 15 Nov 2002 15:51:23 +0000 Subject: [w3m-dev 03435] save image with SAVE * buffer.c (discardBuffer): check image * file.c (loadImageBuffer): add st IMG_FLAG_DONE_REMOVE s/sourcefile/mailcap_source/ * fm.h (IMG_FLAG_DONT_REMOVE): added * image.c (drawImage): & IMG_FLAG_LOADED (deleteImage): & IMG_FLAG_DONT_REMOVE (showImageProgress): & IMG_FLAG_LOADED (getImage): & IMG_FLAG_LOADED (getImageSize): & IMG_FLAG_LOADED * main.c (vmSrc): delete ifdef USE_IMAGE From: Hironori SAKAMOTO --- ChangeLog | 17 ++++++++++++++++- buffer.c | 5 +++-- file.c | 22 ++++++++++------------ fm.h | 3 ++- image.c | 11 ++++++----- main.c | 6 +----- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index f298a44..c370b9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-11-16 Hironori SAKAMOTO + + * [w3m-dev 03435] save image with SAVE + * buffer.c (discardBuffer): check image + * file.c (loadImageBuffer): add st + IMG_FLAG_DONE_REMOVE + s/sourcefile/mailcap_source/ + * fm.h (IMG_FLAG_DONT_REMOVE): added + * image.c (drawImage): & IMG_FLAG_LOADED + (deleteImage): & IMG_FLAG_DONT_REMOVE + (showImageProgress): & IMG_FLAG_LOADED + (getImage): & IMG_FLAG_LOADED + (getImageSize): & IMG_FLAG_LOADED + * main.c (vmSrc): delete ifdef USE_IMAGE + 2002-11-16 Hironori SAKAMOTO * [w3m-dev 03434] Re: cygwin console on Win9X @@ -4751,4 +4766,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.518 2002/11/15 15:44:36 ukai Exp $ +$Id: ChangeLog,v 1.519 2002/11/15 15:51:23 ukai Exp $ diff --git a/buffer.c b/buffer.c index 5c5b246..30043bf 100644 --- a/buffer.c +++ b/buffer.c @@ -1,4 +1,4 @@ -/* $Id: buffer.c,v 1.14 2002/11/08 15:54:46 ukai Exp $ */ +/* $Id: buffer.c,v 1.15 2002/11/15 15:51:23 ukai Exp $ */ #include "fm.h" #ifdef USE_MOUSE @@ -97,7 +97,8 @@ discardBuffer(Buffer *buf) return; if (buf->pagerSource) ISclose(buf->pagerSource); - if (buf->sourcefile) { + if (buf->sourcefile && + (!buf->real_type || strncasecmp(buf->real_type, "image/", 6))) { if (buf->real_scheme != SCM_LOCAL || buf->bufferprop & BP_FRAME) unlink(buf->sourcefile); } diff --git a/file.c b/file.c index c04d0ad..e4a723f 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.117 2002/11/15 15:21:07 ukai Exp $ */ +/* $Id: file.c,v 1.118 2002/11/15 15:51:23 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -6569,6 +6569,7 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) FILE *src = NULL; URLFile f; MySignalHandler(*prevtrap) (); + struct stat st; loadImage(IMG_FLAG_STOP); image = New(Image); @@ -6577,7 +6578,8 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) image->width = -1; image->height = -1; cache = getImage(image, cur_baseURL, IMG_FLAG_AUTO); - if (!cur_baseURL->is_nocache && cache->loaded == IMG_FLAG_LOADED) + if (!cur_baseURL->is_nocache && cache->loaded & IMG_FLAG_LOADED && + !stat(cache->file, &st)) goto image_buffer; prevtrap = signal(SIGINT, KeyAbort); @@ -6597,24 +6599,20 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) cache->loaded = IMG_FLAG_LOADED; cache->index = 0; - /* - * getImageSize(cache); - */ image_buffer: + cache->loaded |= IMG_FLAG_DONT_REMOVE; + if (uf->scheme != SCM_LOCAL) + newBuf->sourcefile = cache->file; + tmp = Sprintf("

", html_quote(image->url)); if (newBuf == NULL) newBuf = newBuffer(INIT_BUFFER_WIDTH); - /* - * if (frame_source) { - */ tmpf = tmpfname(TMPF_SRC, ".html"); src = fopen(tmpf->ptr, "w"); - newBuf->sourcefile = tmpf->ptr; + newBuf->mailcap_source = tmpf->ptr; pushText(fileToDelete, tmpf->ptr); - /* - * } - */ + init_stream(&f, SCM_LOCAL, newStrStream(tmp)); loadHTMLstream(&f, newBuf, src, TRUE); if (src) diff --git a/fm.h b/fm.h index 4a151f9..6bac9ba 100644 --- a/fm.h +++ b/fm.h @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.77 2002/11/15 15:19:44 ukai Exp $ */ +/* $Id: fm.h,v 1.78 2002/11/15 15:51:24 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -238,6 +238,7 @@ extern int REV_LB[]; #define IMG_FLAG_UNLOADED 0 #define IMG_FLAG_LOADED 1 #define IMG_FLAG_ERROR 2 +#define IMG_FLAG_DONT_REMOVE 4 /* * Macros. diff --git a/image.c b/image.c index 099b13f..1c56c92 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.16 2002/11/09 21:55:24 ukai Exp $ */ +/* $Id: image.c,v 1.17 2002/11/15 15:51:24 ukai Exp $ */ #include "fm.h" #include @@ -203,7 +203,7 @@ drawImage() return; for (j = 0; j < n_terminal_image; j++) { i = &terminal_image[j]; - if (!(i->cache->loaded == IMG_FLAG_LOADED && + if (!(i->cache->loaded & IMG_FLAG_LOADED && i->width > 0 && i->height > 0)) continue; if (!(Imgdisplay_rf && Imgdisplay_wf)) { @@ -319,6 +319,7 @@ deleteImage(Buffer *buf) for (i = 0, a = al->anchors; i < al->nanchor; i++, a++) { if (a->image && a->image->cache && a->image->cache->loaded != IMG_FLAG_UNLOADED && + !(a->image->cache->loaded & IMG_FLAG_DONT_REMOVE) && a->image->cache->index < 0) unlink(a->image->cache->file); } @@ -360,7 +361,7 @@ showImageProgress(Buffer *buf) for (i = 0, l = 0, n = 0, a = al->anchors; i < al->nanchor; i++, a++) { if (a->image && a->hseq >= 0) { n++; - if (a->image->cache && a->image->cache->loaded == IMG_FLAG_LOADED) + if (a->image->cache && a->image->cache->loaded & IMG_FLAG_LOADED) l++; } } @@ -587,7 +588,7 @@ getImage(Image * image, ParsedURL *current, int flag) if (!cache->index) cache->index = ++image_index; } - if (cache->loaded == IMG_FLAG_LOADED) + if (cache->loaded & IMG_FLAG_LOADED) getImageSize(cache); return cache; } @@ -600,7 +601,7 @@ getImageSize(ImageCache * cache) if (!activeImage) return FALSE; - if (!cache || cache->loaded != IMG_FLAG_LOADED || + if (!cache || !(cache->loaded & IMG_FLAG_LOADED) || (cache->width > 0 && cache->height > 0)) return FALSE; tmp = Strnew(); diff --git a/main.c b/main.c index 6bff67c..6ce97ba 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.134 2002/11/15 15:36:48 ukai Exp $ */ +/* $Id: main.c,v 1.135 2002/11/15 15:51:24 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include @@ -4230,10 +4230,6 @@ vwSrc(void) if (Currentbuf->type == NULL || Currentbuf->bufferprop & BP_FRAME) return; -#ifdef USE_IMAGE - if (!strncasecmp(Currentbuf->real_type, "image/", 6)) - return; -#endif if ((buf = Currentbuf->linkBuffer[LB_SOURCE]) != NULL || (buf = Currentbuf->linkBuffer[LB_N_SOURCE]) != NULL) { Currentbuf = buf; -- cgit v1.2.3