failed attempt to use slang curses; leave changes in in case someone wants to try...
[nvi.git] / ex / ex_screen.c
blobfd11b8b0d6aa053888b98d6971cc4135b2aba8d5
1 /*-
2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 static const char sccsid[] = "$Id: ex_screen.c,v 10.11 1996/06/29 12:27:15 bostic Exp $ (Berkeley) $Date: 1996/06/29 12:27:15 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
18 #include <sys/time.h>
20 #include <bitstring.h>
21 #include <limits.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "../common/common.h"
27 #include "../vi/vi.h"
30 * ex_bg -- :bg
31 * Hide the screen.
33 * PUBLIC: int ex_bg __P((SCR *, EXCMD *));
35 int
36 ex_bg(sp, cmdp)
37 SCR *sp;
38 EXCMD *cmdp;
40 return (vs_bg(sp));
44 * ex_fg -- :fg [file]
45 * Show the screen.
47 * PUBLIC: int ex_fg __P((SCR *, EXCMD *));
49 int
50 ex_fg(sp, cmdp)
51 SCR *sp;
52 EXCMD *cmdp;
54 SCR *nsp;
55 int newscreen;
57 newscreen = F_ISSET(cmdp, E_NEWSCREEN);
58 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen))
59 return (1);
61 /* Set up the switch. */
62 if (newscreen) {
63 sp->nextdisp = nsp;
64 F_SET(sp, SC_SSWITCH);
66 return (0);
70 * ex_resize -- :resize [+-]rows
71 * Change the screen size.
73 * PUBLIC: int ex_resize __P((SCR *, EXCMD *));
75 int
76 ex_resize(sp, cmdp)
77 SCR *sp;
78 EXCMD *cmdp;
80 adj_t adj;
82 switch (FL_ISSET(cmdp->iflags,
83 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) {
84 case E_C_COUNT:
85 adj = A_SET;
86 break;
87 case E_C_COUNT | E_C_COUNT_NEG:
88 adj = A_DECREASE;
89 break;
90 case E_C_COUNT | E_C_COUNT_POS:
91 adj = A_INCREASE;
92 break;
93 default:
94 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
95 return (1);
97 return (vs_resize(sp, cmdp->count, adj));
101 * ex_sdisplay --
102 * Display the list of screens.
104 * PUBLIC: int ex_sdisplay __P((SCR *));
107 ex_sdisplay(sp)
108 SCR *sp;
110 GS *gp;
111 SCR *tsp;
112 int cnt, col, len, sep;
114 gp = sp->gp;
115 if ((tsp = gp->hq.cqh_first) == (void *)&gp->hq) {
116 msgq(sp, M_INFO, "149|No background screens to display");
117 return (0);
120 col = len = sep = 0;
121 for (cnt = 1; tsp != (void *)&gp->hq && !INTERRUPTED(sp);
122 tsp = tsp->q.cqe_next) {
123 col += len = strlen(tsp->frp->name) + sep;
124 if (col >= sp->cols - 1) {
125 col = len;
126 sep = 0;
127 (void)ex_puts(sp, "\n");
128 } else if (cnt != 1) {
129 sep = 1;
130 (void)ex_puts(sp, " ");
132 (void)ex_puts(sp, tsp->frp->name);
133 ++cnt;
135 if (!INTERRUPTED(sp))
136 (void)ex_puts(sp, "\n");
137 return (0);