Point _frdraw(Frame *f, Point pt) { Frbox *b; int nb, n; for(b=f->box,nb=0; nb<f->nbox; nb++, b++) { _frcklinewrap0(f, &pt, b); if(pt.y == f->r.max.y) { f->nchars -= _frstrlen(f, nb); _frdelbox(f, nb, f->nbox-1); break; } if(b->nrune > 0) { n = _frcanfit(f, pt, b); if(n == 0) drawerror(f->display, "_frcanfit==0"); if(n != b->nrune) { _frsplitbox(f, nb, n); b = &f->box[nb]; } pt.x += b->wid; } else { if(b->bc == '\n') { pt.x = f->r.min.x; pt.y+=f->font->height; } else pt.x += _frnewwid(f, pt, b); } } return pt; }
void frclear(Frame *f) { if(f->nbox) _frdelbox(f, 0, f->nbox-1); if(f->box) free(f->box); f->box = 0; }
void _frmergebox(Frame *f, int bn) /* merge bn and bn+1 */ { Frbox *b; b = &f->box[bn]; _frinsure(f, bn, NBYTE(&b[0])+NBYTE(&b[1])+1); strcpy((char*)runeindex(b[0].a.ptr, b[0].nrune), (char*)b[1].a.ptr); b[0].wid += b[1].wid; b[0].nrune += b[1].nrune; _frdelbox(f, bn+1, bn+1); }
void frclear(Frame *f, int freeall) { if(f->nbox) _frdelbox(f, 0, f->nbox-1); if(f->box) free(f->box); if(freeall){ freeimage(f->tick); freeimage(f->tickback); f->tick = 0; f->tickback = 0; } f->box = 0; f->ticked = 0; }