119304Speter/*- 219304Speter * Copyright (c) 1993, 1994 319304Speter * The Regents of the University of California. All rights reserved. 419304Speter * Copyright (c) 1992, 1993, 1994, 1995, 1996 519304Speter * Keith Bostic. All rights reserved. 619304Speter * 719304Speter * See the LICENSE file for redistribution information. 819304Speter */ 919304Speter 1019304Speter#include "config.h" 1119304Speter 1219304Speter#ifndef lint 13254225Speterstatic const char sccsid[] = "$Id: v_screen.c,v 10.12 2001/06/25 15:19:34 skimo Exp $"; 1419304Speter#endif /* not lint */ 1519304Speter 1619304Speter#include <sys/types.h> 1719304Speter#include <sys/queue.h> 1819304Speter#include <sys/time.h> 1919304Speter 2019304Speter#include <bitstring.h> 2119304Speter#include <limits.h> 2219304Speter#include <stdio.h> 2319304Speter 2419304Speter#include "../common/common.h" 2519304Speter#include "vi.h" 2619304Speter 2719304Speter/* 2819304Speter * v_screen -- ^W 2919304Speter * Switch screens. 3019304Speter * 31281373Sbapt * PUBLIC: int v_screen(SCR *, VICMD *); 3219304Speter */ 3319304Speterint 34254225Speterv_screen(SCR *sp, VICMD *vp) 3519304Speter{ 3619304Speter /* 3719304Speter * You can't leave a colon command-line edit window -- it's not that 3819304Speter * it won't work, but it gets real weird, real fast when you execute 3919304Speter * a colon command out of a window that was forked from a window that's 4019304Speter * now backgrounded... You get the idea. 4119304Speter */ 4219304Speter if (F_ISSET(sp, SC_COMEDIT)) { 4319304Speter msgq(sp, M_ERR, 4419304Speter "308|Enter <CR> to execute a command, :q to exit"); 4519304Speter return (1); 4619304Speter } 4719304Speter 4819304Speter /* 4919304Speter * Try for the next lower screen, or, go back to the first 5019304Speter * screen on the stack. 5119304Speter */ 52254225Speter if (TAILQ_NEXT(sp, q) != NULL) 53254225Speter sp->nextdisp = TAILQ_NEXT(sp, q); 54254225Speter else if (TAILQ_FIRST(sp->gp->dq) == sp) { 5519304Speter msgq(sp, M_ERR, "187|No other screen to switch to"); 5619304Speter return (1); 5719304Speter } else 58254225Speter sp->nextdisp = TAILQ_FIRST(sp->gp->dq); 5919304Speter 6019304Speter F_SET(sp->nextdisp, SC_STATUS); 6119304Speter F_SET(sp, SC_SSWITCH | SC_STATUS); 6219304Speter return (0); 6319304Speter} 64