]>
Commit | Line | Data |
---|---|---|
58b9d8ef | 1 | /* $Header$ |
2 | * | |
3 | * Copyright 1991 by the Massachusetts Institute of Technology. | |
4 | * | |
5 | * For further information on copyright and distribution | |
6 | * see the file mit-copyright.h | |
7 | */ | |
8 | ||
9 | #include <mit-copyright.h> | |
10 | #include <stdio.h> | |
11 | #include <Xm/Xm.h> | |
b2d21e59 | 12 | #include <moira.h> |
58b9d8ef | 13 | #include "mmoira.h" |
14 | ||
15 | ||
16 | help(node) | |
17 | char *node; | |
18 | { | |
19 | FILE *helpfile = NULL; | |
b2d21e59 | 20 | char buf[1024], key[32], *msg, helpbuf[10240], *filename; |
21 | char *realloc(), *getenv(); | |
58b9d8ef | 22 | |
23 | sprintf(key, "*%s\n", node); | |
b2d21e59 | 24 | filename = getenv("MOIRAHELPFILE"); |
25 | if (filename == NULL) | |
26 | filename = HELPFILE; | |
27 | helpfile = fopen(filename, "r"); | |
58b9d8ef | 28 | if (helpfile == NULL) { |
29 | display_error("Sorry, help is currently unavailable.\n"); | |
30 | return; | |
31 | } | |
32 | while (fgets(buf, sizeof(buf), helpfile)) | |
33 | if (!strcmp(buf, key)) | |
34 | break; | |
35 | if (strcmp(buf, key)) { | |
36 | sprintf(buf, "Sorry, unable to find help on topic \"%s\".\n", node); | |
37 | display_error(buf); | |
38 | fclose(helpfile); | |
39 | return; | |
40 | } | |
b2d21e59 | 41 | msg = NULL; |
58b9d8ef | 42 | while (fgets(buf, sizeof(buf), helpfile)) |
43 | if (buf[0] == '*') | |
44 | break; | |
b2d21e59 | 45 | else { |
46 | if (msg) { | |
47 | if (!strcmp(buf, "\n")) | |
48 | strcpy(buf, " \n"); | |
49 | msg = realloc(msg, strlen(msg) + strlen(buf)); | |
50 | strcat(msg, buf); | |
51 | } else | |
52 | msg = strsave(buf); | |
53 | } | |
58b9d8ef | 54 | fclose(helpfile); |
b2d21e59 | 55 | if (msg) { |
56 | PopupHelpWindow(msg); | |
57 | free(msg); | |
58 | } | |
58b9d8ef | 59 | return; |
60 | } | |
61 | ||
62 | help_form_callback(dummy, form) | |
63 | int dummy; | |
64 | EntryForm *form; | |
65 | { | |
f7c9217f | 66 | UserPrompt **p; |
67 | int count; | |
68 | ||
69 | /* undocumented Motif internal routine to advance in tab group. | |
70 | * In this case we're going backwards because for some reason | |
71 | * the form advances whenever this button is pressed. | |
72 | * However, it doesn't seem to go backwards even though source | |
73 | * implies that it should. So we go forward until we wrap. | |
74 | */ | |
75 | count = 0; | |
76 | for (p = form->inputlines; *p; p++) | |
77 | if (!p->insensitive) | |
78 | count++; | |
79 | while (count-- > 1) | |
80 | _XmMgrTraversal(form->formpointer, XmTRAVERSE_PREV_TAB_GROUP); | |
58b9d8ef | 81 | help(form->formname); |
82 | } | |
83 |