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 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 *));
39 ex_display(SCR
*sp
, EXCMD
*cmdp
)
41 switch (cmdp
->argv
[0]->bp
[0]) {
45 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
46 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
48 return (bdisplay(sp
));
51 #define ARG "connections"
52 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
53 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
55 return (cscope_display(sp
));
59 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
60 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
62 return (ex_sdisplay(sp
));
66 if (cmdp
->argv
[0]->len
>= sizeof(ARG
) ||
67 memcmp(cmdp
->argv
[0]->bp
, ARG
, cmdp
->argv
[0]->len
))
69 return (ex_tag_display(sp
));
71 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
85 if (sp
->wp
->cutq
.lh_first
== NULL
&& sp
->wp
->dcbp
== NULL
) {
86 msgq(sp
, M_INFO
, "123|No cut buffers to display");
90 /* Display regular cut buffers. */
91 for (cbp
= sp
->wp
->cutq
.lh_first
; cbp
!= NULL
; cbp
= cbp
->q
.le_next
) {
92 if (isdigit(cbp
->name
))
94 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
99 /* Display numbered buffers. */
100 for (cbp
= sp
->wp
->cutq
.lh_first
; cbp
!= NULL
; cbp
= cbp
->q
.le_next
) {
101 if (!isdigit(cbp
->name
))
103 if (cbp
->textq
.cqh_first
!= (void *)&cbp
->textq
)
108 /* Display default buffer. */
109 if ((cbp
= sp
->wp
->dcbp
) != NULL
)
110 db(sp
, cbp
, "default buffer");
119 db(SCR
*sp
, CB
*cbp
, u_char
*name
)
127 (void)ex_printf(sp
, "********** %s%s\n",
128 name
== NULL
? KEY_NAME(sp
, cbp
->name
) : name
,
129 F_ISSET(cbp
, CB_LMODE
) ? " (line mode)" : " (character mode)");
130 for (tp
= cbp
->textq
.cqh_first
;
131 tp
!= (void *)&cbp
->textq
; tp
= tp
->q
.cqe_next
) {
132 for (len
= tp
->len
, p
= tp
->lb
; len
--; ++p
) {
133 (void)ex_puts(sp
, KEY_NAME(sp
, *p
));
137 (void)ex_puts(sp
, "\n");