split is "sp", not "s"
[nvi.git] / ex / ex_screen.c
blob766a8372d19c9ed5410dab81d13a6176635b6d34
1 /*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: ex_screen.c,v 8.10 1993/12/02 15:14:14 bostic Exp $ (Berkeley) $Date: 1993/12/02 15:14:14 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include <stdlib.h>
15 #include <string.h>
17 #include "vi.h"
18 #include "excmd.h"
21 * ex_split -- :s[plit] [file ...]
22 * Split the screen, optionally setting the file list.
24 int
25 ex_split(sp, ep, cmdp)
26 SCR *sp;
27 EXF *ep;
28 EXCMDARG *cmdp;
30 return (sp->s_split(sp, cmdp->argc ? cmdp->argv : NULL));
34 * ex_bg -- :bg
35 * Hide the screen.
37 int
38 ex_bg(sp, ep, cmdp)
39 SCR *sp;
40 EXF *ep;
41 EXCMDARG *cmdp;
43 return (sp->s_bg(sp));
47 * ex_fg -- :fg [file]
48 * Show the screen.
50 int
51 ex_fg(sp, ep, cmdp)
52 SCR *sp;
53 EXF *ep;
54 EXCMDARG *cmdp;
56 return (sp->s_fg(sp, cmdp->argc ? cmdp->argv[0]->bp : NULL));
60 * ex_resize -- :resize [change]
61 * Change the screen size.
63 int
64 ex_resize(sp, ep, cmdp)
65 SCR *sp;
66 EXF *ep;
67 EXCMDARG *cmdp;
69 if (!F_ISSET(cmdp, E_COUNT))
70 cmdp->count = 1;
71 return (sp->s_rabs(sp, cmdp->count));
75 * ex_sdisplay --
76 * Display the list of screens.
78 int
79 ex_sdisplay(sp, ep)
80 SCR *sp;
81 EXF *ep;
83 SCR *tsp;
84 int cnt, col, len, sep;
86 if ((tsp = sp->gp->hq.cqh_first) == (void *)&sp->gp->hq) {
87 (void)ex_printf(EXCOOKIE,
88 "No backgrounded screens to display.\n");
89 return (0);
92 col = len = sep = 0;
93 for (cnt = 1; tsp != (void *)&sp->gp->hq; tsp = tsp->q.cqe_next) {
94 col += len = strlen(FILENAME(tsp->frp)) + sep;
95 if (col >= sp->cols - 1) {
96 col = len;
97 sep = 0;
98 (void)ex_printf(EXCOOKIE, "\n");
99 } else if (cnt != 1) {
100 sep = 1;
101 (void)ex_printf(EXCOOKIE, " ");
103 (void)ex_printf(EXCOOKIE, "%s", FILENAME(tsp->frp));
104 ++cnt;
106 (void)ex_printf(EXCOOKIE, "\n");
107 return (0);