tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / nvi / dist / ex / ex_screen.c
blob73491f9bf8066209619c19a35f01a6f27ab508ff
1 /* $NetBSD: ex_screen.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
2 /*-
3 * Copyright (c) 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
9 */
11 #include "config.h"
13 #ifndef lint
14 static const char sccsid[] = "Id: ex_screen.c,v 10.12 2001/06/25 15:19:19 skimo Exp (Berkeley) Date: 2001/06/25 15:19:19 ";
15 #endif /* not lint */
17 #include <sys/types.h>
18 #include <sys/queue.h>
19 #include <sys/time.h>
21 #include <bitstring.h>
22 #include <limits.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
27 #include "../common/common.h"
28 #include "../vi/vi.h"
31 * ex_bg -- :bg
32 * Hide the screen.
34 * PUBLIC: int ex_bg __P((SCR *, EXCMD *));
36 int
37 ex_bg(SCR *sp, EXCMD *cmdp)
39 return (vs_bg(sp));
43 * ex_fg -- :fg [file]
44 * Show the screen.
46 * PUBLIC: int ex_fg __P((SCR *, EXCMD *));
48 int
49 ex_fg(SCR *sp, EXCMD *cmdp)
51 SCR *nsp;
52 int newscreen;
54 newscreen = F_ISSET(cmdp, E_NEWSCREEN);
55 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen))
56 return (1);
58 /* Set up the switch. */
59 if (newscreen) {
60 sp->nextdisp = nsp;
61 F_SET(sp, SC_SSWITCH);
63 return (0);
67 * ex_resize -- :resize [+-]rows
68 * Change the screen size.
70 * PUBLIC: int ex_resize __P((SCR *, EXCMD *));
72 int
73 ex_resize(SCR *sp, EXCMD *cmdp)
75 adj_t adj;
77 switch (FL_ISSET(cmdp->iflags,
78 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) {
79 case E_C_COUNT:
80 adj = A_SET;
81 break;
82 case E_C_COUNT | E_C_COUNT_NEG:
83 adj = A_DECREASE;
84 break;
85 case E_C_COUNT | E_C_COUNT_POS:
86 adj = A_INCREASE;
87 break;
88 default:
89 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
90 return (1);
92 return (vs_resize(sp, cmdp->count, adj));
96 * ex_sdisplay --
97 * Display the list of screens.
99 * PUBLIC: int ex_sdisplay __P((SCR *));
102 ex_sdisplay(SCR *sp)
104 GS *gp;
105 SCR *tsp;
106 int cnt, sep;
107 size_t col, len;
109 gp = sp->gp;
110 if ((tsp = TAILQ_FIRST(&gp->hq)) == NULL) {
111 msgq(sp, M_INFO, "149|No background screens to display");
112 return (0);
115 col = len = sep = 0;
116 for (cnt = 1; tsp != NULL && !INTERRUPTED(sp);
117 tsp = TAILQ_NEXT(tsp, q)) {
118 col += len = strlen(tsp->frp->name) + sep;
119 if (col >= sp->cols - 1) {
120 col = len;
121 sep = 0;
122 (void)ex_puts(sp, "\n");
123 } else if (cnt != 1) {
124 sep = 1;
125 (void)ex_puts(sp, " ");
127 (void)ex_puts(sp, tsp->frp->name);
128 ++cnt;
130 if (!INTERRUPTED(sp))
131 (void)ex_puts(sp, "\n");
132 return (0);