ex: convert line input buffer from file encoding to internal encoding
[nvi.git] / ex / ex_screen.c
blob6374a781b15002beced0cc66da4245b65c860b15
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 #ifndef lint
13 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 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
18 #include <sys/time.h>
20 #include <bitstring.h>
21 #include <limits.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
26 #include "../common/common.h"
27 #include "../vi/vi.h"
30 * ex_bg -- :bg
31 * Hide the screen.
33 * PUBLIC: int ex_bg __P((SCR *, EXCMD *));
35 int
36 ex_bg(SCR *sp, EXCMD *cmdp)
38 return (vs_bg(sp));
42 * ex_fg -- :fg [file]
43 * Show the screen.
45 * PUBLIC: int ex_fg __P((SCR *, EXCMD *));
47 int
48 ex_fg(SCR *sp, EXCMD *cmdp)
50 SCR *nsp;
51 int newscreen;
53 newscreen = F_ISSET(cmdp, E_NEWSCREEN);
54 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL, newscreen))
55 return (1);
57 /* Set up the switch. */
58 if (newscreen) {
59 sp->nextdisp = nsp;
60 F_SET(sp, SC_SSWITCH);
62 return (0);
66 * ex_resize -- :resize [+-]rows
67 * Change the screen size.
69 * PUBLIC: int ex_resize __P((SCR *, EXCMD *));
71 int
72 ex_resize(SCR *sp, EXCMD *cmdp)
74 adj_t adj;
76 switch (FL_ISSET(cmdp->iflags,
77 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)) {
78 case E_C_COUNT:
79 adj = A_SET;
80 break;
81 case E_C_COUNT | E_C_COUNT_NEG:
82 adj = A_DECREASE;
83 break;
84 case E_C_COUNT | E_C_COUNT_POS:
85 adj = A_INCREASE;
86 break;
87 default:
88 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
89 return (1);
91 return (vs_resize(sp, cmdp->count, adj));
95 * ex_sdisplay --
96 * Display the list of screens.
98 * PUBLIC: int ex_sdisplay __P((SCR *));
101 ex_sdisplay(SCR *sp)
103 GS *gp;
104 SCR *tsp;
105 int cnt, col, len, sep;
107 gp = sp->gp;
108 if ((tsp = gp->hq.cqh_first) == (void *)&gp->hq) {
109 msgq(sp, M_INFO, "149|No background screens to display");
110 return (0);
113 col = len = sep = 0;
114 for (cnt = 1; tsp != (void *)&gp->hq && !INTERRUPTED(sp);
115 tsp = tsp->q.cqe_next) {
116 col += len = strlen(tsp->frp->name) + sep;
117 if (col >= sp->cols - 1) {
118 col = len;
119 sep = 0;
120 (void)ex_puts(sp, "\n");
121 } else if (cnt != 1) {
122 sep = 1;
123 (void)ex_puts(sp, " ");
125 (void)ex_puts(sp, tsp->frp->name);
126 ++cnt;
128 if (!INTERRUPTED(sp))
129 (void)ex_puts(sp, "\n");
130 return (0);