diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-02-04 15:18:41 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-02-04 15:18:41 +0000 |
commit | a8831d96bdd3caf44bccbc0356daa8c1195c5c6b (patch) | |
tree | 344bb330ff3f5ad7a0e321926d708a376ebc5fe4 /image.c | |
parent | indent breaks config.h Makefile parts (diff) | |
download | w3m-a8831d96bdd3caf44bccbc0356daa8c1195c5c6b.tar.gz w3m-a8831d96bdd3caf44bccbc0356daa8c1195c5c6b.zip |
[w3m-dev 02984] inline image improvements and cleanups
* config.h.dist (HAVE_SYMLINK) added
* config.h.dist (HAVE_LSTAT): added
* configure: symlink() check
* configure: lstat() check
* fm.h (maxLoadImage): added
* form.c (form_write_from_file): s/HAVE_READLINK/HAVE_LSTAT/
* image.c: include <sys/stat.h>
* image.c (MAX_LOAD_IMAGE): default 8
* image.c (max_load_image): deleted
* image.c (n_load_image): added
* image.c (showImageProgress): added
* image.c (loadImage): check load image count
s/HAVE_READLINK/HAVE_LSTAT/ (HAVE_SYMLINK)
showImageProgress
* local.c: include <sys/stat.h>
s/HAVE_READLINK/HAVE_LSTAT/
* rc.c (CMT_MAX_LOAD_IMAGE): added
* rc.c (max_load_image): added
* doc/README.img: update
* doc-jp/README.img: update
* file.c (process_img): pre_int fix
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'image.c')
-rw-r--r-- | image.c | 63 |
1 files changed, 50 insertions, 13 deletions
@@ -1,7 +1,8 @@ -/* $Id: image.c,v 1.3 2002/02/03 06:38:49 ukai Exp $ */ +/* $Id: image.c,v 1.4 2002/02/04 15:18:42 ukai Exp $ */ #include "fm.h" #include <sys/types.h> +#include <sys/stat.h> #include <signal.h> #include <errno.h> #include <unistd.h> @@ -264,9 +265,9 @@ clearImage() /* load image */ #ifndef MAX_LOAD_IMAGE -#define MAX_LOAD_IMAGE 4 +#define MAX_LOAD_IMAGE 8 #endif -static int max_load_image = MAX_LOAD_IMAGE; +static int n_load_image = 0; static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; @@ -333,18 +334,51 @@ getAllImage(Buffer *buf) } void +showImageProgress(Buffer *buf) +{ + AnchorList *al; + Anchor *a; + int i, l, n; + + if (!buf) + return; + al = buf->img; + if (!al) + return; + 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) + l++; + } + } + if (n) { + message(Sprintf("%d/%d images loaded", l, n)->ptr, + buf->cursorX + buf->rootX, buf->cursorY); + refresh(); + } +} + +void loadImage(int flag) { ImageCache *cache; struct stat st; int wait_st, i; + if (maxLoadImage > MAX_LOAD_IMAGE) + maxLoadImage = MAX_LOAD_IMAGE; + else if (maxLoadImage < 1) + maxLoadImage = 1; + if (n_load_image == 0) + n_load_image = maxLoadImage; if (!image_cache) { - image_cache = New_N(ImageCache *, max_load_image); - bzero(image_cache, sizeof(ImageCache *) * max_load_image); + image_cache = New_N(ImageCache *, MAX_LOAD_IMAGE); + bzero(image_cache, sizeof(ImageCache *) * MAX_LOAD_IMAGE); } + if (flag == IMG_FLAG_STOP) { - for (i = 0; i < max_load_image; i++) { + for (i = 0; i < n_load_image; i++) { cache = image_cache[i]; if (!cache) continue; @@ -365,16 +399,17 @@ loadImage(int flag) if (image_lock) unlink(image_lock); need_load_image = FALSE; + n_load_image = maxLoadImage; return; } if (need_load_image) { int draw = FALSE; - for (i = 0; i < max_load_image; i++) { + for (i = 0; i < n_load_image; i++) { cache = image_cache[i]; if (!cache) continue; -#ifdef HAVE_READLINK +#ifdef HAVE_LSTAT if (lstat(cache->touch, &st)) #else if (stat(cache->touch, &st)) @@ -404,6 +439,8 @@ loadImage(int flag) } if (flag == IMG_FLAG_NEXT && draw) drawImage(); + if (Currentbuf) + showImageProgress(Currentbuf); } if (image_lock) @@ -413,19 +450,19 @@ loadImage(int flag) if (!image_list) return; - for (i = 0; i < max_load_image; i++) { + for (i = 0; i < n_load_image; i++) { if (image_cache[i]) continue; while (1) { cache = (ImageCache *) popValue(image_list); if (!cache) { - for (i = 0; i < max_load_image; i++) { + for (i = 0; i < n_load_image; i++) { if (image_cache[i]) goto load_image_end; } image_list = NULL; image_file = NULL; - if (Currentbuf && Currentbuf->need_reshape) + if (Currentbuf) displayBuffer(Currentbuf, B_NORMAL); return; } @@ -442,7 +479,7 @@ loadImage(int flag) flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; -#ifndef HAVE_READLINK +#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) FILE *f; #endif reset_signals(); @@ -454,7 +491,7 @@ loadImage(int flag) b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL); if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6)) unlink(cache->file); -#ifdef HAVE_READLINK +#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) symlink(cache->file, cache->touch); if (lstat(image_lock, &st)) { symlink(cache->file, image_lock); |