w3m

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

commit 6450afb88a3631eaea0c5f99b3e9079fae0f994f
parent e9819c928a172f73ddf473e0dcf49b30ce73a963
Author: ukai <ukai>
Date:   Thu, 14 Mar 2002 16:12:02 +0000

[w3m-dev 03129] Re: X-Face
* configure (use_xface): ask
* fm.h (_Buffer): add header_source
* buffer.c (reshapeBuffer): fix reshape when reading stdin with image
		fix disappearing header when reading stdin
* file.c (xface2xbm): check file existence
* file.c (readHeader): save to tmp file
		X-Face when activeImage & displayImage
* main.c (dispI): comment out checking content type
* main.c (stopI): ditto
* scripts/xface2xbm.in: update compface URL
		read from file $XF
		write to file $XBM
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 16++++++++++++++++
Mbuffer.c | 21+++++++++++++++------
Mconfigure | 6+++++-
Mfile.c | 22+++++++++++++++++++---
Mfm.h | 1+
Mmain.c | 4++++
Mscripts/xface2xbm.in | 23++++++++++++++++-------
7 files changed, 76 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,19 @@ +2002-03-15 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03129] Re: X-Face + * configure (use_xface): ask + * fm.h (_Buffer): add header_source + * buffer.c (reshapeBuffer): fix reshape when reading stdin with image + fix disappearing header when reading stdin + * file.c (xface2xbm): check file existence + * file.c (readHeader): save to tmp file + X-Face when activeImage & displayImage + * main.c (dispI): comment out checking content type + * main.c (stopI): ditto + * scripts/xface2xbm.in: update compface URL + read from file $XF + write to file $XBM + 2002-03-15 Fumitoshi UKAI <ukai@debian.or.jp> * proto.h (readHeader): added diff --git a/buffer.c b/buffer.c @@ -497,15 +497,11 @@ reshapeBuffer(Buffer *buf) buf->need_reshape = FALSE; if (buf->sourcefile == NULL) return; - if (buf->currentURL.scheme == SCM_LOCAL && - !strcmp(buf->currentURL.file, "-")) - return; init_stream(&f, SCM_LOCAL, NULL); examineFile(buf->mailcap_source ? buf->mailcap_source : buf->sourcefile, &f); if (f.stream == NULL) return; - copyBuffer(&sbuf, buf); clearBuffer(buf); while (buf->frameset) { @@ -523,8 +519,21 @@ reshapeBuffer(Buffer *buf) UseContentCharset = FALSE; UseAutoDetect = FALSE; #endif - if (buf->search_header && buf->currentURL.scheme == SCM_LOCAL) - readHeader(&f, buf, TRUE, NULL); + if (buf->search_header && buf->currentURL.scheme == SCM_LOCAL) { + if (buf->header_source && (buf->mailcap_source || + !strcmp(buf->currentURL.file, "-"))) { + URLFile h; + init_stream(&h, SCM_LOCAL, NULL); + examineFile(buf->header_source, &h); + if (h.stream) { + readHeader(&h, buf, TRUE, NULL); + UFclose(&h); + } + } + else + readHeader(&f, buf, TRUE, NULL); + } + if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&f, buf); else diff --git a/configure b/configure @@ -754,6 +754,11 @@ ask_param "Gopher support" use_gopher $include_opt ask_param "Use alarm support code" use_alarm $include_opt ask_param "Use mark operation" use_mark $include_opt +if [ "$use_image" = y ]; then + ask_param "X-Face support (you need uncompface)" use_xface n +else + use_xface=n +fi ### only use config.param def_param use_dict n @@ -770,7 +775,6 @@ def_param vi_prec_num $include_opt def_param label_topline $include_opt def_param nextpage_topline $include_opt def_param ftppass_hostnamegen $include_opt -def_param use_xface $use_image def_param table_expand n def_param table_no_compact n diff --git a/file.c b/file.c @@ -511,14 +511,17 @@ xface2xbm(char *xface) { char *xbm; FILE *f; + struct stat st; xbm = tmpfname(TMPF_DFL, ".xbm")->ptr; - pushText(fileToDelete, xbm); - f = popen(Sprintf("%s > %s", libFile(XFACE2XBM), xbm)->ptr, "w"); + f = popen(Sprintf("%s - %s", libFile(XFACE2XBM), xbm)->ptr, "w"); if (!f) return NULL; fprintf(f, "%s", xface); pclose(f); + if (stat(xbm, &st)) + return NULL; + pushText(fileToDelete, xbm); return xbm; } #endif @@ -538,6 +541,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) #ifdef JP_CHARSET char code = DocumentCode, ic; #endif + FILE *src = NULL; headerlist = newBuf->document_header = newTextList(); if (uf->scheme == SCM_HTTP @@ -549,6 +553,13 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) else http_response_code = 0; + if (thru && !newBuf->header_source) { + Str tmpf = tmpfname(TMPF_DFL, NULL); + pushText(fileToDelete, tmpf->ptr); + src = fopen(tmpf->ptr, "w"); + if (src) + newBuf->header_source = tmpf->ptr; + } while ((tmp = StrmyUFgets(uf))->length) { #ifdef HTTP_DEBUG { @@ -558,6 +569,8 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) fclose(ff); } #endif /* HTTP_DEBUG */ + if (src) + Strfputs(tmp, src); cleanup_line(tmp, HEADER_MODE); if ((tmp->ptr[0] == '\n' || tmp->ptr[0] == '\r' || tmp->ptr[0] == '\0') #ifdef USE_NNTP @@ -611,7 +624,8 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) } #ifdef USE_IMAGE #ifdef USE_XFACE - if (thru && !strncasecmp(tmp->ptr, "X-Face:", 7)) { + if (thru && activeImage && displayImage && + !strncasecmp(tmp->ptr, "X-Face:", 7)) { char *tmpf; Str src; URLFile f; @@ -847,6 +861,8 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) NULL, #endif 0, -1); + if (src) + fclose(src); } char * diff --git a/fm.h b/fm.h @@ -430,6 +430,7 @@ typedef struct _Buffer { char *edit; struct mailcap *mailcap; char *mailcap_source; + char *header_source; char search_header; #ifdef USE_SSL char *ssl_certificate; diff --git a/main.c b/main.c @@ -4547,8 +4547,10 @@ dispI(void) if (!activeImage) return; displayImage = TRUE; +/* if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) return; +*/ Currentbuf->image_flag = IMG_FLAG_AUTO; Currentbuf->need_reshape = TRUE; displayBuffer(Currentbuf, B_REDRAW_IMAGE); @@ -4559,8 +4561,10 @@ stopI(void) { if (!activeImage) return; +/* if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) return; +*/ Currentbuf->image_flag = IMG_FLAG_SKIP; displayBuffer(Currentbuf, B_REDRAW_IMAGE); } diff --git a/scripts/xface2xbm.in b/scripts/xface2xbm.in @@ -1,13 +1,19 @@ #!@PERL@ -# See http://www.lab3.kuis.kyoto-u.ac.jp/~tsumura/emacs/x-face.html +# compface/uncompface +# ftp://metalab.unc.edu/pub/Linux/apps/graphics/convert/ $UNCOMPFACE = "uncompface"; +$XF = @ARGV ? shift @ARGV : '-'; +$XBM = @ARGV ? shift @ARGV : '-'; + +open(XF, "<$XF"); $xf = ""; -while(<>) { +while(<XF>) { # s/^X-Face://i if ($xf eq ""); $xf .= $_; } +close(XF); pipe(R, W2); pipe(R2, W); @@ -17,7 +23,7 @@ if (! fork()) { open(STDIN, "<&R2"); open(STDOUT, ">&W2"); exec $UNCOMPFACE; - die; + exit 1; } close(R2); close(W2); @@ -29,10 +35,12 @@ while(<R>) { } } close(R); +@bm || exit 1; $W = 48; $H = @bm * 8 / $W; # must be 48 -print <<EOF; +open(XBM, ">$XBM"); +print XBM <<EOF; #define xf_width $W #define xf_height $H static char xf_bits[] = { @@ -45,10 +53,11 @@ while (@bm) { $y |= ($x & 1) << (8 - $i); $x >>= 1; } - printf " 0x%02X,", $y; + printf XBM " 0x%02X,", $y; } - print "\n"; + print XBM "\n"; } -print <<EOF; +print XBM <<EOF; }; EOF +close(XBM);