File: frinit.c

package info (click to toggle)
sam 4.3-18.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,440 kB
  • ctags: 1,662
  • sloc: ansic: 14,328; sh: 879; makefile: 205
file content (42 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Copyright (c) 1992 AT&T - All rights reserved. */
#include <u.h>
#include <libc.h>
#include <libg.h>
#include <frame.h>

void
frinit(Frame *f, Rectangle r, Font *ft, Bitmap *b)
{
	f->font = ft;
	f->maxtab = 8*charwidth(ft, '0');
	f->nbox = 0;
	f->nalloc = 0;
	f->nchars = 0;
	f->nlines = 0;
	f->p0 = 0;
	f->p1 = 0;
	f->box = 0;
	f->lastlinefull = 0;
	frsetrects(f, r, b);
}

void
frsetrects(Frame *f, Rectangle r, Bitmap *b)
{
	f->b = b;
	f->entire = r;
	f->r = r;
	f->r.max.y -= (r.max.y-r.min.y)%f->font->height;
	f->left = r.min.x+1;
	f->maxlines = (r.max.y-r.min.y)/f->font->height;
}

void
frclear(Frame *f)
{
	if(f->nbox)
		_frdelbox(f, 0, f->nbox-1);
	if(f->box)
		free(f->box);
	f->box = 0;
}