[w3m-dev 04220] Re: <del>, <s>, <ins>, and so on

Hideyuki SHIRAI (白井秀行) <[email protected]> Tue, 24 Apr 2007 15:17:21 +0900 (JST)
Newsgroups gmane.comp.web.w3m.devel
Organization Resident at Meadowy farm.
Message-ID <[email protected]>

From: Hideyuki SHIRAI () <[email protected]> 
Subject: [w3m-dev 04218] Re: <del>, <s>, <ins>, and so on
Message-ID: <[email protected]>
Date: Tue, 24 Apr 2007 13:56:29 +0900 (JST)

> [DEL:, :DEL], [S:, :S] 
> <ins>  <U> 
> 
> 
> 
> (1) emacs-w3m  [DEL:, :DEL], [S:, :S] 
>     
>     => 
> 
> (2) ins tag  <ins><U></U></ins> <ins> 
>     <ins>  <u> emacs-w3m 
>     
> 
> 


compile option 

% w3m -version
w3m version w3m/0.5.1+cvs-1.974, options lang=ja,m17n,image,...,mark,migemo,emacsdump

 "emacsdump" emacs-w3m 
"-halfdump"  "-emacsdump"  w3m 




# w3m -h  halfdump emacsdump 

CVS Head 

-- 
 (mailto:[email protected])

Index: file.c
===================================================================
RCS file: /cvsroot/w3m/w3m/file.c,v
retrieving revision 1.251
diff -u -r1.251 file.c
--- file.c	19 Apr 2007 12:00:37 -0000	1.251
+++ file.c	24 Apr 2007 06:08:39 -0000
@@ -2444,6 +2444,8 @@
     obuf->bp.in_bold = obuf->in_bold;
     obuf->bp.in_italic = obuf->in_italic;
     obuf->bp.in_under = obuf->in_under;
+    obuf->bp.in_strike = obuf->in_strike;
+    obuf->bp.in_ins = obuf->in_ins;
     obuf->bp.nobr_level = obuf->nobr_level;
     obuf->bp.prev_ctype = obuf->prev_ctype;
     obuf->bp.init_flag = 0;
@@ -2459,6 +2461,8 @@
     obuf->in_bold = obuf->bp.in_bold;
     obuf->in_italic = obuf->bp.in_italic;
     obuf->in_under = obuf->bp.in_under;
+    obuf->in_strike = obuf->bp.in_strike;
+    obuf->in_ins = obuf->bp.in_ins;
     obuf->prev_ctype = obuf->bp.prev_ctype;
     obuf->pos = obuf->bp.pos;
     obuf->top_margin = obuf->bp.top_margin;
@@ -2481,7 +2485,8 @@
 	case HTML_B:
 	case HTML_U:
 	case HTML_I:
-	    push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos);
+	case HTML_S:
+ 	    push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos);
 	    break;
 	}
 	Strcat_charp(obuf->line, obuf->tag_stack[i]->cmdname);
@@ -2695,7 +2700,8 @@
     FILE *f = h_env->f;
     Str line = obuf->line, pass = NULL;
     char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL,
-	*hidden_under = NULL, *hidden_italic = NULL, *hidden = NULL;
+	*hidden_under = NULL, *hidden_italic = NULL, *hidden_strike = NULL,
+	*hidden_ins = NULL, *hidden = NULL;;
 
 #ifdef DEBUG
     if (w3m_debug) {
@@ -2745,6 +2751,18 @@
 		hidden = hidden_under;
 	}
     }
+    if (obuf->in_strike) {
+	if ((hidden_strike = has_hidden_link(obuf, HTML_S)) != NULL) {
+	    if (!hidden || hidden_strike < hidden)
+		hidden = hidden_strike;
+	}
+    }
+    if (obuf->in_ins) {
+	if ((hidden_ins = has_hidden_link(obuf, HTML_INS)) != NULL) {
+	    if (!hidden || hidden_ins < hidden)
+		hidden = hidden_ins;
+	}
+    }
     if (hidden) {
 	pass = Strnew_charp(hidden);
 	Strshrink(line, line->ptr + line->length - hidden);
@@ -2772,6 +2790,10 @@
 	Strcat_charp(line, "</i>");
     if (obuf->in_under && !hidden_under)
 	Strcat_charp(line, "</u>");
+    if (obuf->in_strike && !hidden_strike)
+	Strcat_charp(line, "</s>");
+    if (obuf->in_ins && !hidden_ins)
+	Strcat_charp(line, "</ins>");
 
     if (obuf->top_margin > 0) {
 	int i;
@@ -2978,6 +3000,10 @@
 	push_tag(obuf, "<I>", HTML_I);
     if (!hidden_under && obuf->in_under)
 	push_tag(obuf, "<U>", HTML_U);
+    if (!hidden_strike && obuf->in_strike)
+	push_tag(obuf, "<S>", HTML_S);
+    if (!hidden_ins && obuf->in_ins)
+	push_tag(obuf, "<INS>", HTML_INS);
 }
 
 void
@@ -3092,6 +3118,10 @@
 	push_tag(obuf, "</i>", HTML_N_I);
     if (obuf->in_under)
 	push_tag(obuf, "</u>", HTML_N_U);
+    if (obuf->in_strike)
+	push_tag(obuf, "</s>", HTML_N_S);
+    if (obuf->in_ins)
+	push_tag(obuf, "</ins>", HTML_N_INS);
     bzero(obuf->fontstat, FONTSTAT_SIZE);
 }
 
@@ -3109,6 +3139,10 @@
 	push_tag(obuf, "<i>", HTML_I);
     if (obuf->in_under)
 	push_tag(obuf, "<u>", HTML_U);
+    if (obuf->in_strike)
+	push_tag(obuf, "<s>", HTML_S);
+    if (obuf->in_ins)
+	push_tag(obuf, "<ins>", HTML_INS);
 }
 
 static Str
@@ -4984,37 +5018,101 @@
     case HTML_AREA:
 	return 0;
     case HTML_DEL:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>[DEL:</U>", h_env);
-	else
+	obuf->in_strike++;
+	if (displayInsDel) {
+	    if (obuf->in_strike == 1) {
+		if (w3m_emacs) {
+		    push_tag(obuf, "<s>", HTML_S);
+		} else {
+		    HTMLlineproc1("<U>[DEL:</U>", h_env);
+		}
+	    }
+	} else {
 	    obuf->flag |= RB_DEL;
+	}
 	return 1;
     case HTML_N_DEL:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>:DEL]</U>", h_env);
-	else
-	    obuf->flag &= ~RB_DEL;
+	if (obuf->in_strike == 0)
+	    return 1;
+	if (obuf->in_strike == 1 && close_effect0(obuf, HTML_S))
+	    obuf->in_strike = 0;
+	if (obuf->in_strike > 0) {
+	    obuf->in_strike--;
+	    if (obuf->in_strike == 0) {
+		push_tag(obuf, "</s>", HTML_N_S);
+	    }
+	}
+	if (obuf->in_strike == 0) {
+	    if (displayInsDel) {
+		if (!w3m_emacs) {
+		    HTMLlineproc1("<U>:DEL]</U>", h_env);
+		}
+	    } else {
+		obuf->flag &= ~(RB_DEL | RB_S);
+	    }
+	}
 	return 1;
     case HTML_S:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>[S:</U>", h_env);
-	else
-	    obuf->flag |= RB_S;
+	obuf->in_strike++;
+	if (displayInsDel) {
+	    if (obuf->in_strike == 1) {
+		if (w3m_emacs) {
+		    push_tag(obuf, "<s>", HTML_S);
+		} else {
+		    HTMLlineproc1("<U>[S:</U>", h_env);
+		}
+	    }
+	} else {
+            obuf->flag |= RB_S;
+	}
 	return 1;
     case HTML_N_S:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>:S]</U>", h_env);
-	else
-	    obuf->flag &= ~RB_S;
+	if (obuf->in_strike == 0)
+	    return 1;
+	if (obuf->in_strike == 1 && close_effect0(obuf, HTML_S))
+	    obuf->in_strike = 0;
+	if (obuf->in_strike > 0) {
+	    obuf->in_strike--;
+	    if (obuf->in_strike == 0) {
+		push_tag(obuf, "</s>", HTML_N_S);
+	    }
+	}
+	if (obuf->in_strike == 0){
+	    if (displayInsDel) {
+		if (!w3m_emacs) {
+		    HTMLlineproc1("<U>:S]</U>", h_env);
+		}
+	    } else {
+		obuf->flag &= ~(RB_DEL | RB_S);
+	    }
+	}
 	return 1;
     case HTML_INS:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>[INS:</U>", h_env);
+	obuf->in_ins++;
+	if (obuf->in_ins == 1) {
+	    if (w3m_emacs) {
+		push_tag(obuf, "<ins>", HTML_INS);
+	    } else {
+		HTMLlineproc1("<U>", h_env);
+	    }
+	}
 	return 1;
     case HTML_N_INS:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>:INS]</U>", h_env);
-	return 1;
+	if (obuf->in_ins == 0)
+	    return 1;
+	if (obuf->in_ins == 1 && close_effect0(obuf, HTML_INS))
+	    obuf->in_ins = 0;
+	if (obuf->in_ins > 0) {
+	    obuf->in_ins--;
+	    if (obuf->in_ins == 0) {
+		if (w3m_emacs) {
+		    push_tag(obuf, "</ins>", HTML_N_INS);
+		} else {
+		    HTMLlineproc1("</U>", h_env);
+		}
+	    }
+	}
+ 	return 1;
     case HTML_SUP:
 	if (!(obuf->flag & (RB_DEL | RB_S)))
 	    HTMLlineproc1("^", h_env);
@@ -5301,7 +5399,13 @@
 		case HTML_N_U:
 		    effect &= ~PE_UNDER;
 		    break;
-		case HTML_A:
+		case HTML_S:
+		    /* nothing to do */
+		    break;
+		case HTML_N_S:
+		    /* nothing to do */
+		    break;
+ 		case HTML_A:
 		    if (renderFrameSet &&
 			parsedtag_get_value(tag, ATTR_FRAMENAME, &p)) {
 			p = url_quote_conv(p, buf->document_charset);
@@ -6553,6 +6657,8 @@
     obuf->in_bold = 0;
     obuf->in_italic = 0;
     obuf->in_under = 0;
+    obuf->in_strike = 0;
+    obuf->in_ins = 0;
     obuf->prev_ctype = PC_ASCII;
     obuf->tag_sp = 0;
     obuf->fontstat_sp = 0;
@@ -6595,6 +6701,14 @@
 	push_tag(obuf, "</u>", HTML_N_U);
 	obuf->in_under = 0;
     }
+    if (obuf->in_strike) {
+	push_tag(obuf, "</s>", HTML_N_S);
+	obuf->in_strike = 0;
+    }
+    if (obuf->in_ins) {
+	push_tag(obuf, "</ins>", HTML_N_INS);
+	obuf->in_ins = 0;
+    }
     if (obuf->flag & RB_INTXTA)
 	HTMLlineproc1("</textarea>", h_env);
     /* for unbalanced select tag */
Index: fm.h
===================================================================
RCS file: /cvsroot/w3m/w3m/fm.h,v
retrieving revision 1.135
diff -u -r1.135 fm.h
--- fm.h	19 Apr 2007 11:42:29 -0000	1.135
+++ fm.h	24 Apr 2007 06:08:40 -0000
@@ -539,7 +539,7 @@
 
 #define FONT_STACK_SIZE 5
 
-#define FONTSTAT_SIZE 5
+#define FONTSTAT_SIZE 7
 
 #define _INIT_BUFFER_WIDTH (COLS - (showLineNum ? 6 : 1))
 #define INIT_BUFFER_WIDTH ((_INIT_BUFFER_WIDTH > 0) ? _INIT_BUFFER_WIDTH : 0)
@@ -588,7 +588,9 @@
 #define in_bold fontstat[0]
 #define in_under fontstat[1]
 #define in_italic fontstat[2]
-#define in_stand fontstat[3]
+#define in_strike fontstat[3]
+#define in_ins fontstat[4]
+#define in_stand fontstat[5]
 
 #define RB_PRE		0x01
 #define RB_SCRIPT	0x02
@@ -985,6 +987,8 @@
 global char *migemo_command init(DEF_MIGEMO_COMMAND);
 #endif				/* USE_MIGEMO */
 
+global int w3m_emacs init(FALSE);
+
 global struct auth_cookie *Auth_cookie init(NULL);
 #ifdef USE_COOKIE
 global struct cookie *First_cookie init(NULL);
Index: main.c
===================================================================
RCS file: /cvsroot/w3m/w3m/main.c,v
retrieving revision 1.253
diff -u -r1.253 main.c
--- main.c	10 Dec 2006 10:49:23 -0000	1.253
+++ main.c	24 Apr 2007 06:08:41 -0000
@@ -169,6 +169,7 @@
 #ifdef USE_MIGEMO
 	    ",migemo"
 #endif
+	    ",emacsdump"
 	);
 }
 
@@ -597,6 +598,10 @@
 		w3m_dump = (DUMP_HEAD | DUMP_SOURCE | DUMP_EXTRA);
 	    else if (!strcmp("-halfdump", argv[i]))
 		w3m_dump = DUMP_HALFDUMP;
+	    else if (!strcmp("-emacsdump",argv[i])) {
+		w3m_dump = DUMP_HALFDUMP;
+	        w3m_emacs = TRUE;
+	    }
 	    else if (!strcmp("-halfload", argv[i])) {
 		w3m_dump = 0;
 		w3m_halfload = TRUE;