w3m

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

commit 985fea00b4a1dae96eb2e1cebc92e0322e4d9bc5
parent 282ed32931ec20b5fed75dce1b27f7e640478422
Author: ukai <ukai>
Date:   Wed, 11 Dec 2002 15:07:53 +0000

[w3m-dev 03559] Re: use select instead of signal for loading images
* fm.h (Buffer): add image_loaded
* image.c (W3M_SIGIMG): deleted
	(image_lock): deleted
	(need_load_image): deleted
	(load_image_handler): deleted
	(load_image_next): deleted
	(getAllImage): check image_loaded
	(loadImage): delete image_lock
		delete IMG_FLAG_NEXT
* main.c (main): check image_loaded
* proto.h (sleep_till_anykey): return int
* terms.c (sleep_till_anykey): return int
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 16++++++++++++++++
Mfm.h | 1+
Mimage.c | 77++++++++++++++++-------------------------------------------------------------
Mmain.c | 12++++++------
Mproto.h | 2+-
Mterms.c | 8+++++---
6 files changed, 45 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,21 @@ 2002-12-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03559] Re: use select instead of signal for loading images + * fm.h (Buffer): add image_loaded + * image.c (W3M_SIGIMG): deleted + (image_lock): deleted + (need_load_image): deleted + (load_image_handler): deleted + (load_image_next): deleted + (getAllImage): check image_loaded + (loadImage): delete image_lock + delete IMG_FLAG_NEXT + * main.c (main): check image_loaded + * proto.h (sleep_till_anykey): return int + * terms.c (sleep_till_anykey): return int + +2002-12-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03558] long title is displayed over tab region * display.c (redrawNLine): check l < 0 use addnstr diff --git a/fm.h b/fm.h @@ -458,6 +458,7 @@ typedef struct _Buffer { char *ssl_certificate; #endif char image_flag; + char image_loaded; char need_reshape; Anchor *submit; struct _BufferPos *undo; diff --git a/image.c b/image.c @@ -12,10 +12,6 @@ #ifdef USE_IMAGE -#ifndef W3M_SIGIMG -#define W3M_SIGIMG (SIGUSR1) -#endif - static int image_index = 0; /* display image */ @@ -276,25 +272,6 @@ static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; static ImageCache **image_cache = NULL; -static char *image_lock = NULL; -static int need_load_image = FALSE; - -static MySignalHandler -load_image_handler(SIGNAL_ARG) -{ - need_load_image = TRUE; - signal(W3M_SIGIMG, load_image_handler); - SIGNAL_RETURN; -} - -static MySignalHandler -load_image_next(SIGNAL_ARG) -{ - need_load_image = TRUE; - signal(W3M_SIGIMG, load_image_handler); - loadImage(IMG_FLAG_NEXT); - SIGNAL_RETURN; -} void deleteImage(Buffer *buf) @@ -328,13 +305,18 @@ getAllImage(Buffer *buf) if (!buf) return; + buf->image_loaded = TRUE; al = buf->img; if (!al) return; current = baseURL(buf); for (i = 0, a = al->anchors; i < al->nanchor; i++, a++) { - if (a->image) + if (a->image) { a->image->cache = getImage(a->image, current, buf->image_flag); + if (a->image->cache && + a->image->cache->loaded == IMG_FLAG_UNLOADED) + buf->image_loaded = FALSE; + } } } @@ -401,14 +383,11 @@ loadImage(int flag) } image_list = NULL; image_file = NULL; - 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 < n_load_image; i++) { cache = image_cache[i]; @@ -432,7 +411,7 @@ loadImage(int flag) if (!stat(cache->file, &st)) { cache->loaded = IMG_FLAG_LOADED; if (getImageSize(cache)) { - if (flag == IMG_FLAG_NEXT && CurrentTab && Currentbuf) + if (CurrentTab && Currentbuf) Currentbuf->need_reshape = TRUE; } draw = TRUE; @@ -442,17 +421,12 @@ loadImage(int flag) unlink(cache->touch); image_cache[i] = NULL; } - if (flag == IMG_FLAG_NEXT && draw) + if (draw && CurrentTab && Currentbuf) { drawImage(); - if (CurrentTab && Currentbuf) showImageProgress(Currentbuf); + } } - if (image_lock) - unlink(image_lock); - need_load_image = FALSE; - signal(W3M_SIGIMG, load_image_handler); - if (!image_list) return; for (i = 0; i < n_load_image; i++) { @@ -463,7 +437,7 @@ loadImage(int flag) if (!cache) { for (i = 0; i < n_load_image; i++) { if (image_cache[i]) - goto load_image_end; + return; } image_list = NULL; image_file = NULL; @@ -476,17 +450,9 @@ loadImage(int flag) } image_cache[i] = cache; - if (!image_lock) { - image_lock = tmpfname(TMPF_DFL, ".lock")->ptr; - pushText(fileToDelete, image_lock); - } - flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; -#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) - FILE *f; -#endif reset_signals(); signal(SIGINT, SIG_IGN); close_tty(); @@ -498,21 +464,13 @@ loadImage(int flag) unlink(cache->file); #if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) symlink(cache->file, cache->touch); - if (lstat(image_lock, &st)) { - if (symlink(cache->file, image_lock)) - exit(0); #else - f = fopen(cache->touch, "w"); - if (f) - fclose(f); - if (stat(image_lock, &st)) { - f = fopen(image_lock, "w"); - if (!f) - exit(0); - fclose(f); -#endif - kill(getppid(), W3M_SIGIMG); + { + FILE *f = fopen(cache->touch, "w"); + if (f) + fclose(f); } +#endif exit(0); } else if (cache->pid < 0) { @@ -520,9 +478,6 @@ loadImage(int flag) return; } } - load_image_end: - if (flag == IMG_FLAG_NEXT) - signal(W3M_SIGIMG, load_image_next); } ImageCache * diff --git a/main.c b/main.c @@ -1039,14 +1039,14 @@ main(int argc, char **argv, char **envp) signal(SIGWINCH, resize_handler); #endif #ifdef USE_IMAGE - if (activeImage && displayImage) - loadImage(IMG_FLAG_NEXT); + if (activeImage && displayImage && Currentbuf->img && + !Currentbuf->image_loaded) { + do { + loadImage(IMG_FLAG_NEXT); + } while (sleep_till_anykey(1, 0) <= 0); + } #endif c = getch(); -#ifdef USE_IMAGE - if (activeImage && displayImage) - loadImage(IMG_FLAG_START); -#endif #ifdef SIGWINCH signal(SIGWINCH, resize_hook); #endif diff --git a/proto.h b/proto.h @@ -472,7 +472,7 @@ extern void flush_tty(void); extern void toggle_stand(void); extern char getch(void); extern void bell(void); -extern void sleep_till_anykey(int sec, int purge); +extern int sleep_till_anykey(int sec, int purge); #ifdef USE_IMAGE extern void touch_cursor(); #endif diff --git a/terms.c b/terms.c @@ -1962,12 +1962,12 @@ skip_escseq(void) } } -void +int sleep_till_anykey(int sec, int purge) { fd_set rfd; struct timeval tim; - int er, c; + int er, c, ret; TerminalMode ioval; TerminalGet(tty, &ioval); @@ -1979,7 +1979,8 @@ sleep_till_anykey(int sec, int purge) FD_ZERO(&rfd); FD_SET(tty, &rfd); - if (select(tty + 1, &rfd, 0, 0, &tim) > 0 && purge) { + ret = select(tty + 1, &rfd, 0, 0, &tim); + if (ret > 0 && purge) { c = getch(); if (c == ESC_CODE) skip_escseq(); @@ -1989,6 +1990,7 @@ sleep_till_anykey(int sec, int purge) printf("Error occured: errno=%d\n", errno); reset_exit(SIGNAL_ARGLIST); } + return ret; } #ifdef USE_MOUSE