1 #include <u.h> 2 #include <libc.h> 3 #include <libg.h> 4 #include <frame.h> 5 6 void 7 frinit(Frame *f, Rectangle r, Font *ft, Bitmap *b) 8 { 9 f->font = ft; 10 f->maxtab = 8*charwidth(ft, '0'); 11 f->nbox = 0; 12 f->nalloc = 0; 13 f->nchars = 0; 14 f->nlines = 0; 15 f->p0 = 0; 16 f->p1 = 0; 17 f->box = 0; 18 f->lastlinefull = 0; 19 frsetrects(f, r, b); 20 } 21 22 void 23 frsetrects(Frame *f, Rectangle r, Bitmap *b) 24 { 25 f->b = b; 26 f->entire = r; 27 f->r = r; 28 f->r.max.y -= (r.max.y-r.min.y)%f->font->height; 29 f->left = r.min.x+1; 30 f->maxlines = (r.max.y-r.min.y)/f->font->height; 31 } 32 33 void 34 frclear(Frame *f) 35 { 36 if(f->nbox) 37 _frdelbox(f, 0, f->nbox-1); 38 if(f->box) 39 free(f->box); 40 f->box = 0; 41 } 42