/* Load a help topic if it isn't already available */ void helploadtopic(char* topic) { helploadmetafile(); /* Make sure the metafile is loaded */ if (findsection(&helplist, topic) == NULL) { stringvector file = helploadfile(topic); if (file.first == NULL) { /* Try loading from the data directory */ char* fullname = fullpath(helpdatapath, topic, SLASH_DEFAULT); file = helploadfile(fullname); free(fullname); } if (file.first == NULL) { /* Try loading from the docs subdirectory */ char* midname = fullpath("docs", topic, SLASH_DEFAULT); char* fullname = fullpath(helpdatapath, midname, SLASH_DEFAULT); file = helploadfile(fullname); free(midname); free(fullname); } /* If we loaded it, add to the list */ if (file.first != NULL) { helpsection* section = (helpsection*) malloc(sizeof(helpsection)); inithelpsection(section); section->title = str_dup(topic); section->sv = file; appendsection(&helplist, section); } } }
int isname(pchar section,pchar name) { int result = 0; trim(section); current = findsection(section); if(current) { if(getvalue(name)) result =1; } return result; }
void help(displaymethod* d) { helploadmetafile(); /* Load the metafile if it hasn't already been loaded */ if (findsection(&helplist, "index") != NULL) { helpsectiontopic("index", NULL, d); } else { stringvector aboutdialog; initstringvector(&aboutdialog); pushstring(&aboutdialog, str_dup("@About KevEdit")); pushstring(&aboutdialog, str_dup("$KevEdit Version " PACKAGE_VERSION)); pushstring(&aboutdialog, str_dup("Copyright (C) 2000-2005 Kev Vance, et al.")); pushstring(&aboutdialog, str_dup("Distribute under the terms of the GNU GPL")); editbox("", &aboutdialog, 0, EDITBOX_ZOCMODE | EDITBOX_MOVEMENT, d); deletestringvector(&aboutdialog); } }
int helpsectiontopic(char* sectiontitle, char* topic, displaymethod* d) { helpsection* sectionnode; stringvector section; helploadtopic(sectiontitle); sectionnode = findsection(&helplist, sectiontitle); if (sectionnode != NULL) { /* Grab the section svector from the section node and use it */ section = sectionnode->sv; if (section.first != NULL) { section.cur = section.first; return helptopic(section, topic, d); } } return 1; }