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"
44 freeset(browser, new_browser);
68 size_t user_doc_path_len = strlen(user_doc_path);
69 size_t devel_doc_path_len = strlen(devel_doc_path);
71 const char *rel_path =
NULp;
72 if (strncmp(helpfile, user_doc_path, user_doc_path_len) == 0 && helpfile[user_doc_path_len] ==
'/') {
73 rel_path = helpfile+user_doc_path_len+1;
75 else if (strncmp(helpfile, devel_doc_path, devel_doc_path_len) == 0 && helpfile[devel_doc_path_len] ==
'/') {
77 rel_path = helpfile+devel_doc_path_len+1;
80 if (helpfile[0]==
'/' && !rel_path) {
84 if (!rel_path) rel_path = helpfile;
97 aw_assert(devel_size <= 0 || gen_size <= 0);
122 free(devel_doc_path);
124 return strdup(result);
138 size_t user_doc_path_len = strlen(user_doc_path);
141 if (strncmp(helpfile, user_doc_path, user_doc_path_len) == 0) {
143 size_t result_len = strlen(result);
147 if (strcmp(result+result_len-5,
".hlp_") == 0) {
148 strcpy(result+result_len-5,
".html");
165 static void store_helpfile_in_tarball(
const char *path,
const char *mode) {
174 error =
"Unexpected helpfile name (in store_helpfile_in_tarball)";
179 static void aw_helpfile_modified_cb(
const char *path) {
180 static enum { UNMODIFIED, MODIFIED, NOTIFIED } state = UNMODIFIED;
182 store_helpfile_in_tarball(path,
"end");
183 if (state == UNMODIFIED) state = MODIFIED;
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!");
215 store_helpfile_in_tarball(helpfile,
"start");
218 aw_message(
"Warning: you do not have the permission to save changes to that helpfile\n"
219 "(ask your admin to gain write access)");
222 AW_edit_notified(helpfile, makeFileChangedCallback(aw_helpfile_modified_cb));
231 if (!ref)
return NULp;
247 if (strcmp(file, result)==0) freenull(result);
255 result = strdup(ref);
264 const char *sep = strchr(history,
'#');
265 char *lastHelp = sep ?
ARB_strpartdup(history, sep-1) : strdup(history);
278 const char *sep = strchr(history,
'#');
296 if (entries.
size()) {
303 HELP.uplinks->clear();
306 for (
size_t i = 0; i<entries.
size(); ++i) {
308 HELP.links->insert(title, entries[i]);
312 HELP.uplinks->insert_default(
" ",
"");
HELP.uplinks->update();
313 HELP.links ->insert_default(
" ",
"");
HELP.links ->update();
333 if (stat(help_file, &st) == 0) {
339 if (stat(compressed, &st) == 0) {
350 "(gunzip <%s >%s ; %s %s ; rm %s) &",
351 compressed, uncompressed,
352 viewer, uncompressed,
367 if (sys[0] && !error) error =
GBK_system(sys);
373 # define TRACK_HELPFILE
377 #if defined(TRACK_HELPFILE)
380 static bool track_helpfile =
false;
381 static unsigned long helpfile_stamp = 0;
382 static unsigned long helpfile_edited_stamp = 0;
384 const unsigned TRACK_FREQUENCY = 500;
386 static unsigned autorefresh_helpfile(
AW_root *awr) {
388 unsigned callAgainIn = TRACK_FREQUENCY;
393 if (lastChanged != helpfile_stamp) {
395 aw_assert(helpfile_stamp == lastChanged);
397 #if defined(AUTOBUILD_CHANGED_HELPFILE)
400 if (strcmp(help_file, edited_help_file) != 0) {
403 if (editLastChanged>helpfile_edited_stamp) {
406 helpfile_edited_stamp = editLastChanged;
411 free(edited_help_file);
425 #if defined(TRACK_HELPFILE)
426 track_helpfile =
false;
429 if (!strlen(help_file)) {
431 "press the BACK button above.");
445 if (strncmp(help_file,
HELP.history, strlen(help_file)) != 0) {
451 freeset(
HELP.history, h);
456 HELP.history = strdup(help_file);
459 #if defined(TRACK_HELPFILE)
460 track_helpfile =
true;
469 ptr = strdup(helptext);
470 HELP.uplinks->clear();
474 tok = strtok(h+3,
" \n\t");
476 if (tok)
HELP.uplinks->insert(title, tok);
480 HELP.uplinks->insert_default(
" ",
"");
481 HELP.uplinks->update();
483 ptr = strdup(helptext);
488 tok = strtok(h+4,
" \n\t");
490 if (tok)
HELP.links->insert(title, tok);
494 HELP.links->insert_default(
" ",
"");
495 HELP.links->update();
498 if (!ptr) ptr = helptext;
507 "Please help us to complete the ARB-Help by submitting\n"
508 "this missing helplink via ARB_NT/File/About/SubmitBug\n"
536 if (searchtext[0]==0) error =
"Empty searchstring";
538 char *helpfilename =
NULp;
539 static char *last_help;
549 const char *existingSearch = (
const char*)
GBS_read_hash(searchHash, searchtext);
550 if (existingSearch) {
551 helpfilename = strdup(existingSearch);
563 const char *gen_help_tmpl =
"cd %s;grep -i %s `find . -name \"*.hlp\"` | arb_sed -e 'sI:.*IIg' -e 'sI^\\./IIg' | sort | uniq > %s";
564 char *gen_help_cmd =
GBS_global_string_copy(gen_help_tmpl, quotedDocpath, quotedSearchExpression, helpfilename);
570 free(quotedSearchExpression);
581 FILE *helpfp = fopen(helpfilename,
"wt");
584 fprintf(helpfp,
"\nUP arb.hlp\n");
585 if (last_help) fprintf(helpfp,
"UP %s\n", last_help);
591 char *
eol = strchr(rp,
'\n');
599 fprintf(helpfp,
"SUB %s\n", rp);
603 if (eol[0]==0)
break;
607 fprintf(helpfp,
"\nTITLE\t\tResult of search for '%s'\n\n", searchtext);
608 if (results>0) fprintf(helpfp,
"\t\t%i results are shown as subtopics\n", results);
609 else fprintf(helpfp,
"\t\tThere are no results.\n");
611 if (results>0) freedup(last_help, helpfilename);
617 GBS_write_hash(searchHash, searchtext, (
long)strdup(helpfilename));
629 static AW_window_simple *aws =
NULp;
639 aws =
new AW_window_simple;
640 aws->init(awr,
"HELP",
"HELP WINDOW");
641 aws->load_xfig(
"help.fig");
643 aws->button_length(9);
644 aws->auto_space(5, 5);
648 aws->create_button(
"CLOSE",
"CLOSE",
"C");
651 aws->create_button(
"BACK",
"BACK",
"B");
654 aws->create_button(
"HISTORY",
"HISTORY",
"H");
656 aws->at(
"expression");
660 aws->create_button(
"SEARCH",
"SEARCH",
"S",
"+");
664 aws->create_button(
"BROWSE",
"BROWSE",
"B");
667 aws->create_button(
"EDIT",
"EDIT",
"E");
671 HELP.uplinks->insert_default(
" ",
"");
672 HELP.uplinks->update();
676 HELP.links->insert_default(
" ",
"");
677 HELP.links->update();
683 #if defined(TRACK_HELPFILE)
GB_ERROR GBK_system(const char *system_command)
static void aw_help_back(AW_window *aww)
void GB_remove_on_exit(const char *filename)
static void aw_help_helpfile_changed_cb(AW_root *awr)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
static GB_ERROR aw_help_show_external_format(const char *help_file, const char *viewer)
const char * GBS_global_string_to_buffer(char *buffer, size_t bufsize, const char *templat,...)
void AW_edit(const char *path)
static void aw_help_browse(AW_window *aww)
static const char * develDocPath()
static void aw_help_select_newest_in_history(AW_root *aw_root)
void AW_edit_notified(const char *path, const FileChangedCallback &callback)
GB_ERROR GB_export_IO_error(const char *action, const char *filename)
const char * GBS_global_string(const char *templat,...)
GB_HASH * GBS_create_dynaval_hash(long estimated_elements, GB_CASE case_sens, void(*freefun)(long))
char * GBS_string_eval(const char *insource, const char *icommand)
void AW_POPDOWN(AW_window *window)
void add_timed_callback(int ms, const TimedCallback &tcb)
char * ARB_strpartdup(const char *start, const char *end)
long GB_size_of_file(const char *path)
GB_CSTR GB_getenvARB_GS(void)
GB_CSTR GBS_find_string(GB_CSTR cont, GB_CSTR substr, int match_mode)
AW_awar * add_callback(const RootCallback &cb)
struct Unfixed_cb_parameter * UNFIXED
static HelixNrInfo * start
const char * read_char_pntr() const
GB_ERROR GB_export_error(const char *error)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
char * GB_create_tempfile(const char *name)
static char * get_local_help_url(AW_root *awr)
unsigned long GB_time_of_file(const char *path)
static void aw_help_search(AW_window *aww)
static void error(const char *msg)
GB_CSTR GB_path_in_ARBHOME(const char *relative_path)
GB_CSTR GB_getenvHTMLDOCPATH(void)
GB_CSTR GB_getenvDOCPATH(void)
static void aw_help_history(AW_window *aww)
void GBS_dynaval_free(long val)
char * read_string() const
AW_awar * awar(const char *awar)
AW_selection_list * links
bool GB_is_writeablefile(const char *filename)
static char * aw_ref_to_title(const char *ref)
char * GB_unique_filename(const char *name_prefix, const char *suffix)
char * GBK_singlequote(const char *arg)
bool GB_is_directory(const char *path)
GB_CSTR GB_getenvARB_PDFVIEW(void)
const char * GBS_static_string(const char *str)
void aw_message(const char *msg)
void GB_split_full_path(const char *fullpath, char **res_dir, char **res_fullname, char **res_name_only, char **res_suffix)
bool GB_is_regularfile(const char *path)
static void aw_help_edit_help(AW_window *aww)
void AW_help_popup(UNFIXED, const char *help_file)
GB_ERROR write_string(const char *aw_string)
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, SplitMode mode)
static char * get_full_qualified_help_file_name(const char *helpfile, bool path_for_edit=false)
bool ARB_strBeginsWith(const char *str, const char *with)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
bool GBS_string_matches(const char *str, const char *expr, GB_CASE case_sens)
void AW_openURL(AW_root *aw_root, const char *url)
long GBS_read_hash(const GB_HASH *hs, const char *key)
AW_selection_list * uplinks
void aw_message_if(GB_ERROR error)
char * GBS_global_string_copy(const char *templat,...)
char * GB_read_file(const char *path)