1 /* $NetBSD: ex_display.c,v 1.1.1.2 2008/05/18 14:31:14 aymeric Exp $ */
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.
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";
18 #include <sys/types.h>
19 #include <sys/queue.h>
21 #include <bitstring.h>
27 #include "../common/common.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 *));
41 ex_display(SCR
*sp
, EXCMD
*cmdp
)
43 switch (cmdp
->argv
[0]->bp
[0]) {
47 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
48 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
50 return (bdisplay(sp
));
53 #define ARG "connections"
54 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
55 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
57 return (cscope_display(sp
));
61 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
62 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
64 return (ex_sdisplay(sp
));
68 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
69 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
71 return (ex_tag_display(sp
));
73 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
87 if (sp
->wp
->cutq
.lh_first
== NULL
&& sp
->wp
->dcbp
== NULL
) {
88 msgq(sp
, M_INFO
, "123|No cut buffers to display");
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
))
96 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
101 /* Display numbered buffers. */
102 for (cbp
= sp
->wp
->cutq
.lh_first
; cbp
!= NULL
; cbp
= cbp
->q
.le_next
) {
103 if (!isdigit(cbp
->name
))
105 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
110 /* Display default buffer. */
111 if ((cbp
= sp
->wp
->dcbp
) != NULL
)
112 db(sp
, cbp
, "default buffer");
121 db(SCR
*sp
, CB
*cbp
, const char *np
)
127 const unsigned char *name
= (const void *)np
;
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
));
140 (void)ex_puts(sp
, "\n");