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

📄 svi_split.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	free(SVP(tsp));	FREE(tsp, sizeof(SCR));	return (1);}/* * svi_bg -- *	Background the screen, and switch to the next one. */intsvi_bg(csp)	SCR *csp;{	SCR *sp;	/* Try and join with another screen. */	if ((svi_join(csp, &sp)))		return (1);	if (sp == NULL) {		msgq(csp, M_ERR,		    "You may not background your only displayed screen.");		return (1);	}	/* Move the old screen to the hidden queue. */	CIRCLEQ_REMOVE(&csp->gp->dq, csp, q);	CIRCLEQ_INSERT_TAIL(&csp->gp->hq, csp, q);	/* Switch screens. */	csp->nextdisp = sp;	F_SET(csp, S_SSWITCH);	return (0);}/* * svi_join -- *	Join the screen into a related screen, if one exists, *	and return that screen. */intsvi_join(csp, nsp)	SCR *csp, **nsp;{	SCR *sp;	size_t cnt;	/*	 * If a split screen, add space to parent/child.  Make no effort	 * to clean up the screen's values.  If it's not exiting, we'll	 * get it when the user asks to show it again.	 */	if ((sp = csp->q.cqe_prev) == (void *)&csp->gp->dq) {		if ((sp = csp->q.cqe_next) == (void *)&csp->gp->dq) {			*nsp = NULL;			return (0);		}		sp->woff = csp->woff;	}	sp->rows += csp->rows;	if (ISSMALLSCREEN(sp)) {		sp->t_maxrows += csp->rows;		for (cnt = sp->t_rows; ++cnt <= sp->t_maxrows;) {			MOVE(sp, cnt, 0);			clrtoeol();		}		TMAP = HMAP + (sp->t_rows - 1);	} else {		sp->t_maxrows += csp->rows;		sp->t_rows = sp->t_minrows = sp->t_maxrows;		TMAP = HMAP + (sp->t_rows - 1);		if (svi_sm_fill(sp, sp->ep, sp->lno, P_FILL))			return (1);		F_SET(sp, S_REDRAW);	}	/*	 * If the size of the scrolling region hasn't been modified by	 * the user, reset it so it's reasonable for the new screen.	 */	if (!F_ISSET(&sp->opts[O_SCROLL], OPT_SET))		O_VAL(sp, O_SCROLL) = sp->t_maxrows / 2;	*nsp = sp;	return (0);}/* * svi_fg -- *	Background the current screen, and foreground a new one. */intsvi_fg(csp, name)	SCR *csp;	CHAR_T *name;{	SCR *sp;	if (svi_swap(csp, &sp, name))		return (1);	if (sp == NULL) {		if (name == NULL)			msgq(csp, M_ERR, "There are no background screens.");		else			msgq(csp, M_ERR,		    "There's no background screen editing a file named %s.",			    name);		return (1);	}	/* Move the old screen to the hidden queue. */	CIRCLEQ_REMOVE(&csp->gp->dq, csp, q);	CIRCLEQ_INSERT_TAIL(&csp->gp->hq, csp, q);	return (0);}/* * svi_swap -- *	Swap the current screen with a hidden one. */intsvi_swap(csp, nsp, name)	SCR *csp, **nsp;	char *name;{	SCR *sp;	int issmallscreen;	/* Find the screen, or, if name is NULL, the first screen. */	for (sp = csp->gp->hq.cqh_first;	    sp != (void *)&csp->gp->hq; sp = sp->q.cqe_next)		if (name == NULL || !strcmp(FILENAME(sp->frp), name))			break;	if (sp == (void *)&csp->gp->hq) {		*nsp = NULL;		return (0);	}	*nsp = sp;	/* Save the old screen's cursor information. */	csp->frp->lno = csp->lno;	csp->frp->cno = csp->cno;	F_SET(csp->frp, FR_CURSORSET);	/* Switch screens. */	csp->nextdisp = sp;	F_SET(csp, S_SSWITCH);	/* Initialize terminal information. */	SVP(sp)->srows = SVP(csp)->srows;	issmallscreen = ISSMALLSCREEN(sp);	/* Initialize screen information. */	sp->rows = csp->rows;	sp->cols = csp->cols;	sp->woff = csp->woff;	/*	 * Small screens: see svi/svi_refresh.c:svi_refresh, section 3b.	 *	 * The new screens may have different screen options sizes than the	 * old one, so use them.  Make sure that text counts aren't larger	 * than the new screen sizes.	 */	if (issmallscreen) {		sp->t_minrows = sp->t_rows = O_VAL(sp, O_WINDOW);		if (sp->t_rows > csp->t_maxrows)			sp->t_rows = sp->t_maxrows;		if (sp->t_minrows > csp->t_maxrows)			sp->t_minrows = sp->t_maxrows;	} else		sp->t_rows = sp->t_maxrows = sp->t_minrows = sp->rows - 1;	/*	 * If the size of the scrolling region hasn't been modified by	 * the user, reset it so it's reasonable for the new screen.	 */	if (!F_ISSET(&sp->opts[O_SCROLL], OPT_SET))		O_VAL(sp, O_SCROLL) = sp->t_maxrows / 2;	/*	 * Don't change the screen's cursor information other than to	 * note that the cursor is wrong.	 */	F_SET(SVP(sp), SVI_CUR_INVALID);	/*	 * The HMAP may be NULL, if the screen got resized and	 * a bunch of screens had to be hidden.	 */	if (HMAP == NULL)		CALLOC_RET(sp, HMAP, SMAP *, SIZE_HMAP(sp), sizeof(SMAP));	TMAP = HMAP + (sp->t_rows - 1);	/* Fill the map. */	if (svi_sm_fill(sp, sp->ep, sp->lno, P_FILL))		return (1);	/*	 * The new screen replaces the old screen in the parent/child list.	 * We insert the new screen after the old one.  If we're exiting,	 * the exit will delete the old one, if we're foregrounding, the fg	 * code will move the old one to the hidden queue.	 */	CIRCLEQ_REMOVE(&sp->gp->hq, sp, q);	CIRCLEQ_INSERT_AFTER(&csp->gp->dq, csp, sp, q);	F_SET(sp, S_REDRAW);	return (0);}/* * svi_rabs -- *	Change the absolute size of the current screen. */intsvi_rabs(sp, count, adj)	SCR *sp;	long count;	enum adjust adj;{	SCR *g, *s;	/*	 * Figure out which screens will grow, which will shrink, and	 * make sure it's possible.	 */	if (count == 0)		return (0);	if (adj == A_SET) {		if (sp->t_maxrows == count)			return (0);		if (sp->t_maxrows > count) {			adj = A_DECREASE;			count = sp->t_maxrows - count;		} else {			adj = A_INCREASE;			count = count - sp->t_maxrows;		}	}	if (adj == A_DECREASE) {		if (count < 0)			count = -count;		s = sp;		if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)			goto toosmall;		if ((g = sp->q.cqe_prev) == (void *)&sp->gp->dq) {			if ((g = sp->q.cqe_next) == (void *)&sp->gp->dq)				goto toobig;			g->woff -= count;		} else			s->woff += count;	} else {		g = sp;		if ((s = sp->q.cqe_next) != (void *)&sp->gp->dq)			if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)				s = NULL;			else				s->woff += count;		else			s = NULL;		if (s == NULL) {			if ((s = sp->q.cqe_prev) == (void *)&sp->gp->dq) {toobig:				msgq(sp, M_BERR, "The screen cannot %s.",				    adj == A_DECREASE ? "shrink" : "grow");				return (1);			}			if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count) {toosmall:			msgq(sp, M_BERR,				    "The screen can only shrink to %d rows.",				    MINIMUM_SCREEN_ROWS);				return (1);			}			g->woff -= count;		}	}	/*	 * Update the screens; we could optimize the reformatting of the	 * screen, but this isn't likely to be a common enough operation	 * to make it worthwhile.	 */	g->rows += count;	g->t_rows += count;	if (g->t_minrows == g->t_maxrows)		g->t_minrows += count;	g->t_maxrows += count;	_TMAP(g) += count;	(void)status(g, g->ep, g->lno, 0);	F_SET(g, S_REFORMAT);	s->rows -= count;	s->t_rows -= count;	s->t_maxrows -= count;	if (s->t_minrows > s->t_maxrows)		s->t_minrows = s->t_maxrows;	_TMAP(s) -= count;	(void)status(s, s->ep, s->lno, 0);	F_SET(s, S_REFORMAT);	return (0);}

⌨️ 快捷键说明

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