source: branches/stable/WINDOW/AW_help.cxx

Last change on this file was 18092, checked in by westram, 5 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.6 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : AW_help.cxx                                        //
4//   Purpose   :                                                    //
5//                                                                  //
6//   Institute of Microbiology (Technical University Munich)        //
7//   http://www.arb-home.de/                                        //
8//                                                                  //
9// ================================================================ //
10
11#include "aw_awar.hxx"
12#include "aw_window.hxx"
13#include "aw_edit.hxx"
14#include "aw_root.hxx"
15#include "aw_global_awars.hxx"
16#include "aw_msg.hxx"
17#include "aw_select.hxx"
18
19#include <arb_file.h>
20#include <arb_strarray.h>
21
22#include <sys/stat.h>
23#include <arb_str.h>
24
25
26#define AWAR_HELP       "tmp/help/"
27#define AWAR_HELPFILE   AWAR_HELP "file"
28#define AWAR_HELPTEXT   AWAR_HELP "text"
29#define AWAR_HELPSEARCH AWAR_HELP "search"
30
31
32void AW_openURL(AW_root *aw_root, const char *url) {
33    GB_CSTR  ka;
34    char    *browser = aw_root->awar(AWAR_WWW_BROWSER)->read_string();
35
36    while ((ka = GBS_find_string(browser, "$(URL)", 0))) {
37        char *start       = ARB_strpartdup(browser, ka-1);
38        char *new_browser = GBS_global_string_copy("%s%s%s", start, url, ka+6);
39
40        free(start);
41        freeset(browser, new_browser);
42    }
43
44    char     *command = GBS_global_string_copy("(%s)&", browser);
45    GB_ERROR  error   = GBK_system(command); // @@@ use AWT_system_cb here? (need to move whole module -> AWT)
46    aw_message_if(error);
47
48    free(command);
49    free(browser);
50}
51
52// --------------------
53//      help window
54
55static struct {
56    AW_selection_list *uplinks;
57    AW_selection_list *links;
58    char              *history;
59} HELP;
60
61static char *get_full_qualified_help_file_name(const char *helpfile, bool path_for_edit = false) {
62    GB_CSTR   result             = NULp;
63    char     *user_doc_path      = strdup(GB_getenvDOCPATH());
64    char     *devel_doc_path     = strdup(GB_path_in_ARBHOME("HELP_SOURCE/oldhelp"));
65    size_t    user_doc_path_len  = strlen(user_doc_path);
66    size_t    devel_doc_path_len = strlen(devel_doc_path);
67
68    const char *rel_path = NULp;
69    if (strncmp(helpfile, user_doc_path, user_doc_path_len) == 0 && helpfile[user_doc_path_len] == '/') {
70        rel_path = helpfile+user_doc_path_len+1;
71    }
72    else if (strncmp(helpfile, devel_doc_path, devel_doc_path_len) == 0 && helpfile[devel_doc_path_len] == '/') {
73        aw_assert(0);            // when does this happen ? never ?
74        rel_path = helpfile+devel_doc_path_len+1;
75    }
76
77    if (helpfile[0]=='/' && !rel_path) {
78        result = GBS_static_string(helpfile);
79    }
80    else {
81        if (!rel_path) rel_path = helpfile;
82
83        if (rel_path[0]) {
84            if (path_for_edit) {
85#if defined(DEBUG)
86                char *gen_doc_path = strdup(GB_path_in_ARBHOME("HELP_SOURCE/genhelp"));
87
88                char *devel_source = GBS_global_string_copy("%s/%s", devel_doc_path, rel_path);
89                char *gen_source   = GBS_global_string_copy("%s/%s", gen_doc_path, rel_path);
90
91                int devel_size = GB_size_of_file(devel_source);
92                int gen_size   = GB_size_of_file(gen_source);
93
94                aw_assert(devel_size <= 0 || gen_size <= 0); // only one of them shall exist
95
96                if (gen_size>0) {
97                    result = GBS_static_string(gen_source); // edit generated doc
98                }
99                else {
100                    result = GBS_static_string(devel_source); // use normal help source (may be non-existing)
101                }
102
103                free(gen_source);
104                free(devel_source);
105                free(gen_doc_path);
106#else
107                result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path); // use real help file in RELEASE
108#endif // DEBUG
109            }
110            else {
111                result = GBS_global_string("%s/%s", GB_getenvDOCPATH(), rel_path);
112            }
113        }
114        else {
115            result = "";
116        }
117    }
118
119    free(devel_doc_path);
120    free(user_doc_path);
121
122    return strdup(result);
123}
124
125static char *get_full_qualified_help_file_name(AW_root *awr, bool path_for_edit = false) {
126    char *helpfile = awr->awar(AWAR_HELPFILE)->read_string();
127    char *qualified = get_full_qualified_help_file_name(helpfile, path_for_edit);
128    free(helpfile);
129    return qualified;
130}
131
132static char *get_local_help_url(AW_root *awr) {
133    char   *helpfile          = get_full_qualified_help_file_name(awr, false);
134    char   *user_doc_path     = strdup(GB_getenvDOCPATH());
135    char   *user_htmldoc_path = strdup(GB_getenvHTMLDOCPATH());
136    size_t  user_doc_path_len = strlen(user_doc_path);
137    char   *result            = NULp;
138
139    if (strncmp(helpfile, user_doc_path, user_doc_path_len) == 0) { // "real" help file
140        result            = GBS_global_string_copy("%s%s_", user_htmldoc_path, helpfile+user_doc_path_len);
141        size_t result_len = strlen(result);
142
143        aw_assert(result_len > 5);
144
145        if (strcmp(result+result_len-5, ".hlp_") == 0) {
146            strcpy(result+result_len-5, ".html");
147        }
148        else {
149            freenull(result);
150            GB_export_error("Can't browse that file type.");
151        }
152    }
153    else { // on-the-fly-generated help file (e.g. search help)
154        GB_export_error("Can't browse temporary help node");
155    }
156
157    free(user_htmldoc_path);
158    free(user_doc_path);
159    free(helpfile);
160
161    return result;
162}
163
164#if defined(NDEBUG)
165static void store_helpfile_in_tarball(const char *path, const char *mode) {
166    GB_ERROR    error = NULp;
167    const char *base  = GB_path_in_ARBLIB("help");
168
169    if (ARB_strBeginsWith(path, base)) {
170        char *cmd = GBS_global_string_copy("arb_help_useredit.sh %s %s", path+strlen(base)+1, mode);
171        error     = GBK_system(cmd);
172    }
173    else {
174        error = "Unexpected helpfile name (in store_helpfile_in_tarball)";
175    }
176
177    if (error) aw_message(error);
178}
179static void aw_helpfile_modified_cb(const char *path) {
180    static enum { UNMODIFIED, MODIFIED, NOTIFIED } state = UNMODIFIED;
181
182    store_helpfile_in_tarball(path, "end");
183    if (state == UNMODIFIED) state = MODIFIED;
184
185    if (state == MODIFIED) {
186        aw_message("Your changes to ARB help have been stored in an archive.\n"
187                   "See console for what to send to ARB developers!");
188        state = NOTIFIED;
189    }
190}
191#endif
192
193
194static void aw_help_edit_help(AW_window *aww) {
195    char *helpfile = get_full_qualified_help_file_name(aww->get_root(), true);
196
197    if (GB_size_of_file(helpfile)<=0) {
198#if defined(NDEBUG)
199        const char *base = GB_path_in_ARBLIB("help");
200#else
201        const char *base = GB_path_in_ARBHOME("HELP_SOURCE/oldhelp");
202#endif
203
204        const char *copy_cmd = GBS_global_string("cp %s/FORM.hlp %s", base, helpfile); // uses_hlp_res("FORM.hlp"); see ../SOURCE_TOOLS/check_resources.pl@uses_hlp_res
205        aw_message_if(GBK_system(copy_cmd)); // @@@ use AWT_system_cb here (after move)
206    }
207
208#if defined(NDEBUG)
209    store_helpfile_in_tarball(helpfile, "start");
210
211    if (!GB_is_writeablefile(helpfile)) {
212        aw_message("Warning: you do not have the permission to save changes to that helpfile\n"
213                   "(ask your admin to gain write access)");
214    }
215
216    AW_edit_notified(helpfile, makeFileChangedCallback(aw_helpfile_modified_cb));
217#else
218    AW_edit(helpfile);
219#endif
220
221    free(helpfile);
222}
223
224static char *aw_ref_to_title(const char *ref) {
225    if (!ref) return NULp;
226
227    if (GBS_string_matches(ref, "*.ps", GB_IGNORE_CASE)) {   // Postscript file
228        return GBS_global_string_copy("Postscript: %s", ref);
229    }
230
231    char *result = NULp;
232    char *file   = NULp;
233    {
234        char *helpfile = get_full_qualified_help_file_name(ref);
235        file = GB_read_file(helpfile);
236        free(helpfile);
237    }
238
239    if (file) {
240        result = GBS_string_eval(file, "*\nTITLE*\n*=*2:\t=");
241        if (strcmp(file, result)==0) freenull(result);
242        free(file);
243    }
244    else {
245        GB_clear_error();
246    }
247
248    if (!result) {
249        result = strdup(ref);
250    }
251
252    return result;
253}
254
255static void aw_help_select_newest_in_history(AW_root *aw_root) {
256    char *history = HELP.history;
257    if (history) {
258        const char *sep      = strchr(history, '#');
259        char       *lastHelp = sep ? ARB_strpartdup(history, sep-1) : strdup(history);
260
261        aw_root->awar(AWAR_HELPFILE)->write_string(lastHelp);
262        free(lastHelp);
263    }
264}
265
266static void aw_help_back(AW_window *aww) {
267    AW_root    *aw_root = aww->get_root();
268    const char *history = HELP.history;
269    if (history) {
270        const char *currHelp = aw_root->awar(AWAR_HELPFILE)->read_char_pntr();
271        if (currHelp[0]) { // if showing some help
272            const char *sep = strchr(history, '#');
273            if (sep) {
274                char *first = ARB_strpartdup(history, sep-1);
275                freeset(HELP.history, GBS_global_string_copy("%s#%s", sep+1, first)); // wrap first to end
276                free(first);
277                aw_help_select_newest_in_history(aw_root);
278            }
279        }
280        else { // e.g. inside history
281            aw_help_select_newest_in_history(aw_root);
282        }
283    }
284}
285
286static void aw_help_history(AW_window *aww) {
287    ConstStrArray entries;
288    GBT_split_string(entries, HELP.history, '#');
289
290    if (entries.size()) {
291        AW_root    *aw_root  = aww->get_root();
292        const char *currHelp = aw_root->awar(AWAR_HELPFILE)->read_char_pntr();
293
294        if (currHelp[0]) {
295            aw_root->awar(AWAR_HELPFILE)->write_string("");
296
297            HELP.uplinks->clear();
298            HELP.links->clear();
299
300            for (size_t i = 0; i<entries.size(); ++i) {
301                char *title = aw_ref_to_title(entries[i]);
302                HELP.links->insert(title, entries[i]);
303                free(title);
304            }
305
306            HELP.uplinks->insert_default("   ", ""); HELP.uplinks->update();
307            HELP.links  ->insert_default("   ", ""); HELP.links  ->update();
308
309            aw_root->awar(AWAR_HELPTEXT)->write_string("Your previously visited help topics are listed under 'Subtopics'");
310        }
311        else { // e.g. already in HISTORY
312            aw_help_back(aww);
313        }
314    }
315}
316
317static GB_ERROR aw_help_show_external_format(const char *help_file, const char *viewer) {
318    // Called to show *.ps or *.pdf in external viewer.
319    // Can as well show *.suffix.gz (decompresses to temporary *.suffix)
320
321    struct stat st;
322    GB_ERROR    error = NULp;
323    char        sys[1024];
324
325    sys[0] = 0;
326
327    if (stat(help_file, &st) == 0) { // *.ps exists
328        GBS_global_string_to_buffer(sys, sizeof(sys), "%s %s &", viewer, help_file);
329    }
330    else {
331        char *compressed = GBS_global_string_copy("%s.gz", help_file);
332
333        if (stat(compressed, &st) == 0) { // *.ps.gz exists
334            char *name_ext;
335            GB_split_full_path(compressed, NULp, NULp, &name_ext, NULp);
336            // 'name_ext' contains xxx.ps or xxx.pdf
337            char *name, *suffix;
338            GB_split_full_path(name_ext, NULp, NULp, &name, &suffix);
339
340            char *tempname     = GB_unique_filename(name, suffix);
341            char *uncompressed = GB_create_tempfile(tempname);
342
343            GBS_global_string_to_buffer(sys, sizeof(sys),
344                                        "(gunzip <%s >%s ; %s %s ; rm %s) &",
345                                        compressed, uncompressed,
346                                        viewer, uncompressed,
347                                        uncompressed);
348
349            free(uncompressed);
350            free(tempname);
351            free(name);
352            free(suffix);
353            free(name_ext);
354        }
355        else {
356            error = GBS_global_string("Neither %s nor %s exists", help_file, compressed);
357        }
358        free(compressed);
359    }
360
361    if (sys[0] && !error) error = GBK_system(sys);
362
363    return error;
364}
365
366#if defined(DEBUG)
367# define TRACK_HELPFILE
368// # define AUTOBUILD_CHANGED_HELPFILE
369#endif
370
371#if defined(TRACK_HELPFILE)
372// automatically update helpfile after changes in DEBUG mode
373
374static bool          track_helpfile        = false;
375static unsigned long helpfile_stamp        = 0;
376static unsigned long helpfile_edited_stamp = 0;
377
378const unsigned TRACK_FREQUENCY = 500; // ms
379
380static unsigned autorefresh_helpfile(AW_root *awr) {
381    char     *help_file   = get_full_qualified_help_file_name(awr);
382    unsigned  callAgainIn = TRACK_FREQUENCY;
383
384    if (help_file[0]) {
385        unsigned long lastChanged = GB_time_of_file(help_file);
386
387        if (lastChanged != helpfile_stamp) {
388            awr->awar(AWAR_HELPFILE)->touch(); // reload
389            aw_assert(helpfile_stamp == lastChanged);
390        }
391#if defined(AUTOBUILD_CHANGED_HELPFILE)
392        else { // automatically make help
393            char *edited_help_file = get_full_qualified_help_file_name(awr, true);
394            if (strcmp(help_file, edited_help_file) != 0) {
395                unsigned long editLastChanged = GB_time_of_file(edited_help_file);
396
397                if (editLastChanged>helpfile_edited_stamp) {
398                    GB_ERROR error = GBK_system("cd $ARBHOME; make help"); // @@@ use AWT_system_cb here (after move)
399                    if (error) aw_message(error);
400                    helpfile_edited_stamp = editLastChanged;
401                    callAgainIn = 10;
402                }
403            }
404
405            free(edited_help_file);
406        }
407#endif
408    }
409    free(help_file);
410
411    return callAgainIn;
412}
413
414#endif
415
416static void aw_help_helpfile_changed_cb(AW_root *awr) {
417    char *help_file = get_full_qualified_help_file_name(awr);
418
419#if defined(TRACK_HELPFILE)
420    track_helpfile = false;
421#endif
422
423    if (!strlen(help_file)) {
424        awr->awar(AWAR_HELPTEXT)->write_string("Select one of the topics from the lists on the left side or\n"
425                                               "press the BACK button above.");
426    }
427    else if (GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE)) { // Postscript file
428        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_GS());
429        if (error) aw_message(error);
430        aw_help_select_newest_in_history(awr);
431    }
432    else if (GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE)) { // PDF file
433        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_PDFVIEW());
434        if (error) aw_message(error);
435        aw_help_select_newest_in_history(awr);
436    }
437    else {
438        if (HELP.history) {
439            if (strncmp(help_file, HELP.history, strlen(help_file)) != 0) {
440                // remove current help from history (if present) and prefix it to history
441                char *srt = GBS_global_string_copy("*#%s*=*1*2:*=%s#*1", help_file, help_file);
442                char *h   = GBS_string_eval(HELP.history, srt);
443
444                aw_assert(h);
445                freeset(HELP.history, h);
446                free(srt);
447            }
448        }
449        else {
450            HELP.history = strdup(help_file);
451        }
452
453#if defined(TRACK_HELPFILE)
454        track_helpfile = true;
455        helpfile_edited_stamp = helpfile_stamp = GB_time_of_file(help_file);
456#endif
457
458        char *helptext = GB_read_file(help_file);
459        if (helptext) {
460            char *ptr;
461            char *h, *h2, *tok;
462
463            ptr = strdup(helptext);
464            HELP.uplinks->clear();
465            h2 = GBS_find_string(ptr, "\nUP", 0);
466            while ((h = h2)) {
467                h2 = GBS_find_string(h2+1, "\nUP", 0);
468                tok = strtok(h+3, " \n\t");  // now I got UP
469                char *title = aw_ref_to_title(tok);
470                if (tok) HELP.uplinks->insert(title, tok);
471                free(title);
472            }
473            free(ptr);
474            HELP.uplinks->insert_default("   ", "");
475            HELP.uplinks->update();
476
477            ptr = strdup(helptext);
478            HELP.links->clear();
479            h2 = GBS_find_string(ptr, "\nSUB", 0);
480            while ((h = h2)) {
481                h2 = GBS_find_string(h2+1, "\nSUB", 0);
482                tok = strtok(h+4, " \n\t");  // now I got SUB
483                char *title = aw_ref_to_title(tok);
484                if (tok) HELP.links->insert(title, tok);
485                free(title);
486            }
487            free(ptr);
488            HELP.links->insert_default("   ", "");
489            HELP.links->update();
490
491            ptr = GBS_find_string(helptext, "TITLE", 0);
492            if (!ptr) ptr = helptext;
493            ptr = GBS_string_eval(ptr, "{*\\:*}=*2");
494
495            awr->awar(AWAR_HELPTEXT)->write_string(ptr);
496            free(ptr);
497            free(helptext);
498        }
499        else {
500            char *msg = GBS_global_string_copy("I cannot find the help file '%s'\n\n"
501                                               "Please help us to complete the ARB-Help by submitting\n"
502                                               "this missing helplink via ARB_NT/File/About/SubmitBug\n"
503                                               "Thank you.\n"
504                                               "\n"
505                                               "Details:\n"
506                                               "%s",
507                                               help_file, GB_await_error());
508            awr->awar(AWAR_HELPTEXT)->write_string(msg);
509            free(msg);
510        }
511    }
512    free(help_file);
513}
514
515static void aw_help_browse(AW_window *aww) {
516    char *help_url = get_local_help_url(aww->get_root());
517    if (help_url) {
518        AW_openURL(aww->get_root(), help_url);
519        free(help_url);
520    }
521    else {
522        aw_message(GBS_global_string("Can't detect URL of help file\n(Reason: %s)", GB_await_error()));
523    }
524}
525
526static void aw_help_search(AW_window *aww) {
527    GB_ERROR  error      = NULp;
528    char     *searchtext = aww->get_root()->awar(AWAR_HELPSEARCH)->read_string();
529
530    if (searchtext[0]==0) error = "Empty searchstring";
531    else {
532        char        *helpfilename = NULp;
533        static char *last_help; // tempfile containing last search result
534
535        // replace all spaces in 'searchtext' by '.*' (also eliminate multi-spaces)
536        freeset(searchtext, GBS_string_eval(searchtext, "  = : =.*"));
537
538        static GB_HASH *searchHash = GBS_create_dynaval_hash(20, GB_MIND_CASE, GBS_dynaval_free);
539
540        // grep .hlp for occurrences of 'searchtext'.
541        // write filenames of matching files into 'helpfilename'
542        {
543            const char *existingSearch = (const char*)GBS_read_hash(searchHash, searchtext);
544            if (existingSearch) {
545                helpfilename = strdup(existingSearch);
546            }
547            else {
548                char *helpname = GB_unique_filename("arb", "hlp");
549                helpfilename   = GB_create_tempfile(helpname);
550                free(helpname);
551            }
552
553            if (!helpfilename) error = GB_await_error();
554            else {
555                char       *quotedSearchExpression = GBK_singlequote(GBS_global_string("^[^#]*%s", searchtext));
556                char       *quotedDocpath          = GBK_singlequote(GB_getenvDOCPATH());
557                const char *gen_help_tmpl          = "cd %s;grep -i %s `find . -name \"*.hlp\"` | arb_sed -e 'sI:.*IIg' -e 'sI^\\./IIg' | sort | uniq > %s";
558                char       *gen_help_cmd           = GBS_global_string_copy(gen_help_tmpl, quotedDocpath, quotedSearchExpression, helpfilename);
559
560                error = GBK_system(gen_help_cmd);
561
562                free(gen_help_cmd);
563                free(quotedDocpath);
564                free(quotedSearchExpression);
565                GB_remove_on_exit(helpfilename);
566            }
567        }
568
569        if (!error) {
570            char *result       = GB_read_file(helpfilename);
571            if (!result) error = GB_await_error();
572            else {
573                // write temporary helpfile containing links to matches as subtopics
574
575                FILE *helpfp       = fopen(helpfilename, "wt");
576                if (!helpfp) error = GB_export_IO_error("writing helpfile", helpfilename);
577                else {
578                    fprintf(helpfp, "\nUP arb.hlp\n");
579                    if (last_help) fprintf(helpfp, "UP %s\n", last_help);
580                    fputc('\n', helpfp);
581
582                    int   results = 0;
583                    char *rp      = result;
584                    while (1) {
585                        char *eol = strchr(rp, '\n');
586                        if (!eol) {
587                            eol = rp;
588                            while (*eol) ++eol;
589                        }
590                        if (eol>rp) {
591                            char old = eol[0];
592                            eol[0] = 0;
593                            fprintf(helpfp, "SUB %s\n", rp);
594                            results++;
595                            eol[0] = old;
596                        }
597                        if (eol[0]==0) break; // all results inserted
598                        rp = eol+1;
599                    }
600
601                    fprintf(helpfp, "\nTITLE\t\tResult of search for '%s'\n\n", searchtext);
602                    if (results>0)  fprintf(helpfp, "\t\t%i results are shown as subtopics\n",  results);
603                    else            fprintf(helpfp, "\t\tThere are no results.\n");
604
605                    if (results>0) freedup(last_help, helpfilename);
606
607                    fclose(helpfp);
608                    aww->get_root()->awar(AWAR_HELPFILE)->write_string(helpfilename); // display results in aws
609                }
610                free(result);
611                GBS_write_hash(searchHash, searchtext, (long)strdup(helpfilename));
612            }
613        }
614        free(helpfilename);
615    }
616
617    if (error) aw_message(error);
618
619    free(searchtext);
620}
621
622void AW_help_popup(UNFIXED, const char *help_file) {
623    static AW_window_simple *aws = NULp;
624
625    AW_root *awr = AW_root::SINGLETON;
626
627    if (!aws) {
628        awr->awar_string(AWAR_HELPTEXT,   "", AW_ROOT_DEFAULT);
629        awr->awar_string(AWAR_HELPSEARCH, "", AW_ROOT_DEFAULT);
630        awr->awar_string(AWAR_HELPFILE,   "", AW_ROOT_DEFAULT);
631        awr->awar(AWAR_HELPFILE)->add_callback(aw_help_helpfile_changed_cb);
632
633        aws = new AW_window_simple;
634        aws->init(awr, "HELP", "HELP WINDOW");
635        aws->load_xfig("help.fig");
636
637        aws->button_length(9);
638        aws->auto_space(5, 5);
639
640        aws->at("close");
641        aws->callback(AW_POPDOWN);
642        aws->create_button("CLOSE", "CLOSE", "C");
643
644        aws->callback(aw_help_back);
645        aws->create_button("BACK", "BACK", "B");
646
647        aws->callback(aw_help_history);
648        aws->create_button("HISTORY", "HISTORY", "H");
649
650        aws->at("expression");
651        aws->d_callback(makeWindowCallback(aw_help_search)); // enable ENTER in searchfield to start search
652        aws->create_input_field(AWAR_HELPSEARCH, 40);
653        aws->callback(aw_help_search);
654        aws->create_button("SEARCH", "SEARCH", "S", "+");
655
656        aws->at("browse");
657        aws->callback(aw_help_browse);
658        aws->create_button("BROWSE", "BROWSE", "B");
659
660        aws->callback(aw_help_edit_help);
661        aws->create_button("EDIT", "EDIT", "E");
662
663        aws->at("super");
664        HELP.uplinks = aws->create_selection_list(AWAR_HELPFILE, false);
665        HELP.uplinks->insert_default("   ", "");
666        HELP.uplinks->update();
667
668        aws->at("sub");
669        HELP.links = aws->create_selection_list(AWAR_HELPFILE, false);
670        HELP.links->insert_default("   ", "");
671        HELP.links->update();
672        HELP.history = NULp;
673
674        aws->at("text");
675        aws->create_text_field(AWAR_HELPTEXT, 3, 3);
676
677#if defined(TRACK_HELPFILE)
678        awr->add_timed_callback(TRACK_FREQUENCY, makeTimedCallback(autorefresh_helpfile));
679#endif
680    }
681
682    aw_assert(help_file);
683
684    awr->awar(AWAR_HELPFILE)->write_string(help_file);
685
686    if (!GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE) &&
687        !GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE))
688    { // don't open help if postscript or pdf file
689        aws->activate();
690    }
691}
692
693
694
Note: See TracBrowser for help on using the repository browser.