void runhelp (char *name) { register r, c, w, h; BOX *box; register struct helptab *p; struct help *hp; hp = findhelp (name); if (! hp) return; p = hp->htab; if (! p->str) inithelp (hp); w = 72; h = 21; r = 2; c = 4; box = VGetBox (r, c-1, h, w+2); /* save box */ VStandOut (); VSetDim (); VFillBox (r, c-1, h, w+2, ' '); /* clear */ VDrawBox (r, c, h, w); /* draw margins */ VMPutString (r, c + (w-6) / 2, " Help "); /* head */ for (; p->row; ++p) { if (p->row >= h) continue; if (p->bold) { VSetBold (); VStandEnd (); } if (! p->col) VMPutString (r+p->row, c + (w-strlen(p->str))/2, p->str); else VMPutString (r+p->row, c + p->col, p->str); if (p->bold) { VSetDim (); VStandOut (); } } VStandEnd (); VSetNormal (); for (;;) { hidecursor (); VSync (); switch (KeyGet ()) { default: break; case cntrl (']'): /* redraw screen */ VRedraw (); continue; } break; } VUngetBox (box); VFreeBox (box); }
E remove(const Key& k) { E temp = findhelp(root, k); if (temp != NULL) { if (removehelp(root, k) && (root->numrecs() == 1)) // Collapse root if (!root->isLeaf()) root = ((BPInternal<Key,E>*)root)->pointers(0); reccount--; } return temp; }
E BPTree<Key, E>::findhelp(BPNode<Key,E>* rt, const Key k) const { int currec = binaryle(rt->keys(), rt->numrecs(), k); if (rt->isLeaf()) if ((((BPLeaf<Key,E>*)rt)->keys())[currec] == k) return ((BPLeaf<Key,E>*)rt)->recs(currec); else return NULL; else return findhelp(((BPInternal<Key,E>*)rt)-> pointers(currec), k); }
void dohelp(bc *bc, char *p) { help *h; if(!*p) listhelp(bc, p); else { h=findhelp(p); if(h && h->name) tprintf(bc, "\n%s:\n\n%s\n", p, h->info); else tprintf(bc, "No help available on '%s'\n", p); } }
E find(const Key& k) const { return findhelp(root, k); }
static int do_showhelp( char **helptopic, char *filename, EVENT (*rtn)( EVENT ), bool first ) { int err; char *ptr; unsigned len; char *htopic; eventMapFn = rtn; helpTab = NULL; helpCur = helpTab; strcpy( curFile, filename ); helpInBuf = HelpMemAlloc( BUF_LEN ); if( helpInBuf == NULL ) { HelpMemFree( helpStack ); return( HELP_NO_MEM ); } helpOutBuf = HelpMemAlloc( BUF_LEN ); if( helpOutBuf == NULL ) { HelpMemFree( helpStack ); return( HELP_NO_MEM ); } // don't fix hyperlink topics if( *helptopic != NULL && first ) { htopic = fixHelpTopic( *helptopic ); } else if( *helptopic == NULL ) { len = 1; htopic = HelpMemAlloc( len ); htopic[0] = '\0'; } else { len = strlen( *helptopic ); htopic = HelpMemAlloc( len + 1 ); strcpy( htopic, *helptopic ); } nexttopic( htopic ); for( ;; ) { err = findhelp( &tabFilter ); if( err != HELP_OK ) break; if( curEvent == EV_ESCAPE ) break; if( curEvent == EV_KILL_UI ) { break; } } SearchDlgFini(); help_close(); // This is Not Nice - we're freeing memory that // someone else allocated! Just don't do it. if( err != HELP_NO_SUBJECT ) { if( *helptopic != NULL ) { HelpMemFree( *helptopic ); *helptopic = NULL; } *filename = '\0'; } HelpMemFree( helpInBuf ); HelpMemFree( helpOutBuf ); HelpMemFree( htopic ); if( helpTab != NULL && helpCur->key2_len != 0 ) { // cross file link len = helpCur->key1_len; *helptopic = ptr = HelpMemAlloc( len + 1 ); strncpy( ptr, helpCur->keyword, len ); ptr[len] = '\0'; ptr = helpCur->keyword + len; len = helpCur->key2_len; strncpy( filename, ptr, len ); filename[len] = '\0'; if( helpCur != tabFilter.curr ) { // backwards through cross file link prevtopic(); } } else { Free_Stack(); } free_fields( &helpTab ); return( err ); }