minor char * -> CHAR_T *
[nvi.git] / ex / ex_display.c
blobee67b46755d20892cc7460b3cddafeb68b84a790
1 /*-
2 * Copyright (c) 1992, 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_display.c,v 8.12 1993/12/02 10:55:03 bostic Exp $ (Berkeley) $Date: 1993/12/02 10:55:03 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include <ctype.h>
15 #include <string.h>
17 #include "vi.h"
18 #include "tag.h"
19 #include "excmd.h"
21 static int bdisplay __P((SCR *, EXF *));
22 static void db __P((SCR *, CB *));
25 * ex_display -- :display b[uffers] | s[creens] | t[ags]
27 * Display buffers, tags or screens.
29 int
30 ex_display(sp, ep, cmdp)
31 SCR *sp;
32 EXF *ep;
33 EXCMDARG *cmdp;
35 switch (cmdp->argv[0]->bp[0]) {
36 case 'b':
37 return (bdisplay(sp, ep));
38 case 's':
39 return (ex_sdisplay(sp, ep));
40 case 't':
41 return (ex_tagdisplay(sp, ep));
43 msgq(sp, M_ERR,
44 "Unknown display argument %s, use b[uffers], s[creens], or t[ags].",
45 cmdp->argv[0]);
46 return (1);
50 * bdisplay --
52 * Display buffers.
54 static int
55 bdisplay(sp, ep)
56 SCR *sp;
57 EXF *ep;
59 CB *cbp;
61 if (sp->gp->cutq.lh_first == NULL) {
62 (void)ex_printf(EXCOOKIE, "No cut buffers to display.");
63 return (0);
66 /* Display regular cut buffers. */
67 for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
68 if (isdigit(cbp->name))
69 continue;
70 if (cbp->textq.cqh_first != (void *)&cbp->textq)
71 db(sp, cbp);
73 /* Display numbered buffers. */
74 for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
75 if (!isdigit(cbp->name))
76 continue;
77 if (cbp->textq.cqh_first != (void *)&cbp->textq)
78 db(sp, cbp);
80 return (0);
84 * db --
85 * Display a buffer.
87 static void
88 db(sp, cbp)
89 SCR *sp;
90 CB *cbp;
92 TEXT *tp;
93 size_t len;
94 char *p;
96 (void)ex_printf(EXCOOKIE, "********** %s%s\n", charname(sp, cbp->name),
97 F_ISSET(cbp, CB_LMODE) ? " (line mode)" : "");
98 for (tp = cbp->textq.cqh_first;
99 tp != (void *)&cbp->textq; tp = tp->q.cqe_next) {
100 for (len = tp->len, p = tp->lb; len--;)
101 (void)ex_printf(EXCOOKIE, "%s", charname(sp, *p++));
102 (void)ex_printf(EXCOOKIE, "\n");