changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: mothra: add <strike> support

changeset 4346: 293098f5b0b5
parent 4345: fcc58d5a738e
child 4347: 48947a421eed
author: cinap_lenrek@felloff.net
date: Sun, 15 Mar 2015 17:05:24 +0100
files: sys/src/cmd/mothra/html.h sys/src/cmd/mothra/html.syntax.c sys/src/cmd/mothra/libpanel/panel.h sys/src/cmd/mothra/libpanel/rtext.c sys/src/cmd/mothra/rdhtml.c
description: mothra: add <strike> support
     1.1--- a/sys/src/cmd/mothra/html.h
     1.2+++ b/sys/src/cmd/mothra/html.h
     1.3@@ -34,6 +34,7 @@ struct Stack{
     1.4 	int number;		/* paragraph number */
     1.5 	int ismap;		/* flag of <img> */
     1.6 	int isscript;		/* inside <script> */
     1.7+	int strike;		/* flag of <strike> */
     1.8 	int width;		/* size of image */
     1.9 	int height;
    1.10 	char image[NNAME];	/* arg of <img> */
    1.11@@ -183,10 +184,12 @@ enum{
    1.12 	Tag_p,
    1.13 	Tag_plaintext,
    1.14 	Tag_pre,
    1.15+	Tag_s,
    1.16 	Tag_samp,
    1.17 	Tag_script,
    1.18 	Tag_select,
    1.19 	Tag_span,
    1.20+	Tag_strike,
    1.21 	Tag_strong,
    1.22 	Tag_style,
    1.23 	Tag_source,
     2.1--- a/sys/src/cmd/mothra/html.syntax.c
     2.2+++ b/sys/src/cmd/mothra/html.syntax.c
     2.3@@ -62,10 +62,12 @@ Tag tag[]={
     2.4 [Tag_p]		"p",		NOEND,	/* OPTEND */
     2.5 [Tag_plaintext]	"plaintext",	NOEND,
     2.6 [Tag_pre]	"pre",		END,
     2.7+[Tag_s]		"s",		END,
     2.8 [Tag_samp]	"samp",		END,
     2.9 [Tag_script]	"script",	END,
    2.10 [Tag_select]	"select",	END,
    2.11 [Tag_span]	"span",		END,
    2.12+[Tag_strike]	"strike",	END,
    2.13 [Tag_strong]	"strong",	END,
    2.14 [Tag_style]	"style",	END,
    2.15 [Tag_source]	"source",	NOEND,
     3.1--- a/sys/src/cmd/mothra/libpanel/panel.h
     3.2+++ b/sys/src/cmd/mothra/libpanel/panel.h
     3.3@@ -104,6 +104,7 @@ struct Panel{
     3.4 /* Rtext.flags */
     3.5 #define PL_HOT		1
     3.6 #define PL_SEL		2
     3.7+#define PL_STR		4
     3.8 
     3.9 Panel *plkbfocus;			/* the panel in keyboard focus */
    3.10 
     4.1--- a/sys/src/cmd/mothra/libpanel/rtext.c
     4.2+++ b/sys/src/cmd/mothra/libpanel/rtext.c
     4.3@@ -168,7 +168,7 @@ void pl_stuffbitmap(Panel *p, Image *b){
     4.4 
     4.5 void pl_rtdraw(Image *b, Rectangle r, Rtext *t, Point offs){
     4.6 	static Image *backup;
     4.7-	Point lp;
     4.8+	Point lp, sp;
     4.9 	Rectangle dr;
    4.10 	Image *bb;
    4.11 
    4.12@@ -181,6 +181,7 @@ void pl_rtdraw(Image *b, Rectangle r, Rt
    4.13 		b=backup;
    4.14 	pl_clr(b, r);
    4.15 	lp=ZP;
    4.16+	sp=ZP;
    4.17 	offs=subpt(r.min, offs);
    4.18 	for(;t;t=t->next) if(!eqrect(t->r, Rect(0,0,0,0))){
    4.19 		dr=rectaddpt(t->r, offs);
    4.20@@ -191,6 +192,14 @@ void pl_rtdraw(Image *b, Rectangle r, Rt
    4.21 			if(t->b){
    4.22 				draw(b, insetrect(dr, BORD), t->b, 0, t->b->r.min);
    4.23 				if(t->flags&PL_HOT) border(b, dr, 1, display->black, ZP);
    4.24+				if(t->flags&PL_STR) {
    4.25+					line(b, Pt(dr.min.x, dr.min.y), Pt(dr.max.x, dr.max.y),
    4.26+						Endsquare, Endsquare, 0,
    4.27+						display->black, ZP);
    4.28+					line(b, Pt(dr.min.x, dr.max.y), Pt(dr.max.x, dr.min.y),
    4.29+						Endsquare, Endsquare, 0,
    4.30+						display->black, ZP);
    4.31+				}
    4.32 				if(t->flags&PL_SEL)
    4.33 					pl_highlight(b, dr);
    4.34 			}
    4.35@@ -204,17 +213,30 @@ void pl_rtdraw(Image *b, Rectangle r, Rt
    4.36 				string(b, dr.min, display->black, ZP, t->font, t->text);
    4.37 				if(t->flags&PL_SEL)
    4.38 					pl_highlight(b, dr);
    4.39-				if(t->flags&PL_HOT){
    4.40-					if(lp.y+1 != dr.max.y)
    4.41-						lp = Pt(dr.min.x, dr.max.y-1);
    4.42-					line(b, lp, Pt(dr.max.x, dr.max.y-1),
    4.43+				if(t->flags&PL_STR){
    4.44+					int y = dr.max.y - t->font->height/2;
    4.45+					if(sp.y != y)
    4.46+						sp = Pt(dr.min.x, y);
    4.47+					line(b, sp, Pt(dr.max.x, y),
    4.48 						Endsquare, Endsquare, 0,
    4.49 						display->black, ZP);
    4.50-					lp = Pt(dr.max.x, dr.max.y-1);
    4.51-					continue;
    4.52-				}
    4.53+					sp = Pt(dr.max.x, y);
    4.54+				} else
    4.55+					sp = ZP;
    4.56+				if(t->flags&PL_HOT){
    4.57+					int y = dr.max.y - 1;
    4.58+					if(lp.y != y)
    4.59+						lp = Pt(dr.min.x, y);
    4.60+					line(b, lp, Pt(dr.max.x, y),
    4.61+						Endsquare, Endsquare, 0,
    4.62+						display->black, ZP);
    4.63+					lp = Pt(dr.max.x, y);
    4.64+				} else
    4.65+					lp = ZP;
    4.66+				continue;
    4.67 			}
    4.68-			lp=ZP;
    4.69+			lp = ZP;
    4.70+			sp = ZP;
    4.71 		}
    4.72 	}
    4.73 	if(b!=bb)
     5.1--- a/sys/src/cmd/mothra/rdhtml.c
     5.2+++ b/sys/src/cmd/mothra/rdhtml.c
     5.3@@ -85,7 +85,7 @@ int strtolength(Hglob *g, int dir, char 
     5.4 
     5.5 void pl_htmloutput(Hglob *g, int nsp, char *s, Field *field){
     5.6 	Fontdata *f;
     5.7-	int space, indent;
     5.8+	int space, indent, flags;
     5.9 	Action *ap;
    5.10 	if(g->state->tag==Tag_title
    5.11 /*	|| g->state->tag==Tag_textarea */
    5.12@@ -139,8 +139,12 @@ void pl_htmloutput(Hglob *g, int nsp, ch
    5.13 			space=1000000;
    5.14 		}
    5.15 	}
    5.16-	plrtstr(&g->dst->text, space, indent, f->font, strdup(s),
    5.17-		g->state->link[0] ? PL_HOT : 0, ap);
    5.18+	flags = 0;
    5.19+	if(g->state->link[0])
    5.20+		flags |= PL_HOT;
    5.21+	if(g->state->strike)
    5.22+		flags |= PL_STR;
    5.23+	plrtstr(&g->dst->text, space, indent, f->font, strdup(s), flags, ap);
    5.24 	g->para=0;
    5.25 	g->linebrk=0;
    5.26 	g->dst->changed=1;
    5.27@@ -691,6 +695,7 @@ void plrdhtml(char *name, int fd, Www *d
    5.28 	g.state->indent=25;
    5.29 	g.state->ismap=0;
    5.30 	g.state->isscript=0;
    5.31+	g.state->strike=0;
    5.32 	g.state->width=0;
    5.33 	g.state->height=0;
    5.34 	g.dst=dst;
    5.35@@ -873,6 +878,10 @@ void plrdhtml(char *name, int fd, Www *d
    5.36 		case Tag_strong:
    5.37 			g.state->font=BOLD;
    5.38 			break;
    5.39+		case Tag_s:
    5.40+		case Tag_strike:
    5.41+			g.state->strike=1;
    5.42+			break;
    5.43 		case Tag_blockquot:
    5.44 			g.spacc=0;
    5.45 			g.linebrk=1;