src/ui-term.c
errr Term_resize(int w, int h)
{
	int i;

	int wid, hgt;

	int *hold_x1;
	int *hold_x2;

	term_win *hold_old;
	term_win *hold_scr;
	term_win *hold_mem;
	term_win *hold_tmp;

	ui_event evt = EVENT_EMPTY;
	evt.type = EVT_RESIZE;

	/* Resizing is forbidden */
	if (Term->fixed_shape) return (-1);

	/* Ignore illegal changes */
	if ((w < 1) || (h < 1)) return (-1);

	/* Ignore non-changes */
	if ((Term->wid == w) && (Term->hgt == h)) return (1);

	/* Minimum dimensions */
	wid = MIN(Term->wid, w);
	hgt = MIN(Term->hgt, h);

	/* Save scanners */
	hold_x1 = Term->x1;
	hold_x2 = Term->x2;

	/* Save old window */
	hold_old = Term->old;

	/* Save old window */
	hold_scr = Term->scr;

	/* Save old window */
	hold_mem = Term->mem;

	/* Save old window */
	hold_tmp = Term->tmp;

	/* Create new scanners */
	Term->x1 = mem_zalloc(h * sizeof(int));
	Term->x2 = mem_zalloc(h * sizeof(int));

	/* Create new window */
	Term->old = mem_zalloc(sizeof(term_win));

	/* Initialize new window */
	term_win_init(Term->old, w, h);

	/* Save the contents */
	term_win_copy(Term->old, hold_old, wid, hgt);

	/* Create new window */
	Term->scr = mem_zalloc(sizeof(term_win));

	/* Initialize new window */
	term_win_init(Term->scr, w, h);

	/* Save the contents */
	term_win_copy(Term->scr, hold_scr, wid, hgt);

	/* If needed */
	if (hold_mem) {
		/* Create new window */
		Term->mem = mem_zalloc(sizeof(term_win));

		/* Initialize new window */
		term_win_init(Term->mem, w, h);

		/* Save the contents */
		term_win_copy(Term->mem, hold_mem, wid, hgt);
	}

	/* If needed */
	if (hold_tmp) {
		/* Create new window */
		Term->tmp = mem_zalloc(sizeof(term_win));

		/* Initialize new window */
		term_win_init(Term->tmp, w, h);

		/* Save the contents */
		term_win_copy(Term->tmp, hold_tmp, wid, hgt);
	}

	/* Free some arrays */
	mem_free(hold_x1);
	mem_free(hold_x2);

	/* Nuke */
	term_win_nuke(hold_old);

	/* Kill */
	mem_free(hold_old);

	/* Illegal cursor */
	if (Term->old->cx >= w) Term->old->cu = 1;
	if (Term->old->cy >= h) Term->old->cu = 1;

	/* Nuke */
	term_win_nuke(hold_scr);

	/* Kill */
	mem_free(hold_scr);

	/* Illegal cursor */
	if (Term->scr->cx >= w) Term->scr->cu = 1;
	if (Term->scr->cy >= h) Term->scr->cu = 1;

	/* If needed */
	if (hold_mem) {
		/* Nuke */
		term_win_nuke(hold_mem);

		/* Kill */
		mem_free(hold_mem);

		/* Illegal cursor */
		if (Term->mem->cx >= w) Term->mem->cu = 1;
		if (Term->mem->cy >= h) Term->mem->cu = 1;
	}

	/* If needed */
	if (hold_tmp) {
		/* Nuke */
		term_win_nuke(hold_tmp);

		/* Kill */
		mem_free(hold_tmp);

		/* Illegal cursor */
		if (Term->tmp->cx >= w) Term->tmp->cu = 1;
		if (Term->tmp->cy >= h) Term->tmp->cu = 1;
	}

	/* Save new size */
	Term->wid = w;
	Term->hgt = h;

	/* Force "total erase" */
	Term->total_erase = TRUE;

	/* Assume change */
	for (i = 0; i < h; i++) {
		/* Assume change */
		Term->x1[i] = 0;
		Term->x2[i] = w - 1;
	}

	/* Assume change */
	Term->y1 = 0;
	Term->y2 = h - 1;

	/* Push a resize event onto the stack */
	Term_event_push(&evt);

	/* Success */
	return (0);
}
/**
 * React to a new physical window size.
 */
React to a new physical window size.
React to a new physical window size .
errr Term_resize(int w, int h)
{
	int i;
	int wid, hgt;
	int *hold_x1;
	int *hold_x2;
	term_win *hold_old;
	term_win *hold_scr;
	term_win *hold_mem;
	term_win *hold_tmp;
	ui_event evt = EVENT_EMPTY;
	evt.type = EVT_RESIZE;
	if (Term->fixed_shape) return (-1);
	if ((w < 1) || (h < 1)) return (-1);
	if ((Term->wid == w) && (Term->hgt == h)) return (1);
	wid = MIN(Term->wid, w);
	hgt = MIN(Term->hgt, h);
	hold_x1 = Term->x1;
	hold_x2 = Term->x2;
	hold_old = Term->old;
	hold_scr = Term->scr;
	hold_mem = Term->mem;
	hold_tmp = Term->tmp;
	Term->x1 = mem_zalloc(h * sizeof(int));
	Term->x2 = mem_zalloc(h * sizeof(int));
	Term->old = mem_zalloc(sizeof(term_win));
	term_win_init(Term->old, w, h);
	term_win_copy(Term->old, hold_old, wid, hgt);
	Term->scr = mem_zalloc(sizeof(term_win));
	term_win_init(Term->scr, w, h);
	term_win_copy(Term->scr, hold_scr, wid, hgt);
	if (hold_mem) {
		Term->mem = mem_zalloc(sizeof(term_win));
		term_win_init(Term->mem, w, h);
		term_win_copy(Term->mem, hold_mem, wid, hgt);
	}
	if (hold_tmp) {
		Term->tmp = mem_zalloc(sizeof(term_win));
		term_win_init(Term->tmp, w, h);
		term_win_copy(Term->tmp, hold_tmp, wid, hgt);
	}
	mem_free(hold_x1);
	mem_free(hold_x2);
	term_win_nuke(hold_old);
	mem_free(hold_old);
	if (Term->old->cx >= w) Term->old->cu = 1;
	if (Term->old->cy >= h) Term->old->cu = 1;
	term_win_nuke(hold_scr);
	mem_free(hold_scr);
	if (Term->scr->cx >= w) Term->scr->cu = 1;
	if (Term->scr->cy >= h) Term->scr->cu = 1;
	if (hold_mem) {
		term_win_nuke(hold_mem);
		mem_free(hold_mem);
		if (Term->mem->cx >= w) Term->mem->cu = 1;
		if (Term->mem->cy >= h) Term->mem->cu = 1;
	}
	if (hold_tmp) {
		term_win_nuke(hold_tmp);
		mem_free(hold_tmp);
		if (Term->tmp->cx >= w) Term->tmp->cu = 1;
		if (Term->tmp->cy >= h) Term->tmp->cu = 1;
	}
	Term->wid = w;
	Term->hgt = h;
	Term->total_erase = TRUE;
	for (i = 0; i < h; i++) {
		Term->x1[i] = 0;
		Term->x2[i] = w - 1;
	}
	Term->y1 = 0;
	Term->y2 = h - 1;
	Term_event_push(&evt);
	return (0);
}
errr Term_resize ( int w , int h ) { int i ; int wid , hgt ; int * hold_x1 ; int * hold_x2 ; term_win * hold_old ; term_win * hold_scr ; term_win * hold_mem ; term_win * hold_tmp ; ui_event evt = EVENT_EMPTY ; evt . type = EVT_RESIZE ; if ( Term -> fixed_shape ) return ( -1 ) ; if ( ( w < 1 ) || ( h < 1 ) ) return ( -1 ) ; if ( ( Term -> wid == w ) && ( Term -> hgt == h ) ) return ( 1 ) ; wid = MIN ( Term -> wid , w ) ; hgt = MIN ( Term -> hgt , h ) ; hold_x1 = Term -> x1 ; hold_x2 = Term -> x2 ; hold_old = Term -> old ; hold_scr = Term -> scr ; hold_mem = Term -> mem ; hold_tmp = Term -> tmp ; Term -> x1 = mem_zalloc ( h * sizeof ( int ) ) ; Term -> x2 = mem_zalloc ( h * sizeof ( int ) ) ; Term -> old = mem_zalloc ( sizeof ( term_win ) ) ; term_win_init ( Term -> old , w , h ) ; term_win_copy ( Term -> old , hold_old , wid , hgt ) ; Term -> scr = mem_zalloc ( sizeof ( term_win ) ) ; term_win_init ( Term -> scr , w , h ) ; term_win_copy ( Term -> scr , hold_scr , wid , hgt ) ; if ( hold_mem ) { Term -> mem = mem_zalloc ( sizeof ( term_win ) ) ; term_win_init ( Term -> mem , w , h ) ; term_win_copy ( Term -> mem , hold_mem , wid , hgt ) ; } if ( hold_tmp ) { Term -> tmp = mem_zalloc ( sizeof ( term_win ) ) ; term_win_init ( Term -> tmp , w , h ) ; term_win_copy ( Term -> tmp , hold_tmp , wid , hgt ) ; } mem_free ( hold_x1 ) ; mem_free ( hold_x2 ) ; term_win_nuke ( hold_old ) ; mem_free ( hold_old ) ; if ( Term -> old -> cx >= w ) Term -> old -> cu = 1 ; if ( Term -> old -> cy >= h ) Term -> old -> cu = 1 ; term_win_nuke ( hold_scr ) ; mem_free ( hold_scr ) ; if ( Term -> scr -> cx >= w ) Term -> scr -> cu = 1 ; if ( Term -> scr -> cy >= h ) Term -> scr -> cu = 1 ; if ( hold_mem ) { term_win_nuke ( hold_mem ) ; mem_free ( hold_mem ) ; if ( Term -> mem -> cx >= w ) Term -> mem -> cu = 1 ; if ( Term -> mem -> cy >= h ) Term -> mem -> cu = 1 ; } if ( hold_tmp ) { term_win_nuke ( hold_tmp ) ; mem_free ( hold_tmp ) ; if ( Term -> tmp -> cx >= w ) Term -> tmp -> cu = 1 ; if ( Term -> tmp -> cy >= h ) Term -> tmp -> cu = 1 ; } Term -> wid = w ; Term -> hgt = h ; Term -> total_erase = TRUE ; for ( i = 0 ; i < h ; i ++ ) { Term -> x1 [ i ] = 0 ; Term -> x2 [ i ] = w - 1 ; } Term -> y1 = 0 ; Term -> y2 = h - 1 ; Term_event_push ( & evt ) ; return ( 0 ) ; }
React to a new physical window size.
React to a new physical window size .
/* Resizing is forbidden */ /* Ignore illegal changes */ /* Ignore non-changes */ /* Minimum dimensions */ /* Save scanners */ /* Save old window */ /* Save old window */ /* Save old window */ /* Save old window */ /* Create new scanners */ /* Create new window */ /* Initialize new window */ /* Save the contents */ /* Create new window */ /* Initialize new window */ /* Save the contents */ /* If needed */ /* Create new window */ /* Initialize new window */ /* Save the contents */ /* If needed */ /* Create new window */ /* Initialize new window */ /* Save the contents */ /* Free some arrays */ /* Nuke */ /* Kill */ /* Illegal cursor */ /* Nuke */ /* Kill */ /* Illegal cursor */ /* If needed */ /* Nuke */ /* Kill */ /* Illegal cursor */ /* If needed */ /* Nuke */ /* Kill */ /* Illegal cursor */ /* Save new size */ /* Force "total erase" */ /* Assume change */ /* Assume change */ /* Assume change */ /* Push a resize event onto the stack */ /* Success */