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.
13 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 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
25 #include "../common/common.h"
28 static int is_prefix
__P((ARGS
*, CHAR_T
*));
29 static int bdisplay
__P((SCR
*));
30 static void db
__P((SCR
*, CB
*, u_char
*));
33 * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
35 * Display cscope connections, buffers, tags or screens.
37 * PUBLIC: int ex_display __P((SCR *, EXCMD *));
40 ex_display(SCR
*sp
, EXCMD
*cmdp
)
48 if (!is_prefix(arg
, L("buffers")))
50 return (bdisplay(sp
));
52 if (!is_prefix(arg
, L("connections")))
54 return (cscope_display(sp
));
56 if (!is_prefix(arg
, L("screens")))
58 return (ex_sdisplay(sp
));
60 if (!is_prefix(arg
, L("tags")))
62 return (ex_tag_display(sp
));
64 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
71 * Check that a command argument matches a prefix of a given string.
74 is_prefix(ARGS
*arg
, CHAR_T
*str
)
76 return arg
->len
<= STRLEN(str
) && !MEMCMP(arg
->bp
, str
, arg
->len
);
89 if (sp
->wp
->cutq
.lh_first
== NULL
&& sp
->wp
->dcbp
== NULL
) {
90 msgq(sp
, M_INFO
, "123|No cut buffers to display");
94 /* Display regular cut buffers. */
95 for (cbp
= sp
->wp
->cutq
.lh_first
; cbp
!= NULL
; cbp
= cbp
->q
.le_next
) {
96 if (isdigit(cbp
->name
))
98 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
103 /* Display numbered buffers. */
104 for (cbp
= sp
->wp
->cutq
.lh_first
; cbp
!= NULL
; cbp
= cbp
->q
.le_next
) {
105 if (!isdigit(cbp
->name
))
107 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
112 /* Display default buffer. */
113 if ((cbp
= sp
->wp
->dcbp
) != NULL
)
114 db(sp
, cbp
, "default buffer");
123 db(SCR
*sp
, CB
*cbp
, u_char
*name
)
131 (void)ex_printf(sp
, "********** %s%s\n",
132 name
== NULL
? KEY_NAME(sp
, cbp
->name
) : name
,
133 F_ISSET(cbp
, CB_LMODE
) ? " (line mode)" : " (character mode)");
134 for (tp
= cbp
->textq
.cqh_first
;
135 tp
!= (void *)&cbp
->textq
; tp
= tp
->q
.cqe_next
) {
136 for (len
= tp
->len
, p
= tp
->lb
; len
--; ++p
) {
137 (void)ex_puts(sp
, KEY_NAME(sp
, *p
));
141 (void)ex_puts(sp
, "\n");