2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1995-1998 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/* LINTLIBRARY */
2N/A
2N/A/*
2N/A * copywin.c
2N/A *
2N/A * XCurses Library
2N/A *
2N/A * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
2N/A *
2N/A */
2N/A
2N/A#ifdef M_RCSID
2N/A#ifndef lint
2N/Astatic char rcsID[] =
2N/A"$Header: /team/ps/sun_xcurses/archive/local_changes/xcurses/src/lib/"
2N/A"libxcurses/src/libc/xcurses/rcs/copywin.c 1.6 1998/06/01 17:29:15 "
2N/A"cbates Exp $";
2N/A#endif
2N/A#endif
2N/A
2N/A#include <private.h>
2N/A
2N/A#undef min
2N/A#define min(a, b) ((a) < (b) ? (a) : (b))
2N/A
2N/A/*
2N/A * Version of copywin used internally by Curses to compute
2N/A * the intersection of the two windows before calling copywin().
2N/A */
2N/Aint
2N/A__m_copywin(const WINDOW *s, WINDOW *t, int transparent)
2N/A{
2N/A int code, sminr, sminc, tminr, tminc, tmaxr, tmaxc;
2N/A
2N/A tmaxc = min(s->_begx + s->_maxx, t->_begx + t->_maxx) - 1 - t->_begx;
2N/A tmaxr = min(s->_begy + s->_maxy, t->_begy + t->_maxy) - 1 - t->_begy;
2N/A
2N/A if (s->_begy < t->_begy) {
2N/A sminr = t->_begy - s->_begy;
2N/A tminr = 0;
2N/A } else {
2N/A sminr = 0;
2N/A tminr = s->_begy - t->_begy;
2N/A }
2N/A if (s->_begx < t->_begx) {
2N/A sminc = t->_begx - s->_begx;
2N/A tminc = 0;
2N/A } else {
2N/A sminc = 0;
2N/A tminc = s->_begx- t->_begx;
2N/A }
2N/A code = copywin(s, t, sminr, sminc,
2N/A tminr, tminc, tmaxr, tmaxc, transparent);
2N/A
2N/A return (code);
2N/A}
2N/A
2N/A/*
2N/A * Overlay specified part of source window over destination window
2N/A * NOTE copying is destructive only if transparent is set to false.
2N/A */
2N/Aint
2N/Acopywin(const WINDOW *s, WINDOW *t,
2N/A int sminr, int sminc, int tminr, int tminc,
2N/A int tmaxr, int tmaxc, int transparent)
2N/A{
2N/A int tc;
2N/A cchar_t *st, *tt;
2N/A cchar_t bg = s->_bg;
2N/A
2N/A for (; tminr <= tmaxr; ++tminr, ++sminr) {
2N/A st = s->_line[sminr] + sminc;
2N/A tt = t->_line[tminr] + tminc;
2N/A
2N/A /* Copy source region to target. */
2N/A for (tc = tminc; tc <= tmaxc; ++tc, ++tt, ++st) {
2N/A if (transparent) {
2N/A if (__m_cc_compare(st, &bg, 1))
2N/A continue;
2N/A }
2N/A *tt = *st;
2N/A __m_touch_locs(t, tminr, tc, tc + 1);
2N/A }
2N/A#ifdef M_CURSES_SENSIBLE_WINDOWS
2N/A /*
2N/A * Case 4 -
2N/A * Expand incomplete glyph from source into target window.
2N/A */
2N/A if (0 < tminc && !t->_line[tminr][tminc]._f)
2N/A (void) __m_cc_expand(t, tminr, tminc, -1);
2N/A if (tmaxc + 1 < t->_maxx && !__m_cc_islast(t, tminr, tmaxc))
2N/A (void) __m_cc_expand(t, tminr, tmaxc, 1);
2N/A#endif /* M_CURSES_SENSIBLE_WINDOWS */
2N/A }
2N/A
2N/A return (OK);
2N/A}