This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / usr.bin / vi / nex / ex_screen.c
CommitLineData
18ae9d6b
AS
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static char sccsid[] = "@(#)ex_screen.c 8.10 (Berkeley) 12/2/93";
36#endif /* not lint */
37
38#include <sys/types.h>
39
40#include <stdlib.h>
41#include <string.h>
42
43#include "vi.h"
44#include "excmd.h"
45
46/*
47 * ex_split -- :s[plit] [file ...]
48 * Split the screen, optionally setting the file list.
49 */
50int
51ex_split(sp, ep, cmdp)
52 SCR *sp;
53 EXF *ep;
54 EXCMDARG *cmdp;
55{
56 return (sp->s_split(sp, cmdp->argc ? cmdp->argv : NULL));
57}
58
59/*
60 * ex_bg -- :bg
61 * Hide the screen.
62 */
63int
64ex_bg(sp, ep, cmdp)
65 SCR *sp;
66 EXF *ep;
67 EXCMDARG *cmdp;
68{
69 return (sp->s_bg(sp));
70}
71
72/*
73 * ex_fg -- :fg [file]
74 * Show the screen.
75 */
76int
77ex_fg(sp, ep, cmdp)
78 SCR *sp;
79 EXF *ep;
80 EXCMDARG *cmdp;
81{
82 return (sp->s_fg(sp, cmdp->argc ? cmdp->argv[0]->bp : NULL));
83}
84
85/*
86 * ex_resize -- :resize [change]
87 * Change the screen size.
88 */
89int
90ex_resize(sp, ep, cmdp)
91 SCR *sp;
92 EXF *ep;
93 EXCMDARG *cmdp;
94{
95 if (!F_ISSET(cmdp, E_COUNT))
96 cmdp->count = 1;
97 return (sp->s_rabs(sp, cmdp->count));
98}
99
100/*
101 * ex_sdisplay --
102 * Display the list of screens.
103 */
104int
105ex_sdisplay(sp, ep)
106 SCR *sp;
107 EXF *ep;
108{
109 SCR *tsp;
110 int cnt, col, len, sep;
111
112 if ((tsp = sp->gp->hq.cqh_first) == (void *)&sp->gp->hq) {
113 (void)ex_printf(EXCOOKIE,
114 "No backgrounded screens to display.\n");
115 return (0);
116 }
117
118 col = len = sep = 0;
119 for (cnt = 1; tsp != (void *)&sp->gp->hq; tsp = tsp->q.cqe_next) {
120 col += len = strlen(FILENAME(tsp->frp)) + sep;
121 if (col >= sp->cols - 1) {
122 col = len;
123 sep = 0;
124 (void)ex_printf(EXCOOKIE, "\n");
125 } else if (cnt != 1) {
126 sep = 1;
127 (void)ex_printf(EXCOOKIE, " ");
128 }
129 (void)ex_printf(EXCOOKIE, "%s", FILENAME(tsp->frp));
130 ++cnt;
131 }
132 (void)ex_printf(EXCOOKIE, "\n");
133 return (0);
134}