source: branches/species/WINDOW/AW_help.cxx

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