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.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
22 #include "../common/common.h"
25 static int is_prefix(ARGS *, CHAR_T *);
26 static int bdisplay(SCR *);
27 static void db(SCR *, CB *, const char *);
30 * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
32 * Display cscope connections, buffers, tags or screens.
34 * PUBLIC: int ex_display(SCR *, EXCMD *);
37 ex_display(SCR *sp, EXCMD *cmdp)
45 if (!is_prefix(arg, L("buffers")))
47 return (bdisplay(sp));
49 if (!is_prefix(arg, L("connections")))
51 return (cscope_display(sp));
53 if (!is_prefix(arg, L("screens")))
55 return (ex_sdisplay(sp));
57 if (!is_prefix(arg, L("tags")))
59 return (ex_tag_display(sp));
61 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
68 * Check that a command argument matches a prefix of a given string.
71 is_prefix(ARGS *arg, CHAR_T *str)
73 return arg->len <= STRLEN(str) && !MEMCMP(arg->bp, str, arg->len);
86 if (SLIST_EMPTY(sp->gp->cutq) && sp->gp->dcbp == NULL) {
87 msgq(sp, M_INFO, "123|No cut buffers to display");
91 /* Display regular cut buffers. */
92 SLIST_FOREACH(cbp, sp->gp->cutq, q) {
93 if (isdigit(cbp->name))
95 if (!TAILQ_EMPTY(cbp->textq))
100 /* Display numbered buffers. */
101 SLIST_FOREACH(cbp, sp->gp->cutq, q) {
102 if (!isdigit(cbp->name))
104 if (!TAILQ_EMPTY(cbp->textq))
109 /* Display default buffer. */
110 if ((cbp = sp->gp->dcbp) != NULL)
111 db(sp, cbp, "default buffer");
120 db(SCR *sp, CB *cbp, const char *name)
128 (void)ex_printf(sp, "********** %s%s\n",
129 name == NULL ? KEY_NAME(sp, cbp->name) : name,
130 F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
131 TAILQ_FOREACH(tp, cbp->textq, q) {
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");