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

📄 w.c

📁 举世闻名的joe记事本源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	if ((w->link.next == w->t->topwin || w->link.next->y == -1) && w != w->t->topwin)		return wgrow(w->link.prev->main);	/* Is this window too small already? */	if (w->h <= FITHEIGHT)		return -1;	/* Get to window below us */	for (nextw = w->link.next; nextw != w->t->topwin && nextw->fixed; nextw = nextw->link.next) ;	if (nextw == w->t->topwin)		return -1;	/* Decrease the size of this window */	seth(w, w->h - 1);	/* Increase the size of next window */	seth(nextw, nextw->h + 1);	/* Do it */	wfit(w->t);	return 0;}/* Grow window up */int wgrowup(W *w){	return wshrink(w->link.prev->main);}/* Grow window down */int wgrowdown(W *w){	return wgrow(w->link.prev->main);}/* Show all windows */void wshowall(Screen *t){	int n = 0;	int set;	W *w;	/* Count no. of main windows */	w = t->topwin;	do {		if (!w->win)			++n;		w = w->link.next;	} while (w != t->topwin);	/* Compute size to set each window */	if ((set = (t->h - t->wind) / n) < FITHEIGHT)		set = FITHEIGHT;	/* Set size of each variable size window */	w = t->topwin;	do {		if (!w->win) {			int h = getminh(w);			if (h >= set)				seth(w, 2);			else				seth(w, set - (h - 2));			w->orgwin = NULL;		}		w = w->link.next;	} while (w != t->topwin);	/* Do it */	wfit(t);}static void wspread(Screen *t){	int n = 0;	W *w = t->topwin;	do {		if (w->y >= 0 && !w->win)			++n;		w = w->link.next;	} while (w != t->topwin);	if (!n) {		wfit(t);		return;	}	if ((t->h - t->wind) / n >= FITHEIGHT)		n = (t->h - t->wind) / n;	else		n = FITHEIGHT;	w = t->topwin;	do {		if (!w->win) {			int h = getminh(w);			if (h >= n)				seth(w, 2);			else				seth(w, n - (h - 2));			w->orgwin = NULL;		}		w = w->link.next;	} while (w != t->topwin);	wfit(t);}/* Show just one family of windows */void wshowone(W *w){	W *q = w->t->topwin;	do {		if (!q->win) {			seth(q, w->t->h - w->t->wind - (getminh(q) - 2));			q->orgwin = NULL;		}		q = q->link.next;	} while (q != w->t->topwin);	wfit(w->t);}/* Create a window */W *wcreate(Screen *t, WATOM *watom, W *where, W *target, W *original, int height, unsigned char *huh, int *notify){	W *new;	if (height < 1)		return NULL;	/* Create the window */	new = (W *) joe_malloc(sizeof(W));	new->notify = notify;	new->t = t;	new->w = t->w - 1;	seth(new, height);	new->h = new->reqh;	new->y = -1;	new->ny = 0;	new->nh = 0;	new->x = 0;	new->huh = huh;	new->orgwin = original;	new->watom = watom;	new->object = NULL;	new->msgb = NULL;	new->msgt = NULL;	/* Set window's target and family *//* was:	if (new->win = target) {	which may be mistyped == */	if ((new->win = target) != NULL) {	/* A subwindow */		new->main = target->main;		new->fixed = height;	} else {		/* A parent window */		new->main = new;		new->fixed = 0;	}	/* Get space for window */	if (original) {		if (original->h - height <= 2) {			/* Not enough space for window */			joe_free(new);			return NULL;		} else			seth(original, original->h - height);	}	/* Create new keyboard handler for window */	if (watom->context)		new->kbd = mkkbd(kmap_getcontext(watom->context));	else		new->kbd = NULL;	/* Put window on the screen */	if (where)		enquef(W, link, where, new);	else {		if (t->topwin)			enqueb(W, link, t->topwin, new);		else {			izque(W, link, new);			t->curwin = t->topwin = new;		}	}	return new;}/* Abort group of windows */static int doabort(W *w, int *ret){	int amnt = geth(w);	W *z;	w->y = -2;	if (w->t->topwin == w)		w->t->topwin = w->link.next;      loop:	z = w->t->topwin;	do {		if (z->orgwin == w)			z->orgwin = NULL;		if ((z->win == w || z->main == w) && z->y != -2) {			amnt += doabort(z, ret);			goto loop;		}	} while (z = z->link.next, z != w->t->topwin);	if (w->orgwin)		seth(w->orgwin, geth(w->orgwin) + geth(w));	if (w->t->curwin == w) {		if (w->t->curwin->win)			w->t->curwin = w->t->curwin->win;		else if (w->orgwin)			w->t->curwin = w->orgwin;		else			w->t->curwin = w->link.next;	}	if (qempty(W, link, w)) {		leave = 1;		amnt = 0;	}	deque(W, link, w);	if (w->watom->abort && w->object) {		*ret = w->watom->abort(w->object);		if (w->notify)			*w->notify = -1;	} else {		*ret = -1;		if (w->notify)			*w->notify = 1;	}	rmkbd(w->kbd);	joe_free(w);	windie(w);	return amnt;}/* Abort a window and its children */int wabort(W *w){	Screen *t = w->t;	int ret;	if (w != w->main) {		doabort(w, &ret);		if (!leave)			wfit(t);	} else {		doabort(w, &ret);		if (!leave) {			if (lastw(t)->link.next != t->topwin)				wfit(t);			else				wspread(t);		}	}	return ret;}/* Display a message and skip the next key */int bg_msg;static void mdisp(SCRN *t, int y, unsigned char *s){	int ofst;	int len;	len = fmtlen(s);	if (len <= (t->co - 1))		ofst = 0;	else		ofst = len - (t->co - 1);	genfmt(t, 0, y, ofst, s, BG_COLOR(bg_msg), 1);	t->updtab[y] = 1;}void msgout(W *w){	SCRN *t = w->t->t;	if (w->msgb) {		mdisp(t, w->y + w->h - 1, w->msgb);		w->msgb = 0;	}	if (w->msgt) {		mdisp(t, w->y + ((w->h > 1 && (w->y || !staen)) ? 1 : 0), w->msgt);		w->msgt = 0;	}}/* Set temporary message */unsigned char msgbuf[JOE_MSGBUFSIZE];/* display message on bottom line of window */void msgnw(W *w, unsigned char *s){	w->msgb = s;}void msgnwt(W *w, unsigned char *s){	w->msgt = s;}int urtn(BASE *b, int k){	if (b->parent->watom->rtn)		return b->parent->watom->rtn(b, k);	else		return -1;}int utype(BASE *b, int k){	if (b->parent->watom->type)		return b->parent->watom->type(b, k);	else		return -1;}/* Window user commands */int uprevw(BASE *bw){	return wprev(bw->parent->t);}int unextw(BASE *bw){	return wnext(bw->parent->t);}int ugroww(BASE *bw){	return wgrow(bw->parent);}int ushrnk(BASE *bw){	return wshrink(bw->parent);}int uexpld(BASE *bw){	if (bw->parent->t->h - bw->parent->t->wind == getgrouph(bw->parent))		wshowall(bw->parent->t);	else		wshowone(bw->parent);	return 0;}int uretyp(BASE *bw){	nredraw(bw->parent->t->t);	return 0;}/* Get message window on screen */W *find_window(Screen *t, B *b){	W *w = t->topwin;	do {		if (w->watom == &watomtw && ((BW *)w->object)->b == b)			return w;		w = w->link.next;	} while(w != t->topwin);	return 0;}int umwind(BW *bw){	W *msgw;	if (!errbuf) {		msgnw(bw->parent, joe_gettext(_("There is no message buffer")));		return -1;	}	/* Find message window */	msgw = find_window(bw->parent->t, errbuf);	if (msgw) {		/* The window exists */		bw->parent->t->curwin = msgw;		wshowone(msgw);		return 0;	} else {		/* Make it the current window */		msgw = bw->parent;		get_buffer_in_window(bw, errbuf);		wshowone(msgw);		return 0;	}}/* Fit previous window and current window on screen.  If there is no previous window, * split the current window to create one. */int umfit(BW *bw){	W *p;	W *w = bw->parent->main;	Screen *t = w->t;	wshowone(w);	p = findtopw(w)->link.prev->main;	if (p == w) {		/* We have to split */		usplitw(bw);	}	w = t->curwin;	p = findtopw(w)->link.prev->main;	if (p == w) {		return -1;	}	/* Request size */	if (p->t->h - 6 < 3)		return -1;	seth(p, p->t->h - 6);	t->topwin = p;	t->curwin = p;	/* Fit them on the screen */	wfit(t);	t->curwin = w;	wfit(t);	return 0;}

⌨️ 快捷键说明

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