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

Hiroyuki Ito <[email protected]> Sun, 22 Apr 2007 22:26:43 +0900 (JST)
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>

> > (****1)
> > a               insert start<ins><u>b</u></ins>
> > a               <ins><u>b</u></ins>
> > a               <ins><u>b</u></ins>insert end
> > 
> > 
> 
> 
> 


<del> 


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	22 Apr 2007 05:51:11 -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,84 @@
     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) {
+		HTMLlineproc1("<U>[DEL:</U>", h_env);
+		push_tag(obuf, "<s>", HTML_S);
+	    }
+	} else {
 	    obuf->flag |= RB_DEL;
+	}
 	return 1;
     case HTML_N_DEL:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>:DEL]</U>", h_env);
-	else
-	    obuf->flag &= ~RB_DEL;
-	return 1;
+	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) {
+		HTMLlineproc1("<U>:DEL]</U>", h_env);
+	    } else {
+		obuf->flag &= ~(RB_DEL | RB_S);
+	    }
+	}
     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) {
+		HTMLlineproc1("<U>[S:</U>", h_env);
+		push_tag(obuf, "<s>", HTML_S);
+	    }
+	} 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) {
+		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) {
+	    push_tag(obuf, "<ins>", HTML_INS);
+	    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) {
+		HTMLlineproc1("</U>", h_env);
+		push_tag(obuf, "</ins>", HTML_N_INS);
+	    }
+	}
+ 	return 1;
     case HTML_SUP:
 	if (!(obuf->flag & (RB_DEL | RB_S)))
 	    HTMLlineproc1("^", h_env);
@@ -5301,7 +5382,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 +6640,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 +6684,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	22 Apr 2007 05:51:11 -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