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

📄 tw.c

📁 举世闻名的joe记事本源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	TW *tw = (TW *) bw->object;	if (bw->o.linums != bw->linums) {		bw->linums = bw->o.linums;		resizetw(bw, w->w, w->h);		movetw(bw, w->x, w->y);		bwfllw(bw);	}	if (bw->o.hex) {		w->cury = (bw->cursor->byte-bw->top->byte)/16 + bw->y - w->y;		w->curx = (bw->cursor->byte-bw->top->byte)%16 + 60 - bw->offset;	} else {		w->cury = bw->cursor->line - bw->top->line + bw->y - w->y;		w->curx = bw->cursor->xcol - bw->offset + (bw->o.linums ? LINCOLS : 0);	}	if ((staupd || keepup || bw->cursor->line != tw->prevline || bw->b->changed != tw->changed || bw->b != tw->prev_b) && (w->y || !staen)) {		int fill;		tw->prevline = bw->cursor->line;		tw->changed = bw->b->changed;		tw->prev_b = bw->b;		if (bw->o.rmsg[0])			fill = bw->o.rmsg[0];		else			fill = ' ';		tw->stalin = stagen(tw->stalin, bw, bw->o.lmsg, fill);		tw->staright = stagen(tw->staright, bw, bw->o.rmsg, fill);		if (fmtlen(tw->staright) < w->w) {			int x = fmtpos(tw->stalin, w->w - fmtlen(tw->staright));			if (x > sLEN(tw->stalin))				tw->stalin = vsfill(sv(tw->stalin), fill, x - sLEN(tw->stalin));			tw->stalin = vsncpy(tw->stalin, fmtpos(tw->stalin, w->w - fmtlen(tw->staright)), sv(tw->staright));		}		tw->stalin = vstrunc(tw->stalin, fmtpos(tw->stalin, w->w));		genfmt(w->t->t, w->x, w->y, 0, tw->stalin, bg_stalin, 0);		w->t->t->updtab[w->y] = 0;	}	if (flg) {		if (bw->o.hex)			bwgenh(bw);		else			bwgen(bw, bw->o.linums);	}}/* Split current window */static void iztw(TW *tw, int y){	tw->stalin = NULL;	tw->staright = NULL;	tw->changed = -1;	tw->prevline = -1;	tw->staon = (!staen || y);	tw->prev_b = 0;}int usplitw(BW *bw){	W *w = bw->parent;	int newh = getgrouph(w);	W *new;	TW *newtw;	BW *newbw;	dostaupd = 1;	if (newh / 2 < FITHEIGHT)		return -1;	new = wcreate(w->t, w->watom, findbotw(w), NULL, w, newh / 2 + (newh & 1), NULL, NULL);	if (!new)		return -1;	wfit(new->t);	new->object = (void *) (newbw = bwmk(new, bw->b, 0));	++bw->b->count;	newbw->offset = bw->offset;	newbw->object = (void *) (newtw = (TW *) joe_malloc(sizeof(TW)));	iztw(newtw, new->y);	pset(newbw->top, bw->top);	pset(newbw->cursor, bw->cursor);	newbw->cursor->xcol = bw->cursor->xcol;	new->t->curwin = new;	return 0;}int uduptw(BW *bw){	W *w = bw->parent;	int newh = getgrouph(w);	W *new;	TW *newtw;	BW *newbw;	dostaupd = 1;	new = wcreate(w->t, w->watom, findbotw(w), NULL, NULL, newh, NULL, NULL);	if (!new)		return -1;	if (demotegroup(w))		new->t->topwin = new;	new->object = (void *) (newbw = bwmk(new, bw->b, 0));	++bw->b->count;	newbw->offset = bw->offset;	newbw->object = (void *) (newtw = (TW *) joe_malloc(sizeof(TW)));	iztw(newtw, new->y);	pset(newbw->top, bw->top);	pset(newbw->cursor, bw->cursor);	newbw->cursor->xcol = bw->cursor->xcol;	new->t->curwin = new;	wfit(w->t);	return 0;}static void instw(BW *bw, B *b, long int l, long int n, int flg){	if (b == bw->b)		bwins(bw, l, n, flg);}static void deltw(BW *bw, B *b, long int l, long int n, int flg){	if (b == bw->b)		bwdel(bw, l, n, flg);}WATOM watomtw = {	USTR "main",	disptw,	bwfllw,	NULL,	rtntw,	utypebw,	resizetw,	movetw,	instw,	deltw,	TYPETW};int abortit(BW *bw){	W *w;	TW *tw;	B *b;	if (bw->parent->watom != &watomtw)		return wabort(bw->parent);	if (bw->b->pid && bw->b->count==1)		return ukillpid(bw);	w = bw->parent;	tw = (TW *) bw->object;	/* If only one main window on the screen... */	if (countmain(w->t) == 1)		/* Replace it with an orphaned buffer if there are any */		if ((b = borphan()) != NULL) {			void *object = bw->object;			/* FIXME: Shouldn't we wabort() and wcreate here to kill			   any prompt windows? */			bwrm(bw);			w->object = (void *) (bw = bwmk(w, b, 0));			wredraw(bw->parent);			bw->object = object;			return 0;		}	bwrm(bw);	vsrm(tw->stalin);	joe_free(tw);	w->object = NULL;	wabort(w);	/* Eliminate this window and it's children */	return 0;}/* User routine for aborting a text window */static int naborttw(BW *bw, int k, void *object, int *notify){	if (notify)		*notify = 1;	if (k != YES_CODE && !yncheck(yes_key, k))		return -1;	genexmsg(bw, 0, NULL);	return abortit(bw);}static int naborttw1(BW *bw, int k, void *object, int *notify){	if (notify)		*notify = 1;	if (k != YES_CODE && !yncheck(yes_key, k))		return -1;	if (!exmsg) genexmsg(bw, 0, NULL);	return abortit(bw);}/* k is last character types which lead to uabort.  If k is -1, it means uabort   was called internally, and not by the user: which means uabort will not send   Ctrl-C to process */int uabort(BW *bw, int k){	if (bw->parent->watom != &watomtw)		return wabort(bw->parent);	if (bw->b->pid && bw->b->count==1)		return ukillpid(bw);	if (bw->b->changed && bw->b->count == 1 && !bw->b->scratch)		if (mkqw(bw->parent, sz(joe_gettext(_("Lose changes to this file (y,n,^C)? "))), naborttw, NULL, NULL, NULL))			return 0;		else			return -1;	else		return naborttw(bw, YES_CODE, NULL, NULL);}int ucancel(BW *bw, int k){	if (bw->parent->watom != &watomtw) {		wabort(bw->parent);		return 0;	} else		return uabort(bw,k);}/* Same as above, but only calls genexmsg if nobody else has */int uabort1(BW *bw, int k){	if (bw->parent->watom != &watomtw)		return wabort(bw->parent);	if (bw->b->pid && bw->b->count==1)		return ukillpid(bw);	if (bw->b->changed && bw->b->count == 1 && !bw->b->scratch)		if (mkqw(bw->parent, sz(joe_gettext(_("Lose changes to this file (y,n,^C)? "))), naborttw1, NULL, NULL, NULL))			return 0;		else			return -1;	else		return naborttw1(bw, YES_CODE, NULL, NULL);}/* Abort buffer without prompting: just fail if this is last window on buffer */int uabortbuf(BW *bw){	W *w = bw->parent;	B *b;	if (bw->b->pid && bw->b->count==1)		return ukillpid(bw);	if (okrepl(bw))		return -1;	if ((b = borphan()) != NULL) {		void *object = bw->object;		bwrm(bw);		w->object = (void *) (bw = bwmk(w, b, 0));		wredraw(bw->parent);		bw->object = object;		return 0;	}	return naborttw(bw, YES_CODE, NULL, NULL);}/* Kill current window (orphans buffer) */int utw0(BASE *b){	BW *bw = b->parent->main->object;	if (countmain(b->parent->t) == 1)		return -1;	if (bw->b->count == 1)		orphit(bw);	return uabort(bw, -1);}/* Kill all other windows (orphans buffers) */int utw1(BASE *b){	W *starting = b->parent;	W *mainw = starting->main;	Screen *t = mainw->t;	int yn;	do {		yn = 0;	      loop:		do {			wnext(t);		} while (t->curwin->main == mainw && t->curwin != starting);		if (t->curwin->main != mainw) {			BW *bw = t->curwin->main->object;			utw0((BASE *)bw);			yn = 1;			goto loop;		}	} while (yn);	return 0;}void setline(B *b, long int line){	W *w = maint->curwin;	do {		if (w->watom->what == TYPETW) {			BW *bw = w->object;			if (bw->b == b) {				long oline = bw->top->line;				/* pline(bw->top, line); */				pline(bw->cursor, line);				if (w->y >= 0 && bw->top->line > oline && bw->top->line - oline < bw->h)					nscrlup(w->t->t, bw->y, bw->y + bw->h, (int) (bw->top->line - oline));				else if (w->y >= 0 && bw->top->line < oline && oline - bw->top->line < bw->h)					nscrldn(w->t->t, bw->y, bw->y + bw->h, (int) (oline - bw->top->line));				msetI(bw->t->t->updtab + bw->y, 1, bw->h);			}		}	} while ((w = w->link.next) != maint->curwin);	/* In case error buffer was orphaned */	if (errbuf == b && b->oldcur) {		pline(b->oldcur, line);	}}/* Create a text window.  It becomes the last window on the screen */BW *wmktw(Screen *t, B *b){	W *w;	BW *bw;	TW *tw;	w = wcreate(t, &watomtw, NULL, NULL, NULL, t->h, NULL, NULL);	wfit(w->t);	w->object = (void *) (bw = bwmk(w, b, 0));	bw->object = (void *) (tw = (TW *) joe_malloc(sizeof(TW)));	iztw(tw, w->y);	return bw;}

⌨️ 快捷键说明

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