1 /* $NetBSD: ex_display.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
14 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 ";
17 #include <sys/types.h>
18 #include <sys/queue.h>
20 #include <bitstring.h>
26 #include "../common/common.h"
29 static int is_prefix
__P((ARGS
*, const CHAR_T
*));
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
)
49 if (!is_prefix(arg
, L("buffers")))
51 return (bdisplay(sp
));
53 if (!is_prefix(arg
, L("connections")))
55 return (cscope_display(sp
));
57 if (!is_prefix(arg
, L("screens")))
59 return (ex_sdisplay(sp
));
61 if (!is_prefix(arg
, L("tags")))
63 return (ex_tag_display(sp
));
65 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
72 * Check that a command argument matches a prefix of a given string.
75 is_prefix(ARGS
*arg
, const CHAR_T
*str
)
77 return arg
->len
<= STRLEN(str
) && !MEMCMP(arg
->bp
, str
, arg
->len
);
90 if (LIST_EMPTY(&sp
->wp
->cutq
) && sp
->wp
->dcbp
== NULL
) {
91 msgq(sp
, M_INFO
, "123|No cut buffers to display");
95 /* Display regular cut buffers. */
96 LIST_FOREACH(cbp
, &sp
->wp
->cutq
, q
) {
97 if (ISDIGIT(cbp
->name
))
99 if (!TAILQ_EMPTY(&cbp
->textq
))
104 /* Display numbered buffers. */
105 LIST_FOREACH(cbp
, &sp
->wp
->cutq
, q
) {
106 if (!ISDIGIT(cbp
->name
))
108 if (!TAILQ_EMPTY(&cbp
->textq
))
113 /* Display default buffer. */
114 if ((cbp
= sp
->wp
->dcbp
) != NULL
)
115 db(sp
, cbp
, "default buffer");
124 db(SCR
*sp
, CB
*cbp
, const char *np
)
129 const unsigned char *name
= (const void *)np
;
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 TAILQ_FOREACH(tp
, &cbp
->textq
, q
) {
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");