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

📄 frutil.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include <u.h>#include <libc.h>#include <draw.h>#include <thread.h>#include <mouse.h>#include <frame.h>int_frcanfit(Frame *f, Point pt, Frbox *b){	int left, w, nr;	uchar *p;	Rune r;	left = f->r.max.x-pt.x;	if(b->nrune < 0)		return b->minwid <= left;	if(left >= b->wid)		return b->nrune;	for(nr=0,p=b->ptr; *p; p+=w,nr++){		r = *p;		if(r < Runeself)			w = 1;		else			w = chartorune(&r, (char*)p);		left -= stringnwidth(f->font, (char*)p, 1);		if(left < 0)			return nr;	}	drawerror(f->display, "_frcanfit can't");	return 0;}void_frcklinewrap(Frame *f, Point *p, Frbox *b){	if((b->nrune<0? b->minwid : b->wid) > f->r.max.x-p->x){		p->x = f->r.min.x;		p->y += f->font->height;	}}void_frcklinewrap0(Frame *f, Point *p, Frbox *b){	if(_frcanfit(f, *p, b) == 0){		p->x = f->r.min.x;		p->y += f->font->height;	}}void_fradvance(Frame *f, Point *p, Frbox *b){	if(b->nrune<0 && b->bc=='\n'){		p->x = f->r.min.x;		p->y += f->font->height;	}else		p->x += b->wid;}int_frnewwid(Frame *f, Point pt, Frbox *b){	b->wid = _frnewwid0(f, pt, b);	return b->wid;}int_frnewwid0(Frame *f, Point pt, Frbox *b){	int c, x;	c = f->r.max.x;	x = pt.x;	if(b->nrune>=0 || b->bc!='\t')		return b->wid;	if(x+b->minwid > c)		x = pt.x = f->r.min.x;	x += f->maxtab;	x -= (x-f->r.min.x)%f->maxtab;	if(x-pt.x<b->minwid || x>c)		x = pt.x+b->minwid;	return x-pt.x;}void_frclean(Frame *f, Point pt, int n0, int n1)	/* look for mergeable boxes */{	Frbox *b;	int nb, c;	c = f->r.max.x;	for(nb=n0; nb<n1-1; nb++){		b = &f->box[nb];		_frcklinewrap(f, &pt, b);		while(b[0].nrune>=0 && nb<n1-1 && b[1].nrune>=0 && pt.x+b[0].wid+b[1].wid<c){			_frmergebox(f, nb);			n1--;			b = &f->box[nb];		}		_fradvance(f, &pt, &f->box[nb]);	}	for(; nb<f->nbox; nb++){		b = &f->box[nb];		_frcklinewrap(f, &pt, b);		_fradvance(f, &pt, &f->box[nb]);	}	f->lastlinefull = 0;	if(pt.y >= f->r.max.y)		f->lastlinefull = 1;}

⌨️ 快捷键说明

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