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>
23 #include "../common/common.h"
28 * Display help message.
30 * PUBLIC: int ex_help(SCR *, EXCMD *);
33 ex_help(SCR *sp, EXCMD *cmdp)
36 "To see the list of vi commands, enter \":viusage<CR>\"\n");
38 "To see the list of ex commands, enter \":exusage<CR>\"\n");
40 "For an ex command usage statement enter \":exusage [cmd]<CR>\"\n");
42 "For a vi key usage statement enter \":viusage [key]<CR>\"\n");
43 (void)ex_puts(sp, "To exit, enter \":q!\"\n");
48 * ex_usage -- :exusage [cmd]
49 * Display ex usage strings.
51 * PUBLIC: int ex_usage(SCR *, EXCMD *);
54 ex_usage(SCR *sp, EXCMD *cmdp)
59 CHAR_T *name, *p, nb[MAXCMDNAMELEN + 5];
64 if (ISUPPER(ap->bp[0])) {
66 ap->bp[0] = TOLOWER(ap->bp[0]);
69 for (cp = cmds; cp->name != NULL &&
70 MEMCMP(ap->bp, cp->name, ap->len); ++cp);
71 if (cp->name == NULL ||
72 (newscreen && !F_ISSET(cp, E_NEWSCREEN))) {
74 ap->bp[0] = TOUPPER(ap->bp[0]);
75 (void)ex_printf(sp, "The "WVS" command is unknown\n",
76 (int)ap->len, ap->bp);
79 "Command: %s\n Usage: %s\n", cp->help, cp->usage);
82 * The "visual" command has two modes, one from ex,
83 * one from the vi colon line. Don't ask.
85 if (cp != &cmds[C_VISUAL_EX] &&
86 cp != &cmds[C_VISUAL_VI])
88 if (cp == &cmds[C_VISUAL_EX])
89 cp = &cmds[C_VISUAL_VI];
91 cp = &cmds[C_VISUAL_EX];
93 "Command: %s\n Usage: %s\n", cp->help, cp->usage);
97 for (cp = cmds; cp->name != NULL && !INTERRUPTED(sp); ++cp) {
99 * The ^D command has an unprintable name.
102 * We display both capital and lower-case versions of
103 * the appropriate commands -- no need to add in extra
104 * room, they're all short names.
106 if (cp == &cmds[C_SCROLL])
108 else if (F_ISSET(cp, E_NEWSCREEN)) {
110 nb[1] = TOUPPER(cp->name[0]);
113 for (name = cp->name + 1,
114 p = nb + 4; (*p++ = *name++) != '\0';);
119 WVS": %s\n", MAXCMDNAMELEN, name, cp->help);
129 * ex_viusage -- :viusage [key]
130 * Display vi usage strings.
132 * PUBLIC: int ex_viusage(SCR *, EXCMD *);
135 ex_viusage(SCR *sp, EXCMD *cmdp)
142 switch (cmdp->argc) {
144 if (cmdp->argv[0]->len != 1) {
145 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
148 key = cmdp->argv[0]->bp[0];
152 /* Special case: '[' and ']' commands. */
153 if ((key == '[' || key == ']') && cmdp->argv[0]->bp[1] != key)
156 /* Special case: ~ command. */
157 if (key == '~' && O_ISSET(sp, O_TILDEOP))
162 if (kp->usage == NULL)
163 nokey: (void)ex_printf(sp,
164 "The %s key has no current meaning\n",
168 " Key:%s%s\nUsage: %s\n",
169 isblank((u_char)*kp->help) ? "" : " ",
170 kp->help, kp->usage);
173 for (key = 0; key <= MAXVIKEY && !INTERRUPTED(sp); ++key) {
174 /* Special case: ~ command. */
175 if (key == '~' && O_ISSET(sp, O_TILDEOP))
179 if (kp->help != NULL)
180 (void)ex_printf(sp, "%s\n", kp->help);