w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit a5115f3fa41f4fc9ca9ffbecec967c2d4db38633
parent 0d936a3741fcef38bb27b47776872d2369c31c17
Author: ukai <ukai>
Date:   Fri, 15 Nov 2002 15:51:23 +0000

[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 <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 15+++++++++++++++
Mbuffer.c | 3++-
Mfile.c | 20+++++++++-----------
Mfm.h | 1+
Mimage.c | 9+++++----
Mmain.c | 4----
6 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,20 @@ 2002-11-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [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 <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03434] Re: cygwin console on Win9X * terms.c (cygwin_mouse_btn_swapped): ifdef USE_MOUSE (lastConMouse): deleted diff --git a/buffer.c b/buffer.c @@ -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 @@ -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("<img src=\"%s\"><br><br>", 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 @@ -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 @@ -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 @@ -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;