diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-15 17:05:24 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-15 17:05:24 +0100 |
commit | 6411efcde8e9fea9c7a791a76578823bfe0942cb (patch) | |
tree | 0a6df448b90a4687e48f6ebf168c68e0b418b0f3 /sys/src/cmd/mothra | |
parent | e451804a75ac4931e981eec8ba8d7a7a503a0585 (diff) |
mothra: add <strike> support
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r-- | sys/src/cmd/mothra/html.h | 3 | ||||
-rw-r--r-- | sys/src/cmd/mothra/html.syntax.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/panel.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/rtext.c | 38 | ||||
-rw-r--r-- | sys/src/cmd/mothra/rdhtml.c | 15 |
5 files changed, 48 insertions, 11 deletions
diff --git a/sys/src/cmd/mothra/html.h b/sys/src/cmd/mothra/html.h index f486755be..951feeeb9 100644 --- a/sys/src/cmd/mothra/html.h +++ b/sys/src/cmd/mothra/html.h @@ -34,6 +34,7 @@ struct Stack{ int number; /* paragraph number */ int ismap; /* flag of <img> */ int isscript; /* inside <script> */ + int strike; /* flag of <strike> */ int width; /* size of image */ int height; char image[NNAME]; /* arg of <img> */ @@ -183,10 +184,12 @@ enum{ Tag_p, Tag_plaintext, Tag_pre, + Tag_s, Tag_samp, Tag_script, Tag_select, Tag_span, + Tag_strike, Tag_strong, Tag_style, Tag_source, diff --git a/sys/src/cmd/mothra/html.syntax.c b/sys/src/cmd/mothra/html.syntax.c index 87e44016d..a6912d329 100644 --- a/sys/src/cmd/mothra/html.syntax.c +++ b/sys/src/cmd/mothra/html.syntax.c @@ -62,10 +62,12 @@ Tag tag[]={ [Tag_p] "p", NOEND, /* OPTEND */ [Tag_plaintext] "plaintext", NOEND, [Tag_pre] "pre", END, +[Tag_s] "s", END, [Tag_samp] "samp", END, [Tag_script] "script", END, [Tag_select] "select", END, [Tag_span] "span", END, +[Tag_strike] "strike", END, [Tag_strong] "strong", END, [Tag_style] "style", END, [Tag_source] "source", NOEND, diff --git a/sys/src/cmd/mothra/libpanel/panel.h b/sys/src/cmd/mothra/libpanel/panel.h index 8c9680c10..7c06bc2fd 100644 --- a/sys/src/cmd/mothra/libpanel/panel.h +++ b/sys/src/cmd/mothra/libpanel/panel.h @@ -104,6 +104,7 @@ struct Panel{ /* Rtext.flags */ #define PL_HOT 1 #define PL_SEL 2 +#define PL_STR 4 Panel *plkbfocus; /* the panel in keyboard focus */ diff --git a/sys/src/cmd/mothra/libpanel/rtext.c b/sys/src/cmd/mothra/libpanel/rtext.c index 68bccfad3..92f195633 100644 --- a/sys/src/cmd/mothra/libpanel/rtext.c +++ b/sys/src/cmd/mothra/libpanel/rtext.c @@ -168,7 +168,7 @@ void pl_stuffbitmap(Panel *p, Image *b){ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, Point offs){ static Image *backup; - Point lp; + Point lp, sp; Rectangle dr; Image *bb; @@ -181,6 +181,7 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, Point offs){ b=backup; pl_clr(b, r); lp=ZP; + sp=ZP; offs=subpt(r.min, offs); for(;t;t=t->next) if(!eqrect(t->r, Rect(0,0,0,0))){ dr=rectaddpt(t->r, offs); @@ -191,6 +192,14 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, Point offs){ if(t->b){ draw(b, insetrect(dr, BORD), t->b, 0, t->b->r.min); if(t->flags&PL_HOT) border(b, dr, 1, display->black, ZP); + if(t->flags&PL_STR) { + line(b, Pt(dr.min.x, dr.min.y), Pt(dr.max.x, dr.max.y), + Endsquare, Endsquare, 0, + display->black, ZP); + line(b, Pt(dr.min.x, dr.max.y), Pt(dr.max.x, dr.min.y), + Endsquare, Endsquare, 0, + display->black, ZP); + } if(t->flags&PL_SEL) pl_highlight(b, dr); } @@ -204,17 +213,30 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, Point offs){ string(b, dr.min, display->black, ZP, t->font, t->text); if(t->flags&PL_SEL) pl_highlight(b, dr); + if(t->flags&PL_STR){ + int y = dr.max.y - t->font->height/2; + if(sp.y != y) + sp = Pt(dr.min.x, y); + line(b, sp, Pt(dr.max.x, y), + Endsquare, Endsquare, 0, + display->black, ZP); + sp = Pt(dr.max.x, y); + } else + sp = ZP; if(t->flags&PL_HOT){ - if(lp.y+1 != dr.max.y) - lp = Pt(dr.min.x, dr.max.y-1); - line(b, lp, Pt(dr.max.x, dr.max.y-1), + int y = dr.max.y - 1; + if(lp.y != y) + lp = Pt(dr.min.x, y); + line(b, lp, Pt(dr.max.x, y), Endsquare, Endsquare, 0, display->black, ZP); - lp = Pt(dr.max.x, dr.max.y-1); - continue; - } + lp = Pt(dr.max.x, y); + } else + lp = ZP; + continue; } - lp=ZP; + lp = ZP; + sp = ZP; } } if(b!=bb) diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index cf13c213f..aeee19429 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -85,7 +85,7 @@ int strtolength(Hglob *g, int dir, char *str){ void pl_htmloutput(Hglob *g, int nsp, char *s, Field *field){ Fontdata *f; - int space, indent; + int space, indent, flags; Action *ap; if(g->state->tag==Tag_title /* || g->state->tag==Tag_textarea */ @@ -139,8 +139,12 @@ void pl_htmloutput(Hglob *g, int nsp, char *s, Field *field){ space=1000000; } } - plrtstr(&g->dst->text, space, indent, f->font, strdup(s), - g->state->link[0] ? PL_HOT : 0, ap); + flags = 0; + if(g->state->link[0]) + flags |= PL_HOT; + if(g->state->strike) + flags |= PL_STR; + plrtstr(&g->dst->text, space, indent, f->font, strdup(s), flags, ap); g->para=0; g->linebrk=0; g->dst->changed=1; @@ -691,6 +695,7 @@ void plrdhtml(char *name, int fd, Www *dst){ g.state->indent=25; g.state->ismap=0; g.state->isscript=0; + g.state->strike=0; g.state->width=0; g.state->height=0; g.dst=dst; @@ -873,6 +878,10 @@ void plrdhtml(char *name, int fd, Www *dst){ case Tag_strong: g.state->font=BOLD; break; + case Tag_s: + case Tag_strike: + g.state->strike=1; + break; case Tag_blockquot: g.spacc=0; g.linebrk=1; |