PUBLIC void HText_refresh (HText * text) { if (text && text->stale) display_page(text, text->top_of_screen); }
/* Scroll actions */ PUBLIC void HText_scrollTop (HText * text) { display_page(text, 0); }
static void handle_event(XEvent * event) { XWindowAttributes wa; /* fprintf(stderr,"event:handle_event entered\n");*/ set_window(event->xany.window); if (event->type == MotionNotify) { /* fprintf(stderr,"event:handle_event type=MotionNotify\n");*/ handle_motion_event((XMotionEvent *)event); motion = 1; return; } make_busy_cursors(); switch (event->type) { case DestroyNotify: /* fprintf(stderr,"event:handle_event type=DestroyNotify\n");*/ break; case Expose: /* fprintf(stderr,"event:handle_event type=Expose\n");*/ XGetWindowAttributes(gXDisplay, gWindow->fMainWindow, &wa); if ((gWindow->width == 0 && gWindow->height == 0) || (wa.width != gWindow->width || wa.height != gWindow->height)) { gWindow->width = wa.width; gWindow->height = wa.height; display_page(gWindow->page); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; } else /** just redraw the thing **/ expose_page(gWindow->page); XFlush(gXDisplay); clear_exposures(gWindow->fMainWindow); clear_exposures(gWindow->fScrollWindow); break; case ButtonPress: /* fprintf(stderr,"event:handle_event type=ButtonPress\n");*/ handle_button(event->xbutton.button, (XButtonEvent *)event); XFlush(gXDisplay); if (gWindow) { while (XCheckTypedWindowEvent(gXDisplay, gWindow->fMainWindow, Expose, event)); while (XCheckTypedWindowEvent(gXDisplay, gWindow->fScrollWindow, Expose, event)); } break; case KeyPress: /* fprintf(stderr,"event:handle_event type=KeyPress\n");*/ handle_key(event); if (gWindow) { while (XCheckTypedWindowEvent(gXDisplay, gWindow->fMainWindow, Expose, event)); while (XCheckTypedWindowEvent(gXDisplay, gWindow->fScrollWindow, Expose, event)); } break; case MapNotify: /* fprintf(stderr,"event:handle_event type=MapNotify\n");*/ create_window(); break; case SelectionNotify: /* fprintf(stderr,"event:handle_event type=SelectionNotify\n");*/ /* this is in response to a previous request in an input area */ if ( gSavedInputAreaLink ) { XSelectionEvent *pSelEvent; Atom dataProperty; pSelEvent = (XSelectionEvent *) event; dataProperty = XInternAtom(gXDisplay, "PASTE_SELECTION", False); /* change the input focus */ /* change_input_focus(gSavedInputAreaLink); */ /* try to get the selection as a window property */ if ( pSelEvent->requestor == gWindow->fMainWindow && pSelEvent->selection == XA_PRIMARY && /* pSelEvent->time == CurrentTime && */ pSelEvent->target == XA_STRING && pSelEvent->property == dataProperty ) { Atom actual_type; int actual_format; unsigned long nitems, leftover; char *pSelection = NULL; if (Success == XGetWindowProperty(gXDisplay, gWindow->fMainWindow, pSelEvent->property, 0L, 100000000L, True, AnyPropertyType, &actual_type, &actual_format, &nitems, &leftover, (unsigned char **) &pSelection) ) { char *pBuffer; InputItem *item = gSavedInputAreaLink->reference.string; for (pBuffer = pSelection; *pBuffer; ++pBuffer) add_buffer_to_sym(pBuffer, item); XFree(pSelection); } } /* clear the link info */ gSavedInputAreaLink = NULL; } break; default: /* fprintf(stderr,"event:handle_event type=default\n");*/ break; } }
void get_new_window() { int val; char buf[128]; int frame; Window wid; HDWindow *htw; HyperDocPage *hpage; /* * If I am going to try and start a new window, then I should make sure I * have a coonection to listen on * * BUT This code is entered when a socket selects * * if (spad_socket == NULL) { spad_socket = * connect_to_local_server(SpadServer, MenuServer, 10); if (spad_socket * == NULL) { fprintf(stderr, "Get_new_window: Couldn't Connect to * SpadServer\n"); return -1; } } * */ frame = get_int(spad_socket); val = get_int(spad_socket); switch (val) { case StartPage: init_top_window(NULL); val = get_int(spad_socket); init_scanner(); input_type = SourceInputKind::SpadSocket; input_string = ""; gWindow->page = parse_page_from_socket(); gWindow->fAxiomFrame = frame; XFlush(gXDisplay); break; case LinkToPage: get_string_buf(spad_socket, buf, 128); if (init_top_window(buf) == -1) { fprintf(stderr, "get_new_window: Did not find page %s\n", buf); /* return -1; */ } gWindow->fAxiomFrame = frame; break; case PopUpPage: val = get_int(spad_socket); init_form_window(NULL, val); send_int(spad_socket, gWindow->fMainWindow); init_scanner(); input_type = SourceInputKind::SpadSocket; input_string = ""; gWindow->page = parse_page_from_socket(); compute_form_page(gWindow->page); XMapWindow(gXDisplay, gWindow->fMainWindow); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; gWindow->fAxiomFrame = frame; XFlush(gXDisplay); break; case PopUpNamedPage: val = get_int(spad_socket); get_string_buf(spad_socket, buf, 128); if (init_form_window(buf, val) == -1) { send_int(spad_socket, -1); break; } load_page(gWindow->page); compute_form_page(gWindow->page); XMapWindow(gXDisplay, gWindow->fMainWindow); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; gWindow->fAxiomFrame = frame; XFlush(gXDisplay); send_int(spad_socket, gWindow->fMainWindow); /* fprintf(stderr, "Window Id was %d\n", gWindow->fMainWindow); */ break; case ReplaceNamedPage: wid = (Window) get_int(spad_socket); get_string_buf(spad_socket, buf, 128); htw = (HDWindow *) hash_find(&gSessionHashTable,(char *)&wid); if (htw == NULL) break; hpage = (HyperDocPage *) hash_find(gWindow->fPageHashTable, buf); if (hpage == NULL) break; gWindow = htw; gWindow->page = hpage; display_page(gWindow->page); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; clear_exposures(gWindow->fMainWindow); clear_exposures(gWindow->fScrollWindow); XFlush(gXDisplay); break; case ReplacePage: wid = (Window) get_int(spad_socket); set_window(wid); init_scanner(); input_type = SourceInputKind::SpadSocket; input_string = ""; gWindow->page = parse_page_from_socket(); display_page(gWindow->page); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; clear_exposures(gWindow->fMainWindow); clear_exposures(gWindow->fScrollWindow); XFlush(gXDisplay); break; case KillPage: /* Here the user wishes to kill the page */ wid = (Window) get_int(spad_socket); htw = (HDWindow *) hash_find(&gSessionHashTable,(char *)&wid); if (htw !=NULL) { gWindow = htw; exitHyperDoc(); break; } break; } }
static void handle_button(int button, XButtonEvent * event) { HyperLink *link; HyperDocPage *page = NULL; char *page_name; /* find page name from sub-window handle */ link = get_hyper_link(event); if (link == NULL) { /* user clicked on an inactive area */ /* BeepAtTheUser(); */ /* I always thought this was annoying. RSS */ return; } switch (link->type) { case openaxiom_Pastebutton_token: page = paste_button(link->reference.paste); break; case openaxiom_Link_token: page_name = print_to_string(link->reference.node); page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, page_name); break; case openaxiom_Helpbutton_token: helpForHyperDoc(); page = NULL; break; case openaxiom_Scrollbar_token: scrollScroller(event); break; case Scrollupbutton: scrollUp(); break; case Scrolldownbutton: scrollDown(); break; case openaxiom_Inputstring_token: /* We must be changing input focus or getting a selection */ change_input_focus(link); if ( button == Button2 ) { XConvertSelection(gXDisplay, XA_PRIMARY, XA_STRING, XInternAtom(gXDisplay, "PASTE_SELECTION", False), gWindow->fMainWindow, CurrentTime); gSavedInputAreaLink = link; } break; case openaxiom_SimpleBox_token: page = NULL; toggle_input_box(link); break; case openaxiom_Radiobox_token: page = NULL; toggle_radio_box(link); break; case openaxiom_Quitbutton_token: quitHyperDoc(); break; case openaxiom_Returnbutton_token: /* pop memo information */ page = returnlink(); break; case openaxiom_Upbutton_token: /* pop downlink information */ page = uplink(); break; case openaxiom_Downlink_token: page = find_page(link->reference.node); if (page && NotSpecial(page->type)) downlink(); break; case openaxiom_Memolink_token: page = find_page(link->reference.node); if (page && NotSpecial(page->type)) memolink(); break; case openaxiom_Windowlink_token: page = find_page(link->reference.node); if (page && NotSpecial(page->type)) { windowlink_handler(link->reference.node); gNeedIconName = 1; page = NULL; } break; case openaxiom_Lispwindowlink_token: lispwindowlink_handler(link); gNeedIconName = 1; page = NULL; break; case openaxiom_LispMemoLink_token: case openaxiom_Spadmemolink_token: page = issue_server_command(link); if (page && NotSpecial(page->type)) memolink(); break; case openaxiom_LispDownLink_token: case openaxiom_Spaddownlink_token: page = issue_server_command(link); if (page && NotSpecial(page->type)) downlink(); break; case openaxiom_Spadlink_token: case openaxiom_Lisplink_token: page = issue_server_command(link); break; case openaxiom_Lispcommand_token: case openaxiom_Qspadcall_token: case openaxiom_Spadcall_token: page = issue_server_command(link); break; case openaxiom_Lispcommandquit_token: case openaxiom_Spadcallquit_token: case openaxiom_Qspadcallquit_token: page = issue_server_command(link); exitHyperDoc(); break; case openaxiom_Spadcommand_token: case openaxiom_Spadgraph_token: case openaxiom_Spadsrc_token: issue_spadcommand(gWindow->page, link->reference.node, button == Button1, link->type); break; case openaxiom_Unixlink_token: page = issue_unixlink(link->reference.node); if (page && NotSpecial(page->type)) { downlink(); } break; case openaxiom_Unixcommand_token: issue_unixcommand(link->reference.node); break; default: break; } if (page) { switch (page->type) { /* check for special button types */ case openaxiom_Quitbutton_token: exitHyperDoc(); return; case openaxiom_Returnbutton_token: gWindow->page = returnlink(); break; case openaxiom_Upbutton_token: gWindow->page = uplink(); break; case ErrorPage: case UnknownPage: case UlUnknownPage: if (page->type == UlUnknownPage) page->type = UnloadedPageType; downlink(); gWindow->page = page; break; default: /* a normal link */ gWindow->page = page; break; } if (link->type != openaxiom_Pastebutton_token) display_page(gWindow->page); gWindow->fWindowHashTable = gWindow->page->fLinkHashTable; /* reset the window hash */ } }
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; } }
int help(int action) { static FCODE unknowntopic_msg[] = "Unknown Help Topic"; HIST curr; int oldlookatmouse; int oldhelpmode; int flags; HIST next; if (helpmode == -1) /* is help disabled? */ { return (0); } if (help_file == -1) { buzzer(2); return (0); } buffer = (char far *)farmemalloc((long)MAX_PAGE_SIZE + sizeof(LINK)*max_links + sizeof(PAGE)*max_pages); if (buffer == NULL) { buzzer(2); return (0); } link_table = (LINK far *)(&buffer[MAX_PAGE_SIZE]); page_table = (PAGE far *)(&link_table[max_links]); oldlookatmouse = lookatmouse; lookatmouse = 0; timer_start -= clock_ticks(); stackscreen(); if (helpmode >= 0) { next.topic_num = label[helpmode].topic_num; next.topic_off = label[helpmode].topic_off; } else { next.topic_num = helpmode; next.topic_off = 0; } oldhelpmode = helpmode; if (curr_hist <= 0) action = ACTION_CALL; /* make sure it isn't ACTION_PREV! */ do { switch(action) { case ACTION_PREV2: if (curr_hist > 0) curr = hist[--curr_hist]; /* fall-through */ case ACTION_PREV: if (curr_hist > 0) curr = hist[--curr_hist]; break; case ACTION_QUIT: break; case ACTION_INDEX: next.topic_num = label[HELP_INDEX].topic_num; next.topic_off = label[HELP_INDEX].topic_off; /* fall-through */ case ACTION_CALL: curr = next; curr.link = 0; break; } /* switch */ flags = 0; if (curr.topic_num == label[HELP_INDEX].topic_num) flags |= F_INDEX; if (curr_hist > 0) flags |= F_HIST; if ( curr.topic_num >= 0 ) action = help_topic(&curr, &next, flags); else { if ( curr.topic_num == -100 ) { print_document("FRACTINT.DOC", print_doc_msg_func, 1); action = ACTION_PREV2; } else if ( curr.topic_num == -101 ) action = ACTION_PREV2; else { display_page(unknowntopic_msg, NULL, 0, 0, 1, 0, NULL, NULL); action = -1; while (action == -1) { switch (getakey()) { case ESC: action = ACTION_QUIT; break; case ALT_F1: action = ACTION_PREV; break; case F1: action = ACTION_INDEX; break; } /* switch */ } /* while */ } } /* else */ if ( action != ACTION_PREV && action != ACTION_PREV2 ) { if (curr_hist >= MAX_HIST) { int ctr; for (ctr=0; ctr<MAX_HIST-1; ctr++) hist[ctr] = hist[ctr+1]; curr_hist = MAX_HIST-1; } hist[curr_hist++] = curr; } } while (action != ACTION_QUIT); farmemfree((BYTE far *)buffer); unstackscreen(); lookatmouse = oldlookatmouse; helpmode = oldhelpmode; timer_start += clock_ticks(); return(0); }
static int help_topic(HIST *curr, HIST *next, int flags) { int len; int key; int num_pages; int num_link; int page; int curr_link; char title[81]; long where; int draw_page; int action; BYTE ch; int dummy; /* to quiet compiler */ where = topic_offset[curr->topic_num]+sizeof(int); /* to skip flags */ curr_link = curr->link; help_seek(where); dummy = read(help_file, (char *)&num_pages, sizeof(int)); assert(num_pages>0 && num_pages<=max_pages); farread(help_file, (char far *)page_table, 3*sizeof(int)*num_pages); dummy = read(help_file, &ch, 1); len = ch; assert(len<81); dummy = read(help_file, (char *)title, len); title[len] = '\0'; where += sizeof(int) + num_pages*3*sizeof(int) + 1 + len + sizeof(int); for(page=0; page<num_pages; page++) if (curr->topic_off >= page_table[page].offset && curr->topic_off < page_table[page].offset+page_table[page].len ) break; assert(page < num_pages); action = -1; draw_page = 2; do { if (draw_page) { help_seek(where+page_table[page].offset); farread(help_file, buffer, page_table[page].len); num_link = 0; display_page(title, buffer, page_table[page].len, page, num_pages, page_table[page].margin, &num_link, link_table); if (draw_page==2) { assert(num_link<=0 || (curr_link>=0 && curr_link<num_link)); } else if (draw_page==3) curr_link = num_link - 1; else curr_link = 0; if (num_link > 0) color_link(&link_table[curr_link], C_HELP_CURLINK); draw_page = 0; } key = getakey(); switch(key) { case PAGE_DOWN: if (page<num_pages-1) { page++; draw_page = 1; } break; case PAGE_UP: if (page>0) { page--; draw_page = 1; } break; case HOME: if ( page != 0 ) { page = 0; draw_page = 1; } else do_move_link(link_table, num_link, &curr_link, NULL, 0); break; case END: if ( page != num_pages-1 ) { page = num_pages-1; draw_page = 3; } else do_move_link(link_table, num_link, &curr_link, NULL, num_link-1); break; case TAB: if ( !do_move_link(link_table, num_link, &curr_link, find_link_key, key) && page<num_pages-1 ) { ++page; draw_page = 1; } break; case BACK_TAB: if ( !do_move_link(link_table, num_link, &curr_link, find_link_key, key) && page>0 ) { --page; draw_page = 3; } break; case DOWN_ARROW: if ( !do_move_link(link_table, num_link, &curr_link, find_link_updown, 0) && page<num_pages-1 ) { ++page; draw_page = 1; } break; case UP_ARROW: if ( !do_move_link(link_table, num_link, &curr_link, find_link_updown, 1) && page>0 ) { --page; draw_page = 3; } break; case LEFT_ARROW: do_move_link(link_table, num_link, &curr_link, find_link_leftright, 1); break; case RIGHT_ARROW: do_move_link(link_table, num_link, &curr_link, find_link_leftright, 0); break; case ESC: /* exit help */ action = ACTION_QUIT; break; case BACKSPACE: /* prev topic */ case ALT_F1: if (flags & F_HIST) action = ACTION_PREV; break; case F1: /* help index */ if (!(flags & F_INDEX)) action = ACTION_INDEX; break; case ENTER: case ENTER_2: if (num_link > 0) { next->topic_num = link_table[curr_link].topic_num; next->topic_off = link_table[curr_link].topic_off; action = ACTION_CALL; } break; } /* switch */ } while ( action == -1 ); curr->topic_off = page_table[page].offset; curr->link = curr_link; return (action); }
void lcd_display_complete_handle(void) { analyse_display_data(); g_lcdMultiPage.page_num++; display_page(0); }