w3m

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

commit 951f36e957fb2bbe8eda0227ed961d1abb1d4e4b
parent f441f1fc68cef3f80cfc8e3c38e542683664803c
Author: ukai <ukai>
Date:   Wed, 13 Mar 2002 17:04:56 +0000

[w3m-dev 03127] X-Face
* NEWS: X-Face support
* configure (use_xface): added
* config.h.dist (USE_XFACE): added
	(XFACE2XBM): added
* file.c (xface2xbm): added
	(readHeader): X-Face: handling
* scripts/Makefile (LIB_TARGETS): add xface2xbm
* scripts/xface2xbm.in: added
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 12++++++++++++
MNEWS | 5+++++
Mconfig.h.dist | 2++
Mconfigure | 3+++
Mfile.c | 41+++++++++++++++++++++++++++++++++++++++++
Mscripts/Makefile | 2+-
Ascripts/xface2xbm.in | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,17 @@ 2002-03-14 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03127] X-Face + * NEWS: X-Face support + * configure (use_xface): added + * config.h.dist (USE_XFACE): added + (XFACE2XBM): added + * file.c (xface2xbm): added + (readHeader): X-Face: handling + * scripts/Makefile (LIB_TARGETS): add xface2xbm + * scripts/xface2xbm.in: added + +2002-03-14 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03126] reshapeBuffer() and -m option * buffer.c (reshapeBuffer): fix reshapeBuffer() in case of -m option diff --git a/NEWS b/NEWS @@ -1,3 +1,8 @@ +w3m 0.4? + +* X-Face support: USE_XFACE, require uncompface + +---------------------------------------------------------------- w3m 0.3 - 2002-03-06 * rc: mailer diff --git a/config.h.dist b/config.h.dist @@ -123,6 +123,7 @@ MODEL=Linux.i686-monster-ja #undef USE_ALARM #undef USE_IMAGE #define USE_HELP_CGI +#undef USE_XFACE #define DEF_EDITOR "/bin/vi" #define DEF_MAILER "/bin/mail" @@ -143,6 +144,7 @@ MODEL=Linux.i686-monster-ja #define W3MCONFIG "w3mconfig" #define IMGSIZE "w3mimgsize" #define IMGDISPLAY "w3mimgdisplay" +#define XFACE2XBM "xface2xbm" #define RC_DIR "~/.w3m" #define BOOKMARK "bookmark.html" diff --git a/configure b/configure @@ -770,6 +770,7 @@ 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 @@ -2127,6 +2128,7 @@ $def_use_gopher $def_use_alarm $def_use_image $def_use_help_cgi +$def_use_xface #define DEF_EDITOR "$editor" #define DEF_MAILER "$mailer" @@ -2147,6 +2149,7 @@ $def_use_help_cgi #define W3MCONFIG "w3mconfig" #define IMGSIZE "w3mimgsize" #define IMGDISPLAY "w3mimgdisplay" +#define XFACE2XBM "xface2xbm" #define RC_DIR "~/.w3m" #define BOOKMARK "bookmark.html" diff --git a/file.c b/file.c @@ -504,6 +504,26 @@ matchattr(char *p, char *attr, int len, Str *value) return 0; } +#ifdef USE_IMAGE +#ifdef USE_XFACE +static char * +xface2xbm(char *xface) +{ + char *xbm; + FILE *f; + + xbm = tmpfname(TMPF_DFL, ".xbm")->ptr; + pushText(fileToDelete, xbm); + f = popen(Sprintf("%s > %s", libFile(XFACE2XBM), xbm)->ptr, "w"); + if (!f) + return NULL; + fprintf(f, "%s", xface); + pclose(f); + return xbm; +} +#endif +#endif + void readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) { @@ -589,6 +609,27 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) lineBuf2->length, -1); for (; *q && (*q == '\r' || *q == '\n'); q++) ; } +#ifdef USE_IMAGE +#ifdef USE_XFACE + if (thru && !strncasecmp(tmp->ptr, "X-Face:", 7)) { + char *tmpf; + Str src; + URLFile f; + Line *l; + + tmpf = xface2xbm(&tmp->ptr[7]); + if (tmpf) { + src = Sprintf("<img src=\"%s\" alt=\"X-Face\" width=48 height=48>", + html_quote(tmpf)); + init_stream(&f, SCM_LOCAL, newStrStream(src)); + loadHTMLstream(&f, newBuf, NULL, TRUE); + for (l = newBuf->lastLine; l && l->real_linenumber; + l = l->prev) + l->real_linenumber = 0; + } + } +#endif +#endif lineBuf2 = tmp; } else { diff --git a/scripts/Makefile b/scripts/Makefile @@ -6,7 +6,7 @@ LIB_DIR = $(prefix)/lib/w3m HELP_DIR = $(prefix)/lib/w3m RC_DIR = ~/.w3m -LIB_TARGETS = dirlist.cgi w3mhelp.cgi w3mmail.cgi +LIB_TARGETS = dirlist.cgi w3mhelp.cgi w3mmail.cgi xface2xbm HELP_LIBS = w3mhelp-funcname.pl w3mhelp-funcdesc.pl MKDIR = mkdir -p diff --git a/scripts/xface2xbm.in b/scripts/xface2xbm.in @@ -0,0 +1,54 @@ +#!@PERL@ + +# See http://www.lab3.kuis.kyoto-u.ac.jp/~tsumura/emacs/x-face.html +$UNCOMPFACE = "uncompface"; + +$xf = ""; +while(<>) { +# s/^X-Face://i if ($xf eq ""); + $xf .= $_; +} + +pipe(R, W2); +pipe(R2, W); +if (! fork()) { + close(R); + close(W); + open(STDIN, "<&R2"); + open(STDOUT, ">&W2"); + exec $UNCOMPFACE; + die; +} +close(R2); +close(W2); +print W $xf; +close(W); +while(<R>) { + while(s/0x(..)(..)//) { + push(@bm, hex($1), hex($2)); + } +} +close(R); + +$W = 48; +$H = @bm * 8 / $W; # must be 48 +print <<EOF; +#define xf_width $W +#define xf_height $H +static char xf_bits[] = { +EOF +while (@bm) { + for (1..6) { + $x = shift @bm; + $y = 0; + for $i (1 .. 8) { + $y |= ($x & 1) << (8 - $i); + $x >>= 1; + } + printf " 0x%02X,", $y; + } + print "\n"; +} +print <<EOF; +}; +EOF