1 |
|
|
/* $OpenBSD: v_screen.c,v 1.9 2016/01/06 22:28:52 millert Exp $ */ |
2 |
|
|
|
3 |
|
|
/*- |
4 |
|
|
* Copyright (c) 1993, 1994 |
5 |
|
|
* The Regents of the University of California. All rights reserved. |
6 |
|
|
* Copyright (c) 1992, 1993, 1994, 1995, 1996 |
7 |
|
|
* Keith Bostic. All rights reserved. |
8 |
|
|
* |
9 |
|
|
* See the LICENSE file for redistribution information. |
10 |
|
|
*/ |
11 |
|
|
|
12 |
|
|
#include "config.h" |
13 |
|
|
|
14 |
|
|
#include <sys/types.h> |
15 |
|
|
#include <sys/queue.h> |
16 |
|
|
#include <sys/time.h> |
17 |
|
|
|
18 |
|
|
#include <bitstring.h> |
19 |
|
|
#include <limits.h> |
20 |
|
|
#include <stdio.h> |
21 |
|
|
|
22 |
|
|
#include "../common/common.h" |
23 |
|
|
#include "vi.h" |
24 |
|
|
|
25 |
|
|
/* |
26 |
|
|
* v_screen -- ^W |
27 |
|
|
* Switch screens. |
28 |
|
|
* |
29 |
|
|
* PUBLIC: int v_screen(SCR *, VICMD *); |
30 |
|
|
*/ |
31 |
|
|
int |
32 |
|
|
v_screen(SCR *sp, VICMD *vp) |
33 |
|
|
{ |
34 |
|
|
/* |
35 |
|
|
* You can't leave a colon command-line edit window -- it's not that |
36 |
|
|
* it won't work, but it gets real weird, real fast when you execute |
37 |
|
|
* a colon command out of a window that was forked from a window that's |
38 |
|
|
* now backgrounded... You get the idea. |
39 |
|
|
*/ |
40 |
|
|
if (F_ISSET(sp, SC_COMEDIT)) { |
41 |
|
|
msgq(sp, M_ERR, |
42 |
|
|
"Enter <CR> to execute a command, :q to exit"); |
43 |
|
|
return (1); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
/* |
47 |
|
|
* Try for the next lower screen, or, go back to the first |
48 |
|
|
* screen on the stack. |
49 |
|
|
*/ |
50 |
|
|
if (TAILQ_NEXT(sp, q)) |
51 |
|
|
sp->nextdisp = TAILQ_NEXT(sp, q); |
52 |
|
|
else if (TAILQ_FIRST(&sp->gp->dq) == sp) { |
53 |
|
|
msgq(sp, M_ERR, "No other screen to switch to"); |
54 |
|
|
return (1); |
55 |
|
|
} else |
56 |
|
|
sp->nextdisp = TAILQ_FIRST(&sp->gp->dq); |
57 |
|
|
|
58 |
|
|
F_SET(sp->nextdisp, SC_STATUS); |
59 |
|
|
F_SET(sp, SC_SSWITCH | SC_STATUS); |
60 |
|
|
return (0); |
61 |
|
|
} |