source: tags/ms_r17q3/WINDOW/AW_help.cxx

Last change on this file was 16469, checked in by westram, 7 years ago
  • reintegrates 'textedit' into 'trunk'
    • fixes #586
      • editor now always started asynchronously
      • uses inotify to track file changes
    • also use inotify to track directory updates (in order to update file selections when needed)
      (./) by [16515] ff.; merged by [16551]
  • adds: log:branches/textedit@16448:16468
  • 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             = 0;
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 = 0;
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            = 0;
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 = NULL;
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 0;
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 = 0;
232    char *file = 0;
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==0) {
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 = NULL;
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, NULL, NULL, &name_ext, NULL);
336            // 'name_ext' contains xxx.ps or xxx.pdf
337            char *name, *suffix;
338            GB_split_full_path(name_ext, NULL, NULL, &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#endif
369
370#if defined(TRACK_HELPFILE)
371// automatically update helpfile after changes in DEBUG mode
372
373static bool          track_helpfile        = false;
374static unsigned long helpfile_stamp        = 0;
375static unsigned long helpfile_edited_stamp = 0;
376
377const unsigned TRACK_FREQUENCY = 500; // ms
378
379static unsigned autorefresh_helpfile(AW_root *awr) {
380    char     *help_file   = get_full_qualified_help_file_name(awr);
381    unsigned  callAgainIn = TRACK_FREQUENCY;
382
383    if (help_file[0]) {
384        unsigned long lastChanged = GB_time_of_file(help_file);
385
386        if (lastChanged != helpfile_stamp) {
387            awr->awar(AWAR_HELPFILE)->touch(); // reload
388            aw_assert(helpfile_stamp == lastChanged);
389        }
390        else {
391            char *edited_help_file = get_full_qualified_help_file_name(awr, true);
392            if (strcmp(help_file, edited_help_file) != 0) {
393                unsigned long editLastChanged = GB_time_of_file(edited_help_file);
394
395                if (editLastChanged>helpfile_edited_stamp) {
396                    GB_ERROR error = GBK_system("cd $ARBHOME; make help"); // @@@ use AWT_system_cb here (after move)
397                    if (error) aw_message(error);
398                    helpfile_edited_stamp = editLastChanged;
399                    callAgainIn = 10;
400                }
401            }
402
403            free(edited_help_file);
404        }
405    }
406    free(help_file);
407
408    return callAgainIn;
409}
410
411#endif
412
413static void aw_help_helpfile_changed_cb(AW_root *awr) {
414    char *help_file = get_full_qualified_help_file_name(awr);
415
416#if defined(TRACK_HELPFILE)
417    track_helpfile = false;
418#endif
419
420    if (!strlen(help_file)) {
421        awr->awar(AWAR_HELPTEXT)->write_string("Select one of the topics from the lists on the left side or\n"
422                                               "press the BACK button above.");
423    }
424    else if (GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE)) { // Postscript file
425        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_GS());
426        if (error) aw_message(error);
427        aw_help_select_newest_in_history(awr);
428    }
429    else if (GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE)) { // PDF file
430        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_PDFVIEW());
431        if (error) aw_message(error);
432        aw_help_select_newest_in_history(awr);
433    }
434    else {
435        if (HELP.history) {
436            if (strncmp(help_file, HELP.history, strlen(help_file)) != 0) {
437                // remove current help from history (if present) and prefix it to history
438                char *srt = GBS_global_string_copy("*#%s*=*1*2:*=%s#*1", help_file, help_file);
439                char *h   = GBS_string_eval(HELP.history, srt);
440
441                aw_assert(h);
442                freeset(HELP.history, h);
443                free(srt);
444            }
445        }
446        else {
447            HELP.history = strdup(help_file);
448        }
449
450#if defined(TRACK_HELPFILE)
451        track_helpfile = true;
452        helpfile_edited_stamp = helpfile_stamp = GB_time_of_file(help_file);
453#endif
454
455        char *helptext = GB_read_file(help_file);
456        if (helptext) {
457            char *ptr;
458            char *h, *h2, *tok;
459
460            ptr = strdup(helptext);
461            HELP.uplinks->clear();
462            h2 = GBS_find_string(ptr, "\nUP", 0);
463            while ((h = h2)) {
464                h2 = GBS_find_string(h2+1, "\nUP", 0);
465                tok = strtok(h+3, " \n\t");  // now I got UP
466                char *title = aw_ref_to_title(tok);
467                if (tok) HELP.uplinks->insert(title, tok);
468                free(title);
469            }
470            free(ptr);
471            HELP.uplinks->insert_default("   ", "");
472            HELP.uplinks->update();
473
474            ptr = strdup(helptext);
475            HELP.links->clear();
476            h2 = GBS_find_string(ptr, "\nSUB", 0);
477            while ((h = h2)) {
478                h2 = GBS_find_string(h2+1, "\nSUB", 0);
479                tok = strtok(h+4, " \n\t");  // now I got SUB
480                char *title = aw_ref_to_title(tok);
481                if (tok) HELP.links->insert(title, tok);
482                free(title);
483            }
484            free(ptr);
485            HELP.links->insert_default("   ", "");
486            HELP.links->update();
487
488            ptr = GBS_find_string(helptext, "TITLE", 0);
489            if (!ptr) ptr = helptext;
490            ptr = GBS_string_eval(ptr, "{*\\:*}=*2");
491
492            awr->awar(AWAR_HELPTEXT)->write_string(ptr);
493            free(ptr);
494            free(helptext);
495        }
496        else {
497            char *msg = GBS_global_string_copy("I cannot find the help file '%s'\n\n"
498                                               "Please help us to complete the ARB-Help by submitting\n"
499                                               "this missing helplink via ARB_NT/File/About/SubmitBug\n"
500                                               "Thank you.\n"
501                                               "\n"
502                                               "Details:\n"
503                                               "%s",
504                                               help_file, GB_await_error());
505            awr->awar(AWAR_HELPTEXT)->write_string(msg);
506            free(msg);
507        }
508    }
509    free(help_file);
510}
511
512static void aw_help_browse(AW_window *aww) {
513    char *help_url = get_local_help_url(aww->get_root());
514    if (help_url) {
515        AW_openURL(aww->get_root(), help_url);
516        free(help_url);
517    }
518    else {
519        aw_message(GBS_global_string("Can't detect URL of help file\n(Reason: %s)", GB_await_error()));
520    }
521}
522
523static void aw_help_search(AW_window *aww) {
524    GB_ERROR  error      = 0;
525    char     *searchtext = aww->get_root()->awar(AWAR_HELPSEARCH)->read_string();
526
527    if (searchtext[0]==0) error = "Empty searchstring";
528    else {
529        char        *helpfilename = 0;
530        static char *last_help; // tempfile containing last search result
531
532        // replace all spaces in 'searchtext' by '.*' (also eliminate multi-spaces)
533        freeset(searchtext, GBS_string_eval(searchtext, "  = : =.*"));
534
535        static GB_HASH *searchHash = GBS_create_dynaval_hash(20, GB_MIND_CASE, GBS_dynaval_free);
536
537        // grep .hlp for occurrences of 'searchtext'.
538        // write filenames of matching files into 'helpfilename'
539        {
540            const char *existingSearch = (const char*)GBS_read_hash(searchHash, searchtext);
541            if (existingSearch) {
542                helpfilename = strdup(existingSearch);
543            }
544            else {
545                char *helpname = GB_unique_filename("arb", "hlp");
546                helpfilename   = GB_create_tempfile(helpname);
547                free(helpname);
548            }
549
550            if (!helpfilename) error = GB_await_error();
551            else {
552                char       *quotedSearchExpression = GBK_singlequote(GBS_global_string("^[^#]*%s", searchtext));
553                char       *quotedDocpath          = GBK_singlequote(GB_getenvDOCPATH());
554                const char *gen_help_tmpl          = "cd %s;grep -i %s `find . -name \"*.hlp\"` | arb_sed -e 'sI:.*IIg' -e 'sI^\\./IIg' | sort | uniq > %s";
555                char       *gen_help_cmd           = GBS_global_string_copy(gen_help_tmpl, quotedDocpath, quotedSearchExpression, helpfilename);
556
557                error = GBK_system(gen_help_cmd);
558
559                free(gen_help_cmd);
560                free(quotedDocpath);
561                free(quotedSearchExpression);
562                GB_remove_on_exit(helpfilename);
563            }
564        }
565
566        if (!error) {
567            char *result       = GB_read_file(helpfilename);
568            if (!result) error = GB_await_error();
569            else {
570                // write temporary helpfile containing links to matches as subtopics
571
572                FILE *helpfp       = fopen(helpfilename, "wt");
573                if (!helpfp) error = GB_export_IO_error("writing helpfile", helpfilename);
574                else {
575                    fprintf(helpfp, "\nUP arb.hlp\n");
576                    if (last_help) fprintf(helpfp, "UP %s\n", last_help);
577                    fputc('\n', helpfp);
578
579                    int   results = 0;
580                    char *rp      = result;
581                    while (1) {
582                        char *eol = strchr(rp, '\n');
583                        if (!eol) {
584                            eol = rp;
585                            while (*eol) ++eol;
586                        }
587                        if (eol>rp) {
588                            char old = eol[0];
589                            eol[0] = 0;
590                            fprintf(helpfp, "SUB %s\n", rp);
591                            results++;
592                            eol[0] = old;
593                        }
594                        if (eol[0]==0) break; // all results inserted
595                        rp = eol+1;
596                    }
597
598                    fprintf(helpfp, "\nTITLE\t\tResult of search for '%s'\n\n", searchtext);
599                    if (results>0)  fprintf(helpfp, "\t\t%i results are shown as subtopics\n",  results);
600                    else            fprintf(helpfp, "\t\tThere are no results.\n");
601
602                    if (results>0) freedup(last_help, helpfilename);
603
604                    fclose(helpfp);
605                    aww->get_root()->awar(AWAR_HELPFILE)->write_string(helpfilename); // display results in aws
606                }
607                free(result);
608                GBS_write_hash(searchHash, searchtext, (long)strdup(helpfilename));
609            }
610        }
611        free(helpfilename);
612    }
613
614    if (error) aw_message(error);
615
616    free(searchtext);
617}
618
619void AW_help_popup(UNFIXED, const char *help_file) {
620    static AW_window_simple *aws = 0;
621
622    AW_root *awr = AW_root::SINGLETON;
623
624    if (!aws) {
625        awr->awar_string(AWAR_HELPTEXT,   "", AW_ROOT_DEFAULT);
626        awr->awar_string(AWAR_HELPSEARCH, "", AW_ROOT_DEFAULT);
627        awr->awar_string(AWAR_HELPFILE,   "", AW_ROOT_DEFAULT);
628        awr->awar(AWAR_HELPFILE)->add_callback(aw_help_helpfile_changed_cb);
629
630        aws = new AW_window_simple;
631        aws->init(awr, "HELP", "HELP WINDOW");
632        aws->load_xfig("help.fig");
633
634        aws->button_length(9);
635        aws->auto_space(5, 5);
636
637        aws->at("close");
638        aws->callback(AW_POPDOWN);
639        aws->create_button("CLOSE", "CLOSE", "C");
640
641        aws->callback(aw_help_back);
642        aws->create_button("BACK", "BACK", "B");
643
644        aws->callback(aw_help_history);
645        aws->create_button("HISTORY", "HISTORY", "H");
646
647        aws->at("expression");
648#if defined(ARB_MOTIF)
649        aws->d_callback(makeWindowCallback(aw_help_search)); // enable ENTER in searchfield to start search
650#endif
651        aws->create_input_field(AWAR_HELPSEARCH, 40);
652        aws->callback(aw_help_search);
653#if defined(ARB_GTK)
654        aws->highlight(); // enable ENTER to start search
655#endif
656        aws->create_button("SEARCH", "SEARCH", "S", "+");
657
658        aws->at("browse");
659        aws->callback(aw_help_browse);
660        aws->create_button("BROWSE", "BROWSE", "B");
661
662        aws->callback(aw_help_edit_help);
663        aws->create_button("EDIT", "EDIT", "E");
664
665        aws->at("super");
666        HELP.uplinks = aws->create_selection_list(AWAR_HELPFILE, false);
667        HELP.uplinks->insert_default("   ", "");
668        HELP.uplinks->update();
669
670        aws->at("sub");
671        HELP.links = aws->create_selection_list(AWAR_HELPFILE, false);
672        HELP.links->insert_default("   ", "");
673        HELP.links->update();
674        HELP.history = 0;
675
676        aws->at("text");
677        aws->create_text_field(AWAR_HELPTEXT, 3, 3);
678
679#if defined(TRACK_HELPFILE)
680        awr->add_timed_callback(TRACK_FREQUENCY, makeTimedCallback(autorefresh_helpfile));
681#endif
682    }
683
684    aw_assert(help_file);
685
686    awr->awar(AWAR_HELPFILE)->write_string(help_file);
687
688    if (!GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE) &&
689        !GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE))
690    { // don't open help if postscript or pdf file
691        aws->activate();
692    }
693}
694
695
696
Note: See TracBrowser for help on using the repository browser.