source: tags/ms_r16q2/WINDOW/AW_help.cxx

Last change on this file was 15027, checked in by westram, 8 years ago
  • UNFIX unused AW_window-parameter of AW_help_popup
  • 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
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       = GB_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);
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, bool fileWasChanged, bool editorTerminated) {
180    static enum { UNMODIFIED, MODIFIED, NOTIFIED } state = UNMODIFIED;
181
182    if (fileWasChanged) {
183        store_helpfile_in_tarball(path, "end");
184        if (state == UNMODIFIED) state = MODIFIED;
185    }
186    if (editorTerminated) {
187        if (state == MODIFIED) {
188            aw_message("Your changes to ARB help have been stored in an archive.\n"
189                       "See console for what to send to ARB developers!");
190            state = NOTIFIED;
191        }
192    }
193}
194#endif
195
196
197static void aw_help_edit_help(AW_window *aww) {
198    char *helpfile = get_full_qualified_help_file_name(aww->get_root(), true);
199
200    if (GB_size_of_file(helpfile)<=0) {
201#if defined(NDEBUG)
202        const char *base = GB_path_in_ARBLIB("help");
203#else
204        const char *base = GB_path_in_ARBHOME("HELP_SOURCE/oldhelp");
205#endif
206
207        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
208        aw_message_if(GBK_system(copy_cmd));
209    }
210
211#if defined(NDEBUG)
212    store_helpfile_in_tarball(helpfile, "start");
213
214    if (!GB_is_writeablefile(helpfile)) {
215        aw_message("Warning: you do not have the permission to save changes to that helpfile\n"
216                   "(ask your admin to gain write access)");
217    }
218
219    GBDATA *get_globalawars_gbmain(void); // prototype
220    GBDATA *gbmain = get_globalawars_gbmain(); // hack -- really need main ARB DB here (properties DB does not work with notifications)
221    if (gbmain) {
222        AW_edit(helpfile, aw_helpfile_modified_cb, aww, gbmain);
223    }
224    else {
225        aw_message("Warning: Editing help not possible yet!\n"
226                   "To make it possible:\n"
227                   "- leave help window open,\n"
228                   "- open a database and\n"
229                   "- then click EDIT again.");
230    }
231#else
232    AW_edit(helpfile);
233#endif
234
235    free(helpfile);
236}
237
238static char *aw_ref_to_title(const char *ref) {
239    if (!ref) return 0;
240
241    if (GBS_string_matches(ref, "*.ps", GB_IGNORE_CASE)) {   // Postscript file
242        return GBS_global_string_copy("Postscript: %s", ref);
243    }
244
245    char *result = 0;
246    char *file = 0;
247    {
248        char *helpfile = get_full_qualified_help_file_name(ref);
249        file = GB_read_file(helpfile);
250        free(helpfile);
251    }
252
253    if (file) {
254        result = GBS_string_eval(file, "*\nTITLE*\n*=*2:\t=", 0);
255        if (strcmp(file, result)==0) freenull(result);
256        free(file);
257    }
258    else {
259        GB_clear_error();
260    }
261
262    if (result==0) {
263        result = strdup(ref);
264    }
265
266    return result;
267}
268
269static void aw_help_select_newest_in_history(AW_root *aw_root) {
270    char *history = HELP.history;
271    if (history) {
272        const char *sep      = strchr(history, '#');
273        char       *lastHelp = sep ? GB_strpartdup(history, sep-1) : strdup(history);
274
275        aw_root->awar(AWAR_HELPFILE)->write_string(lastHelp);
276        free(lastHelp);
277    }
278}
279
280static void aw_help_back(AW_window *aww) {
281    AW_root    *aw_root = aww->get_root();
282    const char *history = HELP.history;
283    if (history) {
284        const char *currHelp = aw_root->awar(AWAR_HELPFILE)->read_char_pntr();
285        if (currHelp[0]) { // if showing some help
286            const char *sep = strchr(history, '#');
287            if (sep) {
288                char *first = GB_strpartdup(history, sep-1);
289                freeset(HELP.history, GBS_global_string_copy("%s#%s", sep+1, first)); // wrap first to end
290                free(first);
291                aw_help_select_newest_in_history(aw_root);
292            }
293        }
294        else { // e.g. inside history
295            aw_help_select_newest_in_history(aw_root);
296        }
297    }
298}
299
300static void aw_help_history(AW_window *aww) {
301    ConstStrArray entries;
302    GBT_split_string(entries, HELP.history, '#');
303
304    if (entries.size()) {
305        AW_root    *aw_root  = aww->get_root();
306        const char *currHelp = aw_root->awar(AWAR_HELPFILE)->read_char_pntr();
307
308        if (currHelp[0]) {
309            aw_root->awar(AWAR_HELPFILE)->write_string("");
310
311            HELP.uplinks->clear();
312            HELP.links->clear();
313
314            for (size_t i = 0; i<entries.size(); ++i) {
315                char *title = aw_ref_to_title(entries[i]);
316                HELP.links->insert(title, entries[i]);
317                free(title);
318            }
319
320            HELP.uplinks->insert_default("   ", ""); HELP.uplinks->update();
321            HELP.links  ->insert_default("   ", ""); HELP.links  ->update();
322
323            aw_root->awar(AWAR_HELPTEXT)->write_string("Your previously visited help topics are listed under 'Subtopics'");
324        }
325        else { // e.g. already in HISTORY
326            aw_help_back(aww);
327        }
328    }
329}
330
331static GB_ERROR aw_help_show_external_format(const char *help_file, const char *viewer) {
332    // Called to show *.ps or *.pdf in external viewer.
333    // Can as well show *.suffix.gz (decompresses to temporary *.suffix)
334
335    struct stat st;
336    GB_ERROR    error = NULL;
337    char        sys[1024];
338
339    sys[0] = 0;
340
341    if (stat(help_file, &st) == 0) { // *.ps exists
342        GBS_global_string_to_buffer(sys, sizeof(sys), "%s %s &", viewer, help_file);
343    }
344    else {
345        char *compressed = GBS_global_string_copy("%s.gz", help_file);
346
347        if (stat(compressed, &st) == 0) { // *.ps.gz exists
348            char *name_ext;
349            GB_split_full_path(compressed, NULL, NULL, &name_ext, NULL);
350            // 'name_ext' contains xxx.ps or xxx.pdf
351            char *name, *suffix;
352            GB_split_full_path(name_ext, NULL, NULL, &name, &suffix);
353
354            char *tempname     = GB_unique_filename(name, suffix);
355            char *uncompressed = GB_create_tempfile(tempname);
356
357            GBS_global_string_to_buffer(sys, sizeof(sys),
358                                        "(gunzip <%s >%s ; %s %s ; rm %s) &",
359                                        compressed, uncompressed,
360                                        viewer, uncompressed,
361                                        uncompressed);
362
363            free(uncompressed);
364            free(tempname);
365            free(name);
366            free(suffix);
367            free(name_ext);
368        }
369        else {
370            error = GBS_global_string("Neither %s nor %s exists", help_file, compressed);
371        }
372        free(compressed);
373    }
374
375    if (sys[0] && !error) error = GBK_system(sys);
376
377    return error;
378}
379
380#if defined(DEBUG)
381# define TRACK_HELPFILE
382#endif
383
384#if defined(TRACK_HELPFILE)
385// automatically update helpfile after changes in DEBUG mode
386
387static bool          track_helpfile        = false;
388static unsigned long helpfile_stamp        = 0;
389static unsigned long helpfile_edited_stamp = 0;
390
391const unsigned TRACK_FREQUENCY = 500; // ms
392
393static unsigned autorefresh_helpfile(AW_root *awr) {
394    char     *help_file   = get_full_qualified_help_file_name(awr);
395    unsigned  callAgainIn = TRACK_FREQUENCY;
396
397    if (help_file[0]) {
398        unsigned long lastChanged = GB_time_of_file(help_file);
399
400        if (lastChanged != helpfile_stamp) {
401            awr->awar(AWAR_HELPFILE)->touch(); // reload
402            aw_assert(helpfile_stamp == lastChanged);
403        }
404        else {
405            char *edited_help_file = get_full_qualified_help_file_name(awr, true);
406            if (strcmp(help_file, edited_help_file) != 0) {
407                unsigned long editLastChanged = GB_time_of_file(edited_help_file);
408
409                if (editLastChanged>helpfile_edited_stamp) {
410                    GB_ERROR error = GBK_system("cd $ARBHOME; make help");
411                    if (error) aw_message(error);
412                    helpfile_edited_stamp = editLastChanged;
413                    callAgainIn = 10;
414                }
415            }
416
417            free(edited_help_file);
418        }
419    }
420    free(help_file);
421
422    return callAgainIn;
423}
424
425#endif
426
427static void aw_help_helpfile_changed_cb(AW_root *awr) {
428    char *help_file = get_full_qualified_help_file_name(awr);
429
430#if defined(TRACK_HELPFILE)
431    track_helpfile = false;
432#endif
433
434    if (!strlen(help_file)) {
435        awr->awar(AWAR_HELPTEXT)->write_string("Select one of the topics from the lists on the left side or\n"
436                                               "press the BACK button above.");
437    }
438    else if (GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE)) { // Postscript file
439        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_GS());
440        if (error) aw_message(error);
441        aw_help_select_newest_in_history(awr);
442    }
443    else if (GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE)) { // PDF file
444        GB_ERROR error = aw_help_show_external_format(help_file, GB_getenvARB_PDFVIEW());
445        if (error) aw_message(error);
446        aw_help_select_newest_in_history(awr);
447    }
448    else {
449        if (HELP.history) {
450            if (strncmp(help_file, HELP.history, strlen(help_file)) != 0) {
451                // remove current help from history (if present) and prefix it to history
452                char *comm = GBS_global_string_copy("*#%s*=*1*2:*=%s#*1", help_file, help_file);
453                char *h    = GBS_string_eval(HELP.history, comm, 0);
454
455                aw_assert(h);
456                freeset(HELP.history, h);
457                free(comm);
458            }
459        }
460        else {
461            HELP.history = strdup(help_file);
462        }
463
464#if defined(TRACK_HELPFILE)
465        track_helpfile = true;
466        helpfile_edited_stamp = helpfile_stamp = GB_time_of_file(help_file);
467#endif
468
469        char *helptext = GB_read_file(help_file);
470        if (helptext) {
471            char *ptr;
472            char *h, *h2, *tok;
473
474            ptr = strdup(helptext);
475            HELP.uplinks->clear();
476            h2 = GBS_find_string(ptr, "\nUP", 0);
477            while ((h = h2)) {
478                h2 = GBS_find_string(h2+1, "\nUP", 0);
479                tok = strtok(h+3, " \n\t");  // now I got UP
480                char *title = aw_ref_to_title(tok);
481                if (tok) HELP.uplinks->insert(title, tok);
482                free(title);
483            }
484            free(ptr);
485            HELP.uplinks->insert_default("   ", "");
486            HELP.uplinks->update();
487
488            ptr = strdup(helptext);
489            HELP.links->clear();
490            h2 = GBS_find_string(ptr, "\nSUB", 0);
491            while ((h = h2)) {
492                h2 = GBS_find_string(h2+1, "\nSUB", 0);
493                tok = strtok(h+4, " \n\t");  // now I got SUB
494                char *title = aw_ref_to_title(tok);
495                if (tok) HELP.links->insert(title, tok);
496                free(title);
497            }
498            free(ptr);
499            HELP.links->insert_default("   ", "");
500            HELP.links->update();
501
502            ptr = GBS_find_string(helptext, "TITLE", 0);
503            if (!ptr) ptr = helptext;
504            ptr = GBS_string_eval(ptr, "{*\\:*}=*2", 0);
505
506            awr->awar(AWAR_HELPTEXT)->write_string(ptr);
507            free(ptr);
508            free(helptext);
509        }
510        else {
511            char *msg = GBS_global_string_copy("I cannot find the help file '%s'\n\n"
512                                               "Please help us to complete the ARB-Help by submitting\n"
513                                               "this missing helplink via ARB_NT/File/About/SubmitBug\n"
514                                               "Thank you.\n"
515                                               "\n"
516                                               "Details:\n"
517                                               "%s",
518                                               help_file, GB_await_error());
519            awr->awar(AWAR_HELPTEXT)->write_string(msg);
520            free(msg);
521        }
522    }
523    free(help_file);
524}
525
526static void aw_help_browse(AW_window *aww) {
527    char *help_url = get_local_help_url(aww->get_root());
528    if (help_url) {
529        AW_openURL(aww->get_root(), help_url);
530        free(help_url);
531    }
532    else {
533        aw_message(GBS_global_string("Can't detect URL of help file\n(Reason: %s)", GB_await_error()));
534    }
535}
536
537static void aw_help_search(AW_window *aww) {
538    GB_ERROR  error      = 0;
539    char     *searchtext = aww->get_root()->awar(AWAR_HELPSEARCH)->read_string();
540
541    if (searchtext[0]==0) error = "Empty searchstring";
542    else {
543        char        *helpfilename = 0;
544        static char *last_help; // tempfile containing last search result
545
546        // replace all spaces in 'searchtext' by '.*' (also eliminate multi-spaces)
547        freeset(searchtext, GBS_string_eval(searchtext, "  = : =.*", 0));
548
549        static GB_HASH *searchHash = GBS_create_dynaval_hash(20, GB_MIND_CASE, GBS_dynaval_free);
550
551        // grep .hlp for occurrences of 'searchtext'.
552        // write filenames of matching files into 'helpfilename'
553        {
554            const char *existingSearch = (const char*)GBS_read_hash(searchHash, searchtext);
555            if (existingSearch) {
556                helpfilename = strdup(existingSearch);
557            }
558            else {
559                char *helpname = GB_unique_filename("arb", "hlp");
560                helpfilename   = GB_create_tempfile(helpname);
561                free(helpname);
562            }
563
564            if (!helpfilename) error = GB_await_error();
565            else {
566                char       *quotedSearchExpression = GBK_singlequote(GBS_global_string("^[^#]*%s", searchtext));
567                char       *quotedDocpath          = GBK_singlequote(GB_getenvDOCPATH());
568                const char *gen_help_tmpl          = "cd %s;grep -i %s `find . -name \"*.hlp\"` | arb_sed -e 'sI:.*IIg' -e 'sI^\\./IIg' | sort | uniq > %s";
569                char       *gen_help_cmd           = GBS_global_string_copy(gen_help_tmpl, quotedDocpath, quotedSearchExpression, helpfilename);
570
571                error = GBK_system(gen_help_cmd);
572
573                free(gen_help_cmd);
574                free(quotedDocpath);
575                free(quotedSearchExpression);
576                GB_remove_on_exit(helpfilename);
577            }
578        }
579
580        if (!error) {
581            char *result       = GB_read_file(helpfilename);
582            if (!result) error = GB_await_error();
583            else {
584                // write temporary helpfile containing links to matches as subtopics
585
586                FILE *helpfp       = fopen(helpfilename, "wt");
587                if (!helpfp) error = GB_export_IO_error("writing helpfile", helpfilename);
588                else {
589                    fprintf(helpfp, "\nUP arb.hlp\n");
590                    if (last_help) fprintf(helpfp, "UP %s\n", last_help);
591                    fputc('\n', helpfp);
592
593                    int   results = 0;
594                    char *rp      = result;
595                    while (1) {
596                        char *eol = strchr(rp, '\n');
597                        if (!eol) {
598                            eol = rp;
599                            while (*eol) ++eol;
600                        }
601                        if (eol>rp) {
602                            char old = eol[0];
603                            eol[0] = 0;
604                            fprintf(helpfp, "SUB %s\n", rp);
605                            results++;
606                            eol[0] = old;
607                        }
608                        if (eol[0]==0) break; // all results inserted
609                        rp = eol+1;
610                    }
611
612                    fprintf(helpfp, "\nTITLE\t\tResult of search for '%s'\n\n", searchtext);
613                    if (results>0)  fprintf(helpfp, "\t\t%i results are shown as subtopics\n",  results);
614                    else            fprintf(helpfp, "\t\tThere are no results.\n");
615
616                    if (results>0) freedup(last_help, helpfilename);
617
618                    fclose(helpfp);
619                    aww->get_root()->awar(AWAR_HELPFILE)->write_string(helpfilename); // display results in aws
620                }
621                free(result);
622                GBS_write_hash(searchHash, searchtext, (long)strdup(helpfilename));
623            }
624        }
625        free(helpfilename);
626    }
627
628    if (error) aw_message(error);
629
630    free(searchtext);
631}
632
633void AW_help_popup(UNFIXED, const char *help_file) {
634    static AW_window_simple *aws = 0;
635
636    AW_root *awr = AW_root::SINGLETON;
637
638    if (!aws) {
639        awr->awar_string(AWAR_HELPTEXT,   "", AW_ROOT_DEFAULT);
640        awr->awar_string(AWAR_HELPSEARCH, "", AW_ROOT_DEFAULT);
641        awr->awar_string(AWAR_HELPFILE,   "", AW_ROOT_DEFAULT);
642        awr->awar(AWAR_HELPFILE)->add_callback(aw_help_helpfile_changed_cb);
643
644        aws = new AW_window_simple;
645        aws->init(awr, "HELP", "HELP WINDOW");
646        aws->load_xfig("help.fig");
647
648        aws->button_length(9);
649        aws->auto_space(5, 5);
650
651        aws->at("close");
652        aws->callback(AW_POPDOWN);
653        aws->create_button("CLOSE", "CLOSE", "C");
654
655        aws->callback(aw_help_back);
656        aws->create_button("BACK", "BACK", "B");
657
658        aws->callback(aw_help_history);
659        aws->create_button("HISTORY", "HISTORY", "H");
660
661        aws->at("expression");
662#if defined(ARB_MOTIF)
663        aws->d_callback(makeWindowCallback(aw_help_search)); // enable ENTER in searchfield to start search
664#endif
665        aws->create_input_field(AWAR_HELPSEARCH, 40);
666        aws->callback(aw_help_search);
667#if defined(ARB_GTK)
668        aws->highlight(); // enable ENTER to start search
669#endif
670        aws->create_button("SEARCH", "SEARCH", "S");
671
672        aws->at("browse");
673        aws->callback(aw_help_browse);
674        aws->create_button("BROWSE", "BROWSE", "B");
675
676        aws->callback(aw_help_edit_help);
677        aws->create_button("EDIT", "EDIT", "E");
678
679        aws->at("super");
680        HELP.uplinks = aws->create_selection_list(AWAR_HELPFILE, false);
681        HELP.uplinks->insert_default("   ", "");
682        HELP.uplinks->update();
683
684        aws->at("sub");
685        HELP.links = aws->create_selection_list(AWAR_HELPFILE, false);
686        HELP.links->insert_default("   ", "");
687        HELP.links->update();
688        HELP.history = 0;
689
690        aws->at("text");
691        aws->create_text_field(AWAR_HELPTEXT, 3, 3);
692
693#if defined(TRACK_HELPFILE)
694        awr->add_timed_callback(TRACK_FREQUENCY, makeTimedCallback(autorefresh_helpfile));
695#endif
696    }
697
698    aw_assert(help_file);
699
700    awr->awar(AWAR_HELPFILE)->write_string(help_file);
701
702    if (!GBS_string_matches(help_file, "*.ps", GB_IGNORE_CASE) &&
703        !GBS_string_matches(help_file, "*.pdf", GB_IGNORE_CASE))
704    { // don't open help if postscript or pdf file
705        aws->activate();
706    }
707}
708
709
710
Note: See TracBrowser for help on using the repository browser.