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/* Copyright (c) 1988 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A
2N/A/*
2N/A * Copyright (c) 1997, by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A/* A panels subsystem built on curses--Update the pile of panels */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
2N/A
2N/A/*LINTLIBRARY*/
2N/A
2N/A#include <sys/types.h>
2N/A#include <stdlib.h>
2N/A#include <curses.h>
2N/A#include "private.h"
2N/A
2N/A/*
2N/A * touch_top - Touch the line in all windows
2N/A * which is visible above a given line
2N/A */
2N/Astatic void
2N/Atouch_top(PANEL *panel, int line, _obscured_list *obs, int start_x, int end_x)
2N/A{
2N/A PANEL *pnl;
2N/A _obscured_list *next_obs;
2N/A
2N/A do {
2N/A pnl = obs -> panel_p;
2N/A if ((next_obs = obs->next) == panel -> obscured -> next)
2N/A next_obs = 0;
2N/A
2N/A if (line >= obs -> start && line <= obs -> end &&
2N/A pnl->wstartx <= end_x && pnl->wendx >= start_x) {
2N/A (void) touchline(pnl->win, line - pnl->wstarty, 1);
2N/A if (pnl->wstartx > start_x && pnl->wendx < end_x) {
2N/A if (next_obs)
2N/A touch_top(panel, line, next_obs,
2N/A pnl->wendx+1, end_x);
2N/A end_x = pnl -> wstartx - 1;
2N/A } else {
2N/A if (pnl->wstartx <= start_x)
2N/A start_x = pnl -> wendx + 1;
2N/A if (pnl->wendx >= end_x)
2N/A end_x = pnl -> wstartx - 1;
2N/A if (start_x > end_x)
2N/A return;
2N/A }
2N/A }
2N/A }
2N/A while ((obs = next_obs) != 0);
2N/A}
2N/A
2N/A/*
2N/A * std_touch_top
2N/A * Touch the line in all windows which is visible above a given line.
2N/A * This routine is almost identical to touch_top, except that the "panel"
2N/A * is stdscr in this case. The "obscured" list is the list of panels.
2N/A */
2N/Astatic void
2N/Astd_touch_top(int line, PANEL *obs_pnl, int start_x, int end_x)
2N/A{
2N/A PANEL *next_obs;
2N/A
2N/A do {
2N/A next_obs = obs_pnl -> below;
2N/A
2N/A if (line >= obs_pnl->wstarty && line <= obs_pnl->wendy &&
2N/A obs_pnl->wstartx <= end_x && obs_pnl->wendx >= start_x) {
2N/A (void) touchline(obs_pnl->win,
2N/A line - obs_pnl->wstarty, 1);
2N/A if (obs_pnl->wstartx > start_x &&
2N/A obs_pnl->wendx < end_x) {
2N/A if (next_obs)
2N/A std_touch_top(line, next_obs,
2N/A obs_pnl->wendx+1, end_x);
2N/A end_x = obs_pnl -> wstartx - 1;
2N/A } else {
2N/A if (obs_pnl->wstartx <= start_x)
2N/A start_x = obs_pnl -> wendx + 1;
2N/A if (obs_pnl->wendx >= end_x)
2N/A end_x = obs_pnl -> wstartx - 1;
2N/A if (start_x > end_x)
2N/A return;
2N/A }
2N/A }
2N/A }
2N/A while ((obs_pnl = next_obs) != 0);
2N/A}
2N/A
2N/A/* touchup - Touch lines in obscuring panals as necessary */
2N/Astatic void
2N/Atouchup(PANEL *panel)
2N/A{
2N/A int screen_y, i;
2N/A
2N/A /*
2N/A * for each line in the window which has been touched,
2N/A * touch lines in panals above it.
2N/A */
2N/A
2N/A screen_y = panel->wendy;
2N/A
2N/A for (i = panel->wendy - panel->wstarty; i >= 0; screen_y--, i--) {
2N/A if (is_linetouched(panel -> win, i) == TRUE)
2N/A touch_top(panel, screen_y, panel->obscured->next,
2N/A panel->wstartx, panel->wendx);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * std_touchup
2N/A * Touch lines in obscuring panals as necessary. This routine is
2N/A * almost exactly like touchup, except that the "panel" is stdscr,
2N/A * and the obscured list is the list of panels.
2N/A */
2N/Astatic void
2N/Astd_touchup(void)
2N/A{
2N/A int screen_y;
2N/A
2N/A /*
2N/A * for each line in stdscr which has been touched,
2N/A * touch lines in panals above it.
2N/A */
2N/A
2N/A for (screen_y = LINES - 1; screen_y >= 0; screen_y--) {
2N/A if (is_linetouched(stdscr, screen_y) == TRUE)
2N/A std_touch_top(screen_y, _Top_panel, 0, COLS - 1);
2N/A }
2N/A}
2N/A
2N/A/* update_panels - Refresh the pile of panels */
2N/Avoid
2N/Aupdate_panels(void)
2N/A{
2N/A PANEL *panel;
2N/A
2N/A /*
2N/A * if stdscr has been touched, touch the visible lines
2N/A * in each panel.
2N/A */
2N/A
2N/A if (is_wintouched(stdscr)) {
2N/A if (_Bottom_panel)
2N/A std_touchup();
2N/A
2N/A (void) wnoutrefresh(stdscr);
2N/A }
2N/A
2N/A /*
2N/A * Refresh panals starting at the bottom of the pile.
2N/A * If a line in a window has been touched, touch all
2N/A * corresponding lines in the obscuring windows.
2N/A */
2N/A
2N/A for (panel = _Bottom_panel; panel; panel = panel -> above) {
2N/A if (is_wintouched(panel -> win)) {
2N/A if (panel -> obscured)
2N/A touchup(panel);
2N/A (void) wnoutrefresh(panel -> win);
2N/A }
2N/A }
2N/A}