ref: 6411efcde8e9fea9c7a791a76578823bfe0942cb
parent: e451804a75ac4931e981eec8ba8d7a7a503a0585
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Mar 15 13:05:24 EDT 2015
mothra: add <strike> support
--- a/sys/src/cmd/mothra/html.h
+++ b/sys/src/cmd/mothra/html.h
@@ -34,6 +34,7 @@
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 @@
Tag_p,
Tag_plaintext,
Tag_pre,
+ Tag_s,
Tag_samp,
Tag_script,
Tag_select,
Tag_span,
+ Tag_strike,
Tag_strong,
Tag_style,
Tag_source,
--- a/sys/src/cmd/mothra/html.syntax.c
+++ b/sys/src/cmd/mothra/html.syntax.c
@@ -62,10 +62,12 @@
[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,
--- a/sys/src/cmd/mothra/libpanel/panel.h
+++ b/sys/src/cmd/mothra/libpanel/panel.h
@@ -104,6 +104,7 @@
/* Rtext.flags */
#define PL_HOT 1
#define PL_SEL 2
+#define PL_STR 4
Panel *plkbfocus; /* the panel in keyboard focus */
--- a/sys/src/cmd/mothra/libpanel/rtext.c
+++ b/sys/src/cmd/mothra/libpanel/rtext.c
@@ -168,7 +168,7 @@
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 @@
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 @@
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 @@
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)
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -85,7 +85,7 @@
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 @@
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 @@
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;
@@ -872,6 +877,10 @@
case Tag_b:
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;