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 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
26 #include "../common/common.h"
29 static int is_prefix __P((ARGS *, 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, CHAR_T *str)
77 return arg->len <= STRLEN(str) && !MEMCMP(arg->bp, str, arg->len);
90 if (SLIST_EMPTY(sp->gp->cutq) && sp->gp->dcbp == NULL) {
91 msgq(sp, M_INFO, "123|No cut buffers to display");
95 /* Display regular cut buffers. */
96 SLIST_FOREACH(cbp, sp->gp->cutq, q) {
97 if (isdigit(cbp->name))
99 if (!TAILQ_EMPTY(cbp->textq))
104 /* Display numbered buffers. */
105 SLIST_FOREACH(cbp, sp->gp->cutq, q) {
106 if (!isdigit(cbp->name))
108 if (!TAILQ_EMPTY(cbp->textq))
113 /* Display default buffer. */
114 if ((cbp = sp->gp->dcbp) != NULL)
115 db(sp, cbp, "default buffer");
124 db(SCR *sp, CB *cbp, const char *name)
132 (void)ex_printf(sp, "********** %s%s\n",
133 name == NULL ? KEY_NAME(sp, cbp->name) : name,
134 F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
135 TAILQ_FOREACH(tp, cbp->textq, q) {
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");