1 /* $NetBSD: ex_display.c,v 1.4 2014/01/26 21:43:45 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.
13 #include <sys/cdefs.h>
16 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 ";
19 __RCSID("$NetBSD: ex_display.c,v 1.4 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
25 #include <bitstring.h>
31 #include "../common/common.h"
34 static int is_prefix
__P((ARGS
*, const CHAR_T
*));
35 static int bdisplay
__P((SCR
*));
36 static void db
__P((SCR
*, CB
*, const char *));
39 * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
41 * Display cscope connections, buffers, tags or screens.
43 * PUBLIC: int ex_display __P((SCR *, EXCMD *));
46 ex_display(SCR
*sp
, EXCMD
*cmdp
)
54 if (!is_prefix(arg
, L("buffers")))
56 return (bdisplay(sp
));
58 if (!is_prefix(arg
, L("connections")))
60 return (cscope_display(sp
));
62 if (!is_prefix(arg
, L("screens")))
64 return (ex_sdisplay(sp
));
66 if (!is_prefix(arg
, L("tags")))
68 return (ex_tag_display(sp
));
70 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
77 * Check that a command argument matches a prefix of a given string.
80 is_prefix(ARGS
*arg
, const CHAR_T
*str
)
82 return arg
->len
<= STRLEN(str
) && !MEMCMP(arg
->bp
, str
, arg
->len
);
95 if (LIST_EMPTY(&sp
->wp
->cutq
) && sp
->wp
->dcbp
== NULL
) {
96 msgq(sp
, M_INFO
, "123|No cut buffers to display");
100 /* Display regular cut buffers. */
101 LIST_FOREACH(cbp
, &sp
->wp
->cutq
, q
) {
102 if (ISDIGIT(cbp
->name
))
104 if (!TAILQ_EMPTY(&cbp
->textq
))
109 /* Display numbered buffers. */
110 LIST_FOREACH(cbp
, &sp
->wp
->cutq
, q
) {
111 if (!ISDIGIT(cbp
->name
))
113 if (!TAILQ_EMPTY(&cbp
->textq
))
118 /* Display default buffer. */
119 if ((cbp
= sp
->wp
->dcbp
) != NULL
)
120 db(sp
, cbp
, "default buffer");
129 db(SCR
*sp
, CB
*cbp
, const char *np
)
134 const unsigned char *name
= (const void *)np
;
136 (void)ex_printf(sp
, "********** %s%s\n",
137 name
== NULL
? KEY_NAME(sp
, cbp
->name
) : name
,
138 F_ISSET(cbp
, CB_LMODE
) ? " (line mode)" : " (character mode)");
139 TAILQ_FOREACH(tp
, &cbp
->textq
, q
) {
140 for (len
= tp
->len
, p
= tp
->lb
; len
--; ++p
) {
141 (void)ex_puts(sp
, (char *)KEY_NAME(sp
, *p
));
145 (void)ex_puts(sp
, "\n");