Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / ex / ex_screen.c
blob6486cb31b8000d5fff31c9bdfb9a0cdf1a1d4d39
1 /* $NetBSD: ex_screen.c,v 1.1.1.2 2008/05/18 14:31:17 aymeric Exp $ */
3 /*-
4 * Copyright (c) 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #ifndef lint
15 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";
16 #endif /* not lint */
18 #include <sys/types.h>
19 #include <sys/queue.h>
20 #include <sys/time.h>
22 #include <bitstring.h>
23 #include <limits.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
28 #include "../common/common.h"
29 #include "../vi/vi.h"
32 * ex_bg -- :bg
33 * Hide the screen.
35 * PUBLIC: int ex_bg __P((SCR *, EXCMD *));
37 int
38 ex_bg(SCR *sp, 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(SCR *sp, EXCMD *cmdp)
52 SCR *nsp;
53 int newscreen;
55 newscreen = F_ISSET(cmdp, E_NEWSCREEN);
56 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen))
57 return (1);
59 /* Set up the switch. */
60 if (newscreen) {
61 sp->nextdisp = nsp;
62 F_SET(sp, SC_SSWITCH);
64 return (0);
68 * ex_resize -- :resize [+-]rows
69 * Change the screen size.
71 * PUBLIC: int ex_resize __P((SCR *, EXCMD *));
73 int
74 ex_resize(SCR *sp, EXCMD *cmdp)
76 adj_t adj;
78 switch (FL_ISSET(cmdp->iflags,
79 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) {
80 case E_C_COUNT:
81 adj = A_SET;
82 break;
83 case E_C_COUNT | E_C_COUNT_NEG:
84 adj = A_DECREASE;
85 break;
86 case E_C_COUNT | E_C_COUNT_POS:
87 adj = A_INCREASE;
88 break;
89 default:
90 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
91 return (1);
93 return (vs_resize(sp, cmdp->count, adj));
97 * ex_sdisplay --
98 * Display the list of screens.
100 * PUBLIC: int ex_sdisplay __P((SCR *));
103 ex_sdisplay(SCR *sp)
105 GS *gp;
106 SCR *tsp;
107 int cnt, sep;
108 size_t col, len;
110 gp = sp->gp;
111 if ((tsp = gp->hq.cqh_first) == (void *)&gp->hq) {
112 msgq(sp, M_INFO, "149|No background screens to display");
113 return (0);
116 col = len = sep = 0;
117 for (cnt = 1; tsp != (void *)&gp->hq && !INTERRUPTED(sp);
118 tsp = tsp->q.cqe_next) {
119 col += len = strlen(tsp->frp->name) + sep;
120 if (col >= sp->cols - 1) {
121 col = len;
122 sep = 0;
123 (void)ex_puts(sp, "\n");
124 } else if (cnt != 1) {
125 sep = 1;
126 (void)ex_puts(sp, " ");
128 (void)ex_puts(sp, tsp->frp->name);
129 ++cnt;
131 if (!INTERRUPTED(sp))
132 (void)ex_puts(sp, "\n");
133 return (0);