2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: ex_usage.c,v 8.11 1993/12/17 13:43:59 bostic Exp $ (Berkeley) $Date: 1993/12/17 13:43:59 $";
12 #include <sys/types.h>
21 * Display help message.
29 (void)ex_printf(EXCOOKIE
,
30 "To see the list of vi commands, enter \":viusage<CR>\"\n");
31 (void)ex_printf(EXCOOKIE
,
32 "To see the list of ex commands, enter \":exusage<CR>\"\n");
33 (void)ex_printf(EXCOOKIE
,
34 "For an ex command usage statement enter \":exusage [cmd]<CR>\"\n");
35 (void)ex_printf(EXCOOKIE
,
36 "For a vi key usage statement enter \":viusage [key]<CR>\"\n");
37 (void)ex_printf(EXCOOKIE
, "To exit, enter \":q!\"\n");
42 * ex_usage -- :exusage [cmd]
43 * Display ex usage strings.
46 ex_usage(sp
, ep
, cmdp
)
57 for (cp
= cmds
; cp
->name
!= NULL
&&
58 memcmp(ap
->bp
, cp
->name
, ap
->len
); ++cp
);
60 (void)ex_printf(EXCOOKIE
,
61 "The %.*s command is unknown.",
62 (int)ap
->len
, ap
->bp
);
64 (void)ex_printf(EXCOOKIE
,
65 "Command: %s\n Usage: %s\n", cp
->help
, cp
->usage
);
68 * The "visual" command has two modes, one from ex,
69 * one from the vi colon line. Don't ask.
71 if (cp
!= &cmds
[C_VISUAL_EX
] &&
72 cp
!= &cmds
[C_VISUAL_VI
])
74 if (cp
== &cmds
[C_VISUAL_EX
])
75 cp
= &cmds
[C_VISUAL_VI
];
77 cp
= &cmds
[C_VISUAL_EX
];
78 (void)ex_printf(EXCOOKIE
,
79 "Command: %s\n Usage: %s\n", cp
->help
, cp
->usage
);
83 for (cp
= cmds
; cp
->name
!= NULL
; ++cp
)
84 (void)ex_printf(EXCOOKIE
,
85 "%*s: %s\n", MAXCMDNAMELEN
, cp
->name
, cp
->help
);
94 * ex_viusage -- :viusage [key]
95 * Display vi usage strings.
98 ex_viusage(sp
, ep
, cmdp
)
106 switch (cmdp
->argc
) {
108 key
= cmdp
->argv
[0]->bp
[0];
112 /* Special case: '[' and ']' commands. */
113 if ((key
== '[' || key
== ']') && cmdp
->argv
[0]->bp
[1] != key
)
117 if (kp
->func
== NULL
)
118 nokey
: (void)ex_printf(EXCOOKIE
,
119 "The %s key has no current meaning",
122 (void)ex_printf(EXCOOKIE
,
123 " Key:%s%s\nUsage: %s\n",
124 isblank(*kp
->help
) ? "" : " ", kp
->help
, kp
->usage
);
127 for (key
= 0; key
<= MAXVIKEY
; ++key
) {
129 if (kp
->help
!= NULL
)
130 (void)ex_printf(EXCOOKIE
, "%s\n", kp
->help
);