static char *sccsid
= "@(#)win.c 3.4 84/03/29";
* Higher level routines for dealing with windows.
* There are two types of windows: user window, and information window.
* User windows are the ones with a pty and shell. Information windows
* are for displaying error messages, and other information.
* The windows are stacked in overlapping order and divided into
* three groups: foreground, normal, and background. Information
* windows are always foreground. User windows can be anywhere.
* Addwin() adds a window to one of the three groups.
* Deletewin() deletes a window. Front() moves a window to the front
* of its group. Wwadd() and wwdelete() should never be called
openwin(id
, row
, col
, nrow
, ncol
, nline
, label
)
if (id
< 0 && (id
= findid()) < 0)
if (row
+ nrow
<= 0 || row
> wwnrow
- 1
|| col
+ ncol
<= 0 || col
> wwncol
- 1) {
error("Illegal window position.");
if ((w
= wwopen(WWO_PTY
, nrow
, ncol
, row
, col
, nline
)) == 0) {
if (label
!= 0 && setlabel(w
, label
) < 0)
error("No memory for label.");
if (wwspawn(w
, shell
, shellname
, (char *)0) < 0) {
error("%s: %s.", shell
, wwerror());
for (i
= 0; i
< NWINDOW
&& window
[i
] != 0; i
++)
error("Too many windows.");
if (w
->ww_id
>= 0 && w
->ww_id
< NWINDOW
)
* Open an information (display) window.
if ((w
= wwopen(0, nrow
, wwncol
, 2, 0, 0)) == 0)
(void) setlabel(w
, label
);
* Close an information window.
* Set the current window.
* Move the window to the top of its group.
* Don't do it, if already fully visible.
* Wwvisible() doesn't work for tinted windows.
* But anything to make it faster.
* Always reframe() if doreframe is true.
if (w
->ww_back
!= framewin
&& !wwvisible(w
)) {
if (w
!= bgwin
&& !wwvisible(w
)) {
if (w
->ww_back
!= fgwin
&& !wwvisible(w
)) {
* Add a window at one of four places.
case 0: /* top of foreground windows */
case 1: /* top of normal windows */
case 2: /* bottom of normal windows */
wwadd(w
, bgwin
->ww_back
);
case 3: /* top of background windows */
wwadd(w
, bgwin
->ww_back
);
for (w
= wwhead
.ww_back
; w
!= &wwhead
; w
= w
->ww_back
)
int mode
= w
== selwin
? WWM_REV
: 0;
wwlabel(w
, framewin
, 1, buf
, mode
);
col
= (w
->ww_w
.nc
- strlen(w
->ww_label
)) / 2;
wwlabel(w
, framewin
, col
, w
->ww_label
, mode
);
(void) waitnl1(w
, "[Type any key to continue]");
if (!always
&& w
->ww_cur
.r
< w
->ww_w
.b
- 2)
c
= waitnl1(w
, "[Type escape to abort, any other key to continue]");
return c
== CTRL([) ? 2 : 1;
wwprintf(w
, "\033Y%c%c\033p%s\033q ",
w
->ww_w
.nr
- 1 + ' ', ' ', prompt
); /* print on last line */