Added basic help messages in addtion to reference to web pages

This commit is contained in:
Jim Monte 2019-12-16 01:40:25 -05:00 committed by Holger Vogt
parent 76cf00853c
commit de7d292501
2 changed files with 68 additions and 36 deletions

View File

@ -17,19 +17,20 @@
* Internet Archive using the link below.
* https://web.archive.org/web/20180221111839/http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/
*/
void
com_ghelp(wordlist *wl)
#define BASE_HELP_URL "http://ngspice.sourceforge.net/docs"
void com_ghelp(wordlist *wl)
{
#if defined(HAS_WINGUI) || defined(_MSC_VER) || defined(__MINGW32__) || defined(X_DISPLAY_MISSING) || defined(NOINTHELP)
#if defined(HAS_WINGUI) || defined(_MSC_VER) || defined(__MINGW32__) ||\
defined(X_DISPLAY_MISSING) || defined(NOINTHELP)
com_help(wl);
NG_IGNORE(wl);
(void) printf("Internal help is no longer available!\n"
"For the latest official ngspice manual in PDF format, "
"please see\n"
" http://ngspice.sourceforge.net/docs/ngspice-manual.pdf\n"
"Or for HTML see\n"
" http://ngspice.sourceforge.net/docs/ngspice-html-manual/manual.html\n");
/* After brief help from com_help, add info on the web links to the
* the PDF and HTML versions of the manual */
(void) out_printf("For further details please see the latest official "
"ngspice manual in PDF format at\n"
" " BASE_HELP_URL "/ngspice-manual.pdf\n"
"or in HTML format at\n"
" " BASE_HELP_URL "/ngspice-html-manual/manual.html\n\n");
return;
#else

View File

@ -9,51 +9,78 @@
#include "com_help.h"
#include "ngspice/fteext.h"
void
com_help(wordlist *wl)
#define N_CMD_DFLT 512
void com_help(wordlist *wl)
{
struct comm *c;
struct comm *ccc[512]; /* Should be enough. */
int numcoms, i;
bool allflag = FALSE;
/* Make empty list and "all" behave the same except for the part
* related to "help all" */
if (wl && eq(wl->wl_word, "all")) {
allflag = TRUE;
wl = NULL; /* XXX Probably right */
wl = (wordlist *) NULL;
}
/* We want to use more mode whether "moremode" is set or not. */
/* We want to use more mode whether "moremode" is set or not.
* In that case the code below should be changed... */
out_moremode = TRUE;
out_init();
out_moremode = FALSE;
if (wl == NULL) {
out_printf("For a complete description "
"read the Spice3 User's Manual.\n");
struct comm *ccc_dflt[N_CMD_DFLT]; /* Should be enough. */
struct comm **ccc; /* dynamic alloc in case it is not */
int numcoms;
if (!allflag) {
out_printf("For a list of all commands "
"type \"help all\", for a short\n"
"description of \"command\", "
"type \"help command\".\n");
return;
}
/* Count the number of commands */
for (numcoms = 0; cp_coms[numcoms].co_func != NULL; numcoms++) {
;
}
if (numcoms > N_CMD_DFLT) {
ccc = TMALLOC(struct comm *, numcoms);
}
else {
ccc = ccc_dflt;
}
/* Sort the commands */
for (numcoms = 0; cp_coms[numcoms].co_func != NULL; numcoms++)
for (numcoms = 0; cp_coms[numcoms].co_func != NULL; numcoms++) {
ccc[numcoms] = &cp_coms[numcoms];
}
qsort(ccc, (size_t) numcoms, sizeof(struct comm *), hcomp);
for (i = 0; i < numcoms; i++) {
if ((ccc[i]->co_spiceonly && ft_nutmeg) ||
(ccc[i]->co_help == NULL) ||
(!allflag && !ccc[i]->co_major))
continue;
out_printf("%s ", ccc[i]->co_comname);
out_printf(ccc[i]->co_help, cp_program);
out_send("\n");
/* Print help for each of the "major" commands */
{
int i;
for (i = 0; i < numcoms; i++) {
if ((ccc[i]->co_spiceonly && ft_nutmeg) ||
(ccc[i]->co_help == NULL) ||
(!allflag && !ccc[i]->co_major)) {
continue;
}
out_printf("%s ", ccc[i]->co_comname);
out_printf(ccc[i]->co_help, cp_program);
out_send("\n");
}
}
} else {
/* Free allocation if it was required */
if (ccc != ccc_dflt) {
txfree(ccc);
}
}
else {
while (wl != NULL) {
struct comm *c;
for (c = &cp_coms[0]; c->co_func != NULL; c++)
if (eq(wl->wl_word, c->co_comname)) {
out_printf("%s ", c->co_comname);
@ -73,16 +100,20 @@ com_help(wordlist *wl)
if (al == NULL) {
fprintf(cp_out, "Sorry, no help for %s.\n", wl->wl_word);
} else {
}
else {
out_printf("%s is aliased to ", wl->wl_word);
/* Minor badness here... */
wl_print(al->al_text, cp_out);
out_send("\n");
}
}
wl = wl->wl_next;
}
} /* end of case that a function with the given name was found */
wl = wl->wl_next; /* step to next word in list of help items */
} /* end of loop over list of help items */
}
out_send("\n");
}
} /* end of function com_help */