diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-01-31 20:18:45 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-01-31 20:18:45 +0100 |
commit | 7fbed4d63541f9695c00f295e1dfde10bb8d9808 (patch) | |
tree | d81666f6631616deadcd59bb2ef988ff932c0a21 /sys/src/cmd/mothra | |
parent | 3ce514ca0a36e90a89a066a3c73f4d45ceb5c530 (diff) |
mothra: people do not like it. reverting
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r-- | sys/src/cmd/mothra/libpanel/rtext.c | 92 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/rtext.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/mothra/mothra.c | 6 |
3 files changed, 16 insertions, 83 deletions
diff --git a/sys/src/cmd/mothra/libpanel/rtext.c b/sys/src/cmd/mothra/libpanel/rtext.c index fcd8ab97b..a18be62f5 100644 --- a/sys/src/cmd/mothra/libpanel/rtext.c +++ b/sys/src/cmd/mothra/libpanel/rtext.c @@ -65,55 +65,6 @@ int pl_space(int space, int pos, int indent){ return ((pos-indent+pl_tabmin)/pl_tabsize+PL_ARG(space))*pl_tabsize+indent-pos; } } - -static void -unwrap(Rtext *t) -{ - Rtext *w; - - if(t == nil) - return; - while((w = t->next) != nil){ - if(PL_OP(w->space) != PL_WRAP) - return; - t->next = w->next; - free(w); - } -} - -static void -wrap(Rtext *t, int x) -{ - Rtext *w; - char *s; - Rune r; - - w = nil; - if(t->b){ - if(PL_OP(t->space) == PL_WRAP) - x += PL_ARG(t->space); - if(t->b->repl || x >= Dx(t->b->r) || x > PL_ARGMASK) - return; - plrtbitmap(&w, PL_WRAP|x, 0, t->b, t->flags, t->user); - } - else if(t->p) { - return; - } - else { - s = t->text; - while(*s != '\0'){ - if((t->wid - stringwidth(t->font, s)) >= x) - break; - s += chartorune(&r, s); - } - if(*s == '\0') - return; - plrtstr(&w, PL_WRAP, 0, t->font, s, t->flags, t->user); - } - w->next = t->next; - t->next = w; -} - /* * initialize rectangles & nextlines of text starting at t, * galley width is wid. Returns the total length of the text @@ -131,23 +82,18 @@ int pl_rtfmt(Rtext *t, int wid){ x=0; tp=t; for(;;){ - unwrap(tp); if(tp->b){ - a=Dy(tp->b->r)+BORD; + a=tp->b->r.max.y-tp->b->r.min.y+BORD; d=BORD; - w=Dx(tp->b->r)+BORD*2; - if(PL_OP(t->space) == PL_WRAP) - w -= PL_ARG(t->space); - if(tp->b->repl) - w = wid; + w=tp->b->r.max.x-tp->b->r.min.x+BORD*2; } else if(tp->p){ /* what if plpack fails? */ plpack(tp->p, Rect(0,0,wid,wid)); plmove(tp->p, subpt(Pt(0,0), tp->p->r.min)); - a=Dy(tp->p->r); + a=tp->p->r.max.y-tp->p->r.min.y; d=0; - w=Dx(tp->p->r); + w=tp->p->r.max.x-tp->p->r.min.x; } else{ a=tp->font->ascent; @@ -168,7 +114,6 @@ int pl_rtfmt(Rtext *t, int wid){ } if(eline==t){ /* No progress! Force fit the first block! */ if(tp==t){ - wrap(tp, wid - x); if(a>ascent) ascent=a; if(d>descent) descent=d; eline=tp->next; @@ -183,12 +128,8 @@ int pl_rtfmt(Rtext *t, int wid){ t->r.min.x=p.x; if(t->b){ t->r.max.y=p.y+BORD; - t->r.min.y=p.y-Dy(t->b->r)-BORD; - p.x+=Dx(t->b->r)+BORD*2; - if(PL_OP(t->space) == PL_WRAP) - p.x -= PL_ARG(t->space); - if(t->b->repl) - p.x = wid; + t->r.min.y=p.y-(t->b->r.max.y-t->b->r.min.y)-BORD; + p.x+=(t->b->r.max.x-t->b->r.min.x)+BORD*2; } else if(t->p){ t->r.max.y=p.y; @@ -243,11 +184,7 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){ if(dr.max.y>r.min.y && dr.min.y<r.max.y){ if(t->b){ - Point sp; - sp = t->b->r.min; - if(PL_OP(t->space) == PL_WRAP) - sp.x += PL_ARG(t->space); - draw(b, insetrect(dr, BORD), t->b, 0, sp); + 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_SEL) pl_highlight(b, dr); @@ -356,16 +293,13 @@ void plrtseltext(Rtext *t, Rtext *s, Rtext *e){ char *plrtsnarftext(Rtext *w){ char *b, *p, *e, *t; - int n, m; + int n; b=p=e=0; for(; w; w = w->next){ if((w->flags&PL_SEL)==0 || w->text==0) continue; - m = strlen(w->text); - if(w->next!=0 && PL_OP(w->next->space)==PL_WRAP && w->next->text>w->text) - m -= strlen(w->next->text); - n = m+64; + n = strlen(w->text)+64; if(p+n >= e){ n = (p+n+64)-b; t = pl_erealloc(b, n); @@ -373,12 +307,12 @@ char *plrtsnarftext(Rtext *w){ e = t+n; b = t; } - if(w->space == 0 || PL_OP(w->space) == PL_WRAP) - p += sprint(p, "%.*s", m, w->text); + if(w->space == 0) + p += sprint(p, "%s", w->text); else if(w->space > 0) - p += sprint(p, " %.*s", m, w->text); + p += sprint(p, " %s", w->text); else if(PL_OP(w->space) == PL_TAB) - p += sprint(p, "\t%.*s", m, w->text); + p += sprint(p, "\t%s", w->text); if(w->nextline == w->next) p += sprint(p, "\n"); } diff --git a/sys/src/cmd/mothra/libpanel/rtext.h b/sys/src/cmd/mothra/libpanel/rtext.h index e70b37186..78a4b0ce9 100644 --- a/sys/src/cmd/mothra/libpanel/rtext.h +++ b/sys/src/cmd/mothra/libpanel/rtext.h @@ -8,5 +8,4 @@ #define PL_OP(t) ((t)&~PL_ARGMASK) #define PL_ARG(t) ((t)&PL_ARGMASK) #define PL_TAB PL_SPECIAL(0) /* # of tab stops before text */ -#define PL_WRAP PL_SPECIAL(1) void pltabsize(int, int); /* set min tab and tab size */ diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index 09eeb7bc6..c1faf8ffd 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -318,11 +318,11 @@ void main(int argc, char *argv[]){ plinit(screen->depth); if(debug) notify(dienow); getfonts(); - hrule=allocimage(display, Rect(0, 0, 1, 5), screen->chan, 1, DWhite); + hrule=allocimage(display, Rect(0, 0, 2048, 5), screen->chan, 0, DWhite); if(hrule==0) sysfatal("can't allocimage!"); - draw(hrule, Rect(0,1,1,3), display->black, 0, ZP); - linespace=allocimage(display, Rect(0, 0, 1, 5), screen->chan, 1, DWhite); + draw(hrule, Rect(0,1,1280,3), display->black, 0, ZP); + linespace=allocimage(display, Rect(0, 0, 2048, 5), screen->chan, 0, DWhite); if(linespace==0) sysfatal("can't allocimage!"); bullet=allocimage(display, Rect(0,0,25, 8), screen->chan, 0, DWhite); |