Home | History | Annotate | Line # | Download | only in vi
      1 /*	$NetBSD: v_screen.c,v 1.5 2014/01/26 21:43:45 christos Exp $	*/
      2 /*-
      3  * Copyright (c) 1993, 1994
      4  *	The Regents of the University of California.  All rights reserved.
      5  * Copyright (c) 1992, 1993, 1994, 1995, 1996
      6  *	Keith Bostic.  All rights reserved.
      7  *
      8  * See the LICENSE file for redistribution information.
      9  */
     10 
     11 #include "config.h"
     12 
     13 #include <sys/cdefs.h>
     14 #if 0
     15 #ifndef lint
     16 static const char sccsid[] = "Id: v_screen.c,v 10.12 2001/06/25 15:19:34 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:34 ";
     17 #endif /* not lint */
     18 #else
     19 __RCSID("$NetBSD: v_screen.c,v 1.5 2014/01/26 21:43:45 christos Exp $");
     20 #endif
     21 
     22 #include <sys/types.h>
     23 #include <sys/queue.h>
     24 #include <sys/time.h>
     25 
     26 #include <bitstring.h>
     27 #include <limits.h>
     28 #include <stdio.h>
     29 
     30 #include "../common/common.h"
     31 #include "vi.h"
     32 
     33 /*
     34  * v_screen -- ^W
     35  *	Switch screens.
     36  *
     37  * PUBLIC: int v_screen __P((SCR *, VICMD *));
     38  */
     39 int
     40 v_screen(SCR *sp, VICMD *vp)
     41 {
     42 	/*
     43 	 * You can't leave a colon command-line edit window -- it's not that
     44 	 * it won't work, but it gets real weird, real fast when you execute
     45 	 * a colon command out of a window that was forked from a window that's
     46 	 * now backgrounded...  You get the idea.
     47 	 */
     48 	if (F_ISSET(sp, SC_COMEDIT)) {
     49 		msgq(sp, M_ERR,
     50 		    "308|Enter <CR> to execute a command, :q to exit");
     51 		return (1);
     52 	}
     53 
     54 	/*
     55 	 * Try for the next lower screen, or, go back to the first
     56 	 * screen on the stack.
     57 	 */
     58 	if (TAILQ_NEXT(sp, q) != NULL)
     59 		sp->nextdisp = TAILQ_NEXT(sp, q);
     60 	else if (TAILQ_FIRST(&sp->wp->scrq) == sp) {
     61 		msgq(sp, M_ERR, "187|No other screen to switch to");
     62 		return (1);
     63 	} else
     64 		sp->nextdisp = TAILQ_FIRST(&sp->wp->scrq);
     65 
     66 	F_SET(sp->nextdisp, SC_STATUS);
     67 	F_SET(sp, SC_SSWITCH | SC_STATUS);
     68 	return (0);
     69 }
     70