aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-03-14 16:12:02 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-03-14 16:12:02 +0000
commit739eb5f7ab4d8d10e054ba80813bc1d9e3307450 (patch)
tree16824ac9f18cd2fa93458381c83d4579fa047761
parent* proto.h (readHeader): added (diff)
downloadw3m-739eb5f7ab4d8d10e054ba80813bc1d9e3307450.tar.gz
w3m-739eb5f7ab4d8d10e054ba80813bc1d9e3307450.zip
[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>
-rw-r--r--ChangeLog18
-rw-r--r--buffer.c23
-rwxr-xr-xconfigure8
-rw-r--r--file.c24
-rw-r--r--fm.h3
-rw-r--r--main.c6
-rw-r--r--scripts/xface2xbm.in23
7 files changed, 82 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index d82ff29..62a6d95 100644
--- 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
@@ -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 $
diff --git a/buffer.c b/buffer.c
index 4c341fa..183175b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -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
diff --git a/configure b/configure
index a12c7f3..399c830 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/file.c b/file.c
index 74857e0..58d1032 100644
--- a/file.c
+++ b/file.c
@@ -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 *
diff --git a/fm.h b/fm.h
index 1ac7732..3decd14 100644
--- a/fm.h
+++ b/fm.h
@@ -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;
diff --git a/main.c b/main.c
index d215d61..c63be08 100644
--- a/main.c
+++ b/main.c
@@ -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);
}
diff --git a/scripts/xface2xbm.in b/scripts/xface2xbm.in
index 2c2002a..7d6bede 100644
--- 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);