Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / ex / ex_display.c
blobac1940f8fcf97f65f6459a2a96895d3660136c56
1 /* $NetBSD: ex_display.c,v 1.1.1.2 2008/05/18 14:31:14 aymeric Exp $ */
3 /*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #ifndef lint
15 static const char sccsid[] = "Id: ex_display.c,v 10.15 2001/06/25 15:19:15 skimo Exp (Berkeley) Date: 2001/06/25 15:19:15";
16 #endif /* not lint */
18 #include <sys/types.h>
19 #include <sys/queue.h>
21 #include <bitstring.h>
22 #include <ctype.h>
23 #include <limits.h>
24 #include <stdio.h>
25 #include <string.h>
27 #include "../common/common.h"
28 #include "tag.h"
30 static int bdisplay __P((SCR *));
31 static void db __P((SCR *, CB *, const char *));
34 * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
36 * Display cscope connections, buffers, tags or screens.
38 * PUBLIC: int ex_display __P((SCR *, EXCMD *));
40 int
41 ex_display(SCR *sp, EXCMD *cmdp)
43 switch (cmdp->argv[0]->bp[0]) {
44 case 'b':
45 #undef ARG
46 #define ARG "buffers"
47 if (cmdp->argv[0]->len >= sizeof(ARG) ||
48 memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
49 break;
50 return (bdisplay(sp));
51 case 'c':
52 #undef ARG
53 #define ARG "connections"
54 if (cmdp->argv[0]->len >= sizeof(ARG) ||
55 memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
56 break;
57 return (cscope_display(sp));
58 case 's':
59 #undef ARG
60 #define ARG "screens"
61 if (cmdp->argv[0]->len >= sizeof(ARG) ||
62 memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
63 break;
64 return (ex_sdisplay(sp));
65 case 't':
66 #undef ARG
67 #define ARG "tags"
68 if (cmdp->argv[0]->len >= sizeof(ARG) ||
69 memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
70 break;
71 return (ex_tag_display(sp));
73 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
74 return (1);
78 * bdisplay --
80 * Display buffers.
82 static int
83 bdisplay(SCR *sp)
85 CB *cbp;
87 if (sp->wp->cutq.lh_first == NULL && sp->wp->dcbp == NULL) {
88 msgq(sp, M_INFO, "123|No cut buffers to display");
89 return (0);
92 /* Display regular cut buffers. */
93 for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
94 if (isdigit(cbp->name))
95 continue;
96 if (cbp->textq.cqh_first != (void *)&cbp->textq)
97 db(sp, cbp, NULL);
98 if (INTERRUPTED(sp))
99 return (0);
101 /* Display numbered buffers. */
102 for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
103 if (!isdigit(cbp->name))
104 continue;
105 if (cbp->textq.cqh_first != (void *)&cbp->textq)
106 db(sp, cbp, NULL);
107 if (INTERRUPTED(sp))
108 return (0);
110 /* Display default buffer. */
111 if ((cbp = sp->wp->dcbp) != NULL)
112 db(sp, cbp, "default buffer");
113 return (0);
117 * db --
118 * Display a buffer.
120 static void
121 db(SCR *sp, CB *cbp, const char *np)
123 CHAR_T *p;
124 GS *gp;
125 TEXT *tp;
126 size_t len;
127 const unsigned char *name = (const void *)np;
129 gp = sp->gp;
130 (void)ex_printf(sp, "********** %s%s\n",
131 name == NULL ? KEY_NAME(sp, cbp->name) : name,
132 F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
133 for (tp = cbp->textq.cqh_first;
134 tp != (void *)&cbp->textq; tp = tp->q.cqe_next) {
135 for (len = tp->len, p = tp->lb; len--; ++p) {
136 (void)ex_puts(sp, (char *)KEY_NAME(sp, *p));
137 if (INTERRUPTED(sp))
138 return;
140 (void)ex_puts(sp, "\n");