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

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





[w3m-dev 04206]  <del>  patch 
<del>, <s>, <strike> w3m 
 display_ins_del=0 


<ins> 

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



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




 (emacs-w3m ) (**1)  patch 





diff -u w3m/file.c w3m-test/file.c
--- w3m/file.c	2006-12-27 22:42:45.000000000 +0900
+++ w3m-test/file.c	2006-12-27 23:18:51.000000000 +0900
@@ -2444,6 +2444,7 @@
     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.nobr_level = obuf->nobr_level;
     obuf->bp.prev_ctype = obuf->prev_ctype;
     obuf->bp.init_flag = 0;
@@ -2459,6 +2460,7 @@
     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->prev_ctype = obuf->bp.prev_ctype;
     obuf->pos = obuf->bp.pos;
     obuf->top_margin = obuf->bp.top_margin;
@@ -2481,6 +2483,7 @@
 	case HTML_B:
 	case HTML_U:
 	case HTML_I:
+	case HTML_S:
 	    push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos);
 	    break;
 	}
@@ -2695,7 +2698,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 = NULL;
 
 #ifdef DEBUG
     if (w3m_debug) {
@@ -2745,6 +2749,12 @@
 		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 (hidden) {
 	pass = Strnew_charp(hidden);
 	Strshrink(line, line->ptr + line->length - hidden);
@@ -2772,6 +2782,8 @@
 	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->top_margin > 0) {
 	int i;
@@ -2978,6 +2990,8 @@
 	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);
 }
 
 void
@@ -3092,6 +3106,8 @@
 	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);
     bzero(obuf->fontstat, FONTSTAT_SIZE);
 }
 
@@ -3109,6 +3125,8 @@
 	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);
 }
 
 static Str
@@ -4982,28 +5000,64 @@
     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;
+	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);
+	    }
+	}
 	return 1;
     case HTML_S:
-	if (displayInsDel)
-	    HTMLlineproc1("<U>[S:</U>", h_env);
-	else
+	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)
@@ -5299,6 +5353,12 @@
 		case HTML_N_U:
 		    effect &= ~PE_UNDER;
 		    break;
+		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)) {
@@ -6551,6 +6611,7 @@
     obuf->in_bold = 0;
     obuf->in_italic = 0;
     obuf->in_under = 0;
+    obuf->in_strike = 0;
     obuf->prev_ctype = PC_ASCII;
     obuf->tag_sp = 0;
     obuf->fontstat_sp = 0;
@@ -6593,6 +6654,10 @@
 	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->flag & RB_INTXTA)
 	HTMLlineproc1("</textarea>", h_env);
     /* for unbalanced select tag */
diff -u w3m/fm.h w3m-test/fm.h
--- w3m/fm.h	2006-12-10 20:06:12.000000000 +0900
+++ w3m-test/fm.h	2006-12-27 22:49:06.000000000 +0900
@@ -537,9 +537,9 @@
 
 #define TAG_STACK_SIZE 10
 
-#define FONT_STACK_SIZE 5
+#define FONT_STACK_SIZE 6
 
-#define FONTSTAT_SIZE 5
+#define FONTSTAT_SIZE 6
 
 #define _INIT_BUFFER_WIDTH (COLS - (showLineNum ? 6 : 1))
 #define INIT_BUFFER_WIDTH ((_INIT_BUFFER_WIDTH > 0) ? _INIT_BUFFER_WIDTH : 0)
@@ -588,7 +588,8 @@
 #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_stand fontstat[4]
 
 #define RB_PRE		0x01
 #define RB_SCRIPT	0x02