⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frinit.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include <u.h>#include <libc.h>#include <draw.h>#include <thread.h>#include <mouse.h>#include <frame.h>voidfrinit(Frame *f, Rectangle r, Font *ft, Image *b, Image *cols[NCOL]){	f->font = ft;	f->display = b->display;	f->maxtab = 8*stringwidth(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;	if(cols != 0)		memmove(f->cols, cols, sizeof f->cols);	frsetrects(f, r, b);	if(f->tick==nil && f->cols[BACK]!=0)		frinittick(f);}voidfrinittick(Frame *f){	Image *b;	Font *ft;	b = f->display->screenimage;	ft = f->font;	if(f->tick)		freeimage(f->tick);	f->tick = allocimage(f->display, Rect(0, 0, FRTICKW, ft->height), b->chan, 0, DWhite);	if(f->tick == nil)		return;	if(f->tickback)		freeimage(f->tickback);	f->tickback = allocimage(f->display, f->tick->r, b->chan, 0, DWhite);	if(f->tickback == 0){		freeimage(f->tick);		f->tick = 0;		return;	}	/* background color */	draw(f->tick, f->tick->r, f->cols[BACK], nil, ZP);	/* vertical line */	draw(f->tick, Rect(FRTICKW/2, 0, FRTICKW/2+1, ft->height), f->display->black, nil, ZP);	/* box on each end */	draw(f->tick, Rect(0, 0, FRTICKW, FRTICKW), f->cols[TEXT], nil, ZP);	draw(f->tick, Rect(0, ft->height-FRTICKW, FRTICKW, ft->height), f->cols[TEXT], nil, ZP);}voidfrsetrects(Frame *f, Rectangle r, Image *b){	f->b = b;	f->entire = r;	f->r = r;	f->r.max.y -= (r.max.y-r.min.y)%f->font->height;	f->maxlines = (r.max.y-r.min.y)/f->font->height;}voidfrclear(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;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -