private version of automake no longer needed
[nvi.git] / ex / ex_display.c
blob97fbd34abd2d38a0c5e6e5a2c4fdce63ec83f279
1 /*-
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 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_display.c,v 10.14 2000/07/22 17:31:21 skimo Exp $ (Berkeley) $Date: 2000/07/22 17:31:21 $";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
20 #include <ctype.h>
21 #include <limits.h>
22 #include <stdio.h>
23 #include <string.h>
25 #include "../common/common.h"
26 #include "tag.h"
28 static int bdisplay __P((SCR *));
29 static void db __P((SCR *, CB *, u_char *));
32 * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
34 * Display cscope connections, buffers, tags or screens.
36 * PUBLIC: int ex_display __P((SCR *, EXCMD *));
38 int
39 ex_display(sp, cmdp)
40 SCR *sp;
41 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(sp)
84 SCR *sp;
86 CB *cbp;
88 if (sp->wp->cutq.lh_first == NULL && sp->wp->dcbp == NULL) {
89 msgq(sp, M_INFO, "123|No cut buffers to display");
90 return (0);
93 /* Display regular cut buffers. */
94 for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
95 if (isdigit(cbp->name))
96 continue;
97 if (cbp->textq.cqh_first != (void *)&cbp->textq)
98 db(sp, cbp, NULL);
99 if (INTERRUPTED(sp))
100 return (0);
102 /* Display numbered buffers. */
103 for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
104 if (!isdigit(cbp->name))
105 continue;
106 if (cbp->textq.cqh_first != (void *)&cbp->textq)
107 db(sp, cbp, NULL);
108 if (INTERRUPTED(sp))
109 return (0);
111 /* Display default buffer. */
112 if ((cbp = sp->wp->dcbp) != NULL)
113 db(sp, cbp, "default buffer");
114 return (0);
118 * db --
119 * Display a buffer.
121 static void
122 db(sp, cbp, name)
123 SCR *sp;
124 CB *cbp;
125 u_char *name;
127 CHAR_T *p;
128 GS *gp;
129 TEXT *tp;
130 size_t len;
132 gp = sp->gp;
133 (void)ex_printf(sp, "********** %s%s\n",
134 name == NULL ? KEY_NAME(sp, cbp->name) : name,
135 F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
136 for (tp = cbp->textq.cqh_first;
137 tp != (void *)&cbp->textq; tp = tp->q.cqe_next) {
138 for (len = tp->len, p = tp->lb; len--; ++p) {
139 (void)ex_puts(sp, KEY_NAME(sp, *p));
140 if (INTERRUPTED(sp))
141 return;
143 (void)ex_puts(sp, "\n");