HDWindow * alloc_hd_window(void) { HDWindow *w = (HDWindow *) halloc(sizeof(HDWindow), "HDWindow"); /*char haslisp[10];*/ w->fMemoStack = (HyperDocPage **) halloc(MaxMemoDepth * sizeof(HyperDocPage *), "Memo Stack"); w->fDownLinkStack = (HyperDocPage **) halloc(MaxDownlinkDepth * sizeof(HyperDocPage *), "downlink stack"); w->fDownLinkStackTop = (int *) halloc(MaxDownlinkDepth * sizeof(int), "top downlink stack"); w->fricas_frame = 0; init_page_structs(w); /* Now I initialize the hash tables for the page */ w->fCondHashTable = (HashTable *) halloc(sizeof(HashTable), "cond hash"); hash_init( w->fCondHashTable, CondHashSize, (EqualFunction) string_equal, (HashcodeFunction) string_hash); w->fPasteHashTable = (HashTable *) halloc(sizeof(HashTable), "paste hash"); hash_init( w->fPasteHashTable, PasteHashSize, (EqualFunction) string_equal, (HashcodeFunction) string_hash); w->fPageHashTable = hash_copy_table(&init_page_hash); w->fPatchHashTable = hash_copy_table(&init_patch_hash); w->fMacroHashTable = hash_copy_table(&init_macro_hash); gWindow = w; /*sprintf(haslisp, "%1d\0", MenuServerOpened);*/ make_special_pages(w->fPageHashTable); w->fDisplayedCursor = 0; return w; }
void handle_key(XEvent *event) { char key_buffer[20]; int key_buffer_size = 20; KeySym keysym; XComposeStatus compstatus; int charcount; int display_again = 0; char *name; char *filename; /*char *head = "echo htadd -l ";*/ /*char *blank1 = " ";*/ /*char *blank2 = " \n";*/ char buffer[180]; FILE *filehandle; charcount = XLookupString((XKeyEvent *)event, key_buffer, key_buffer_size, &keysym ,&compstatus); /* 5 args */ key_buffer[charcount] = '\0'; switch (keysym) { case XK_Prior: case XK_F29: scrollUpPage(); break; case XK_Next: case XK_F35: scrollDownPage(); break; case XK_F3: case XK_F12: quitHyperDoc(); break; case XK_F5: if (event->xkey.state & ShiftMask) { name = gWindow->page->name; filename = gWindow->page->filename; sprintf(buffer, "htadd -l %s\n", filename); system(buffer); filehandle = (FILE *) hash_find(&gFileHashTable, filename); fclose(filehandle); hash_delete(&gFileHashTable, filename); gWindow->fMacroHashTable = (HashTable *) halloc(sizeof(HashTable), "macro hash"); hash_init( gWindow->fMacroHashTable, MacroHashSize, (EqualFunction ) string_equal, (HashcodeFunction) string_hash); gWindow->fPatchHashTable = (HashTable *) halloc(sizeof(HashTable), "patch hash"); hash_init( gWindow->fPatchHashTable, PatchHashSize, (EqualFunction ) string_equal, (HashcodeFunction) string_hash); gWindow->fPasteHashTable = (HashTable *) halloc(sizeof(HashTable), "paste hash"); hash_init(gWindow->fPasteHashTable, PasteHashSize, (EqualFunction ) string_equal, (HashcodeFunction) string_hash); gWindow->fCondHashTable = (HashTable *) halloc(sizeof(HashTable), "cond hash"); hash_init( gWindow->fCondHashTable, CondHashSize, (EqualFunction ) string_equal, (HashcodeFunction) string_hash); gWindow->fPageHashTable = (HashTable *) halloc(sizeof(HashTable), "page hash"); hash_init( gWindow->fPageHashTable, PageHashSize, (EqualFunction ) string_equal, (HashcodeFunction) string_hash); make_special_pages(gWindow->fPageHashTable); read_ht_db( gWindow->fPageHashTable, gWindow->fMacroHashTable, gWindow->fPatchHashTable); gWindow->page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, name); if (gWindow->page == NULL) { fprintf(stderr, "lose...gWindow->page for %s is null\n", name); exit(-1); } display_again = 1; } break; case XK_F9: make_window_link(KeyDefsHelpPage); break; case XK_Tab: if (event->xkey.state & ShiftMask) prev_input_focus(); else if (event->xkey.state & ModifiersMask) BeepAtTheUser(); else next_input_focus(); break; case XK_Return: if (!(event->xkey.state & ShiftMask)) { next_input_focus(); break; } /* next ones fall through to input area handling */ case XK_Escape: if (!gWindow->page->current_item) break; case XK_F1: if (!gWindow->page->current_item) { gWindow->page->helppage = alloc_string(NoMoreHelpPage); helpForHyperDoc(); break; } case XK_Home: if (!gWindow->page->current_item) { scrollToFirstPage(); break; } case XK_Up: if (!gWindow->page->current_item) { scrollUp(); break; } case XK_Down: if (!gWindow->page->current_item) { scrollDown(); break; } default: display_again = 0; dialog(event, keysym, key_buffer); XFlush(gXDisplay); break; } if (display_again) { display_page(gWindow->page); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; } }