nrelease: Clean up a bit the 'clean' target
[dragonfly.git] / contrib / nvi2 / ex / ex_screen.c
blob12bfdc3ef161f67323dd6fa1f357a302095088f5
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 #include <sys/types.h>
13 #include <sys/queue.h>
14 #include <sys/time.h>
16 #include <bitstring.h>
17 #include <limits.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
22 #include "../common/common.h"
23 #include "../vi/vi.h"
26 * ex_bg -- :bg
27 * Hide the screen.
29 * PUBLIC: int ex_bg(SCR *, EXCMD *);
31 int
32 ex_bg(SCR *sp, EXCMD *cmdp)
34 return (vs_bg(sp));
38 * ex_fg -- :fg [file]
39 * Show the screen.
41 * PUBLIC: int ex_fg(SCR *, EXCMD *);
43 int
44 ex_fg(SCR *sp, EXCMD *cmdp)
46 SCR *nsp;
47 int newscreen;
49 newscreen = F_ISSET(cmdp, E_NEWSCREEN);
50 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen))
51 return (1);
53 /* Set up the switch. */
54 if (newscreen) {
55 sp->nextdisp = nsp;
56 F_SET(sp, SC_SSWITCH);
58 return (0);
62 * ex_resize -- :resize [+-]rows
63 * Change the screen size.
65 * PUBLIC: int ex_resize(SCR *, EXCMD *);
67 int
68 ex_resize(SCR *sp, EXCMD *cmdp)
70 adj_t adj;
72 switch (FL_ISSET(cmdp->iflags,
73 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) {
74 case E_C_COUNT:
75 adj = A_SET;
76 break;
77 case E_C_COUNT | E_C_COUNT_NEG:
78 adj = A_DECREASE;
79 break;
80 case E_C_COUNT | E_C_COUNT_POS:
81 adj = A_INCREASE;
82 break;
83 default:
84 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
85 return (1);
87 return (vs_resize(sp, cmdp->count, adj));
91 * ex_sdisplay --
92 * Display the list of screens.
94 * PUBLIC: int ex_sdisplay(SCR *);
96 int
97 ex_sdisplay(SCR *sp)
99 GS *gp;
100 SCR *tsp;
101 int cnt, col, len, sep;
103 gp = sp->gp;
104 if ((tsp = TAILQ_FIRST(gp->hq)) == NULL) {
105 msgq(sp, M_INFO, "149|No background screens to display");
106 return (0);
109 col = len = sep = 0;
110 for (cnt = 1; tsp != NULL && !INTERRUPTED(sp);
111 tsp = TAILQ_NEXT(tsp, q)) {
112 col += len = strlen(tsp->frp->name) + sep;
113 if (col >= sp->cols - 1) {
114 col = len;
115 sep = 0;
116 (void)ex_puts(sp, "\n");
117 } else if (cnt != 1) {
118 sep = 1;
119 (void)ex_puts(sp, " ");
121 (void)ex_puts(sp, tsp->frp->name);
122 ++cnt;
124 if (!INTERRUPTED(sp))
125 (void)ex_puts(sp, "\n");
126 return (0);