[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>
This commit is contained in:
Fumitoshi UKAI
2002-03-14 16:12:02 +00:00
parent b0480be55c
commit 739eb5f7ab
7 changed files with 82 additions and 23 deletions
+17 -1
View File
@@ -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
@@ -3153,4 +3169,4 @@
* release-0-2-1
* import w3m-0.2.1
$Id: ChangeLog,v 1.348 2002/03/14 15:41:53 ukai Exp $
$Id: ChangeLog,v 1.349 2002/03/14 16:12:02 ukai Exp $
+16 -7
View File
@@ -1,4 +1,4 @@
/* $Id: buffer.c,v 1.11 2002/03/13 15:51:36 ukai Exp $ */
/* $Id: buffer.c,v 1.12 2002/03/14 16:12:05 ukai Exp $ */
#include "fm.h"
#ifdef USE_MOUSE
@@ -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
Vendored
+6 -2
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# $Id: configure,v 1.64 2002/03/13 17:04:56 ukai Exp $
# $Id: configure,v 1.65 2002/03/14 16:12:06 ukai Exp $
# Configuration.
#
@@ -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
+20 -4
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.84 2002/03/13 17:04:56 ukai Exp $ */
/* $Id: file.c,v 1.85 2002/03/14 16:12:06 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -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 *
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.54 2002/03/12 16:59:50 ukai Exp $ */
/* $Id: fm.h,v 1.55 2002/03/14 16:12:07 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -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;
+5 -1
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.86 2002/03/05 16:58:09 ukai Exp $ */
/* $Id: main.c,v 1.87 2002/03/14 16:12:07 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -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);
}
+16 -7
View File
@@ -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);