示例#1
0
文件: newwin.c 项目: ryo/netbsd-src
/*
 * newpad --
 *	Allocate space for and set up defaults for a new pad.
 */
WINDOW *
newpad(int nlines, int ncols)
{
	if (nlines < 1 || ncols < 1)
		return NULL;
	return __newwin(_cursesi_screen, nlines, ncols, 0, 0, TRUE);
}
示例#2
0
文件: newwin.c 项目: ryo/netbsd-src
/*
 * dupwin --
 *      Create a copy of the given window.
 */
WINDOW *
dupwin(WINDOW *win)
{
	WINDOW *new_one;

	if ((new_one = __newwin(_cursesi_screen, win->maxy, win->maxx,
				win->begy, win->begx, FALSE)) == NULL)
		return NULL;

	overwrite(win, new_one);
	return new_one;
}
示例#3
0
文件: newwin.c 项目: ryo/netbsd-src
/*
 * newwin --
 *	Allocate space for and set up defaults for a new window.
 */
WINDOW *
newwin(int nlines, int ncols, int by, int bx)
{
	return __newwin(_cursesi_screen, nlines, ncols, by, bx, FALSE);
}
示例#4
0
/*
 * getwin --
 *	Read window data from file
 */
WINDOW *
getwin(FILE *fp)
{
	int major, minor;
	WINDOW *wtmp, *win;
	int y, x;
	__LDATA *sp;

#ifdef DEBUG
	__CTRACE(__CTRACE_FILEIO, "getwin\n");
#endif

	/* Check library version */
	if (fread(&major, sizeof(int), 1, fp) != 1)
		return NULL;
	if (fread(&minor, sizeof(int), 1, fp) != 1)
		return NULL;
	if(major != CURSES_LIB_MAJOR || minor != CURSES_LIB_MINOR)
		return NULL;

	/* Window parameters */
	wtmp = (WINDOW *)malloc(sizeof(WINDOW));
	if (wtmp == NULL)
		return NULL;
	if (fread(wtmp, sizeof(WINDOW), 1, fp) != 1)
		goto error0;
	win = __newwin(_cursesi_screen, wtmp->maxy, wtmp->maxx,
	    wtmp->begy, wtmp->begx, FALSE);
	if (win == NULL)
		goto error0;
	win->cury = wtmp->cury;
	win->curx = wtmp->curx;
	win->reqy = wtmp->reqy;
	win->reqx = wtmp->reqx;
	win->flags = wtmp->flags;
	win->delay = wtmp->delay;
	win->wattr = wtmp->wattr;
	win->bch = wtmp->bch;
	win->battr = wtmp->battr;
	win->scr_t = wtmp->scr_t;
	win->scr_b = wtmp->scr_b;
	free(wtmp);
	wtmp = NULL;
	__swflags(win);

#ifdef HAVE_WCHAR
	if (__getnsp(win->bnsp, fp) == ERR)
		goto error1;
#endif /* HAVE_WCHAR */

	/* Lines and line data */
	for (y = 0; y < win->maxy; y++) {
		for (sp = win->alines[y]->line, x = 0; x < win->maxx;
		    x++, sp++) {
			if (fread(&sp->ch, sizeof(wchar_t), 1, fp) != 1)
				goto error1;
			if (fread(&sp->attr, sizeof(attr_t), 1, fp) != 1)
				goto error1;
#ifdef HAVE_WCHAR
			if (sp->nsp != NULL) {
				if (__getnsp(win->bnsp, fp) == ERR)
					goto error1;
			}
#endif /* HAVE_WCHAR */
		}
		__touchline(win, y, 0, (int) win->maxx - 1);
	}
#ifdef DEBUG
	__CTRACE(__CTRACE_FILEIO, "getwin: win = 0x%p\n", win);
#endif
	return win;

error1:
	delwin(win);
error0:
	if (wtmp)
		free(wtmp);
	return NULL;
}