1 #include "afni.h"
2 #include "suma_objs.h" /* 21 Apr 2020 */
3 #include "afni_whelp.h"
4 /*------------------------------------------------------------*/
5 
AFNI_All_Documented_Widgets(void)6 char *AFNI_All_Documented_Widgets(void)
7 {
8    static char FuncName[]={"AFNI_All_Documented_Widgets"};
9    char *s=NULL;
10    SUMA_ENTRY;
11    s = SUMA_append_replace_string(s,AFNI_Help_AllMainCont(TXT),"\n",3);
12 
13    /* s = SUMA_append_replace_string(s,SUMA_Help_AllInstaCorrCont(TXT),"\n",3);*/
14    SUMA_RETURN(s);
15 }
16 
AFNI_gsf(char * uwname,TFORM target,char ** hintout,char ** helpout)17 char * AFNI_gsf(char *uwname, TFORM target, char **hintout, char **helpout)
18 {
19    static char FuncName[]={"AFNI_gsf"};
20    static char sss[64]={"You Should Never Get This"};
21    static int lock = 0;
22    char *DW = SUMA_get_DocumentedWidgets();
23 
24    if (target == WEB && !DW) { /* That is when gsf needs DocumentedWidgets */
25       char *ss=NULL;
26       if (!lock) {
27          /* Need to init list of all documented widgets */
28          /* Careful - next function will call SUMA_gsf() also.
29          Make sure AFNI_gsf() does not rely on DocumentedWidgets
30          for anything but WEB targ */
31          ss = AFNI_All_Documented_Widgets();
32          SUMA_set_DocumentedWidgets(&ss);
33          DW = SUMA_get_DocumentedWidgets();
34          if (!DW) {
35             SUMA_S_Err("Should not fail here");
36             lock = 1;
37             SUMA_RETURN(sss);
38          }
39       } else {
40          SUMA_S_Err("Failed and locked out");
41          SUMA_RETURN(sss);
42       }
43    }
44 
45    SUMA_RETURN(SUMA_gsf_eng(uwname, target, hintout, helpout));
46 }
47 
AFNI_Help_AllMainCont(TFORM targ)48 char * AFNI_Help_AllMainCont (TFORM targ)
49 {
50    static char FuncName[]={"AFNI_Help_AllMainCont"};
51    char *s = NULL, *shh=NULL, *sii=NULL;
52    int k=0;
53    SUMA_STRING *SS = NULL;
54    char *worder[] = {
55                      "AfniCont",
56                      "AfniCont->ProgCont",
57                      "AfniCont->ProgCont->done",
58                      NULL };
59    SUMA_ENTRY;
60 
61    SS = SUMA_StringAppend (NULL, NULL);
62 
63    k = 0;
64    while (worder[k]) {
65          s = AFNI_gsf(worder[k], targ, &sii, &shh);
66          if (!shh || strstr(sii, shh)) {/* help same as hint */
67             SS = SUMA_StringAppend_va(SS, "%s\n", s);
68          } else {
69             SS = SUMA_StringAppend_va(SS, "%s\n%s\n",
70                                    s, shh?shh:"");
71          }
72          SUMA_ifree(sii); SUMA_ifree(shh);
73       ++k;
74    }
75 
76    SUMA_SS2S(SS, s);
77 
78    SUMA_RETURN(SUMA_Sphinx_String_Edit(&s, targ, 0));
79 }
80 
81