Beispiel #1
0
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;
  }
}
Beispiel #2
0
int
main(int argc, char **argv)
{
    int ret_status;

    /* Initialize some global values */
/*    fprintf(stderr,"hyper:main:entered\n");*/
    gArgc = argc;
    gArgv = argv;
    gIsEndOfOutput = 1;

/*    fprintf(stderr,"hyper:main:calling  check_arguments\n");*/
    check_arguments();
/*    fprintf(stderr,"hyper:main:returned check_arguments\n");*/

    /*
     * initialize the hash tables for the files and the windows and images
     */
/*    fprintf(stderr,"hyper:main:calling  init_hash\n");*/
    init_hash();
/*    fprintf(stderr,"hyper:main:returned init_hash\n");*/

    /*
     * initialize the parser keyword hash table
     */
/*    fprintf(stderr,"hyper:main:calling  parser_init\n");*/
    parser_init();
/*    fprintf(stderr,"hyper:main:returned parser_init\n");*/

/*    fprintf(stderr,"hyper:main:calling  read_ht_db\n");*/
    read_ht_db(&init_page_hash, &init_macro_hash, &init_patch_hash);
/*    fprintf(stderr,"hyper:main:returned read_ht_db\n");*/

    /*
     * Now initialize x. This includes opening the display, setting the
     * screen and display global values, and also gets all the fonts and
     * colors we will need.
     */

    if (!make_input_file && !gmake_record_file && !gverify_record_file) {
/*        fprintf(stderr,"hyper:main:calling  initializeWindowSystem\n");*/
        initializeWindowSystem();
/*        fprintf(stderr,"hyper:main:returned initializeWindowSystem\n");*/

        /*
         * Initialize some of the global values used by the input string
         * routines
         */
/*        fprintf(stderr,"hyper:main:calling  init_keyin\n");*/
        init_keyin();
/*        fprintf(stderr,"hyper:main:returned init_keyin\n");*/

        /*
         * regardless of what else happened, we should always pop up an
         * initial window.
         */

/*        fprintf(stderr,"hyper:main:calling  init_top_window\n");*/
        ret_status = init_top_window("RootPage");
/*        fprintf(stderr,"hyper:main:returned init_top_window\n");*/
        gParentWindow = gWindow;
        if (ret_status == -1) {
            fprintf(stderr,
               "(HyperDoc) Could not find RootPage for top-level window.\n");
            exit(-1);
        }

        /*
         * Tell it how to handle the user defined signals I may get
         */
        bsdSignal(SIGUSR2, sigusr2_handler,RestartSystemCalls);
        bsdSignal(SIGUSR1, SIG_IGN,RestartSystemCalls);
#if defined(BSDplatform) || defined(MACOSXplatform)
        bsdSignal(SIGCHLD, sigcld_handler,RestartSystemCalls);
#else
        bsdSignal(SIGCLD, sigcld_handler,RestartSystemCalls);
#endif
        bsdSignal(SIGINT, SIG_IGN,RestartSystemCalls);

        /*
         * Now go to the main event loop. I will never return, so just end
         * the main routine after that
         */

        /*
         * make an input file if requested
         */
    }
    else {

        /*
         * Try to establish all the socket connections I need. If I am an
         * is_fricas_server and the routine fails, it will exit for me
         */
/*        fprintf(stderr,"hyper:main:in else case\n");*/
/*        fprintf(stderr,"hyper:main:calling  make_server_connections\n");*/
        make_server_connections();
/*        fprintf(stderr,"hyper:main:returned make_server_connections\n");*/


        if (make_input_file) ht2_input();
        if (gmake_record_file) make_record();
        if (gverify_record_file) verify_record();
        exit(0);
    }

    /*
     * Try to establish all the socket connections I need. If I am an
     * is_fricas_server and the routine fails, it will exit for me
     */
/*    fprintf(stderr,"hyper:main:calling  make_server_connections\n");*/
    make_server_connections();
/*    fprintf(stderr,"hyper:main:returned make_server_connections\n");*/


/*    fprintf(stderr,"hyper:main:calling  mainEventLoop\n");*/
    mainEventLoop();
/*    fprintf(stderr,"hyper:main:returned mainEventLoop\n");*/

    return 0;
}