📄 lymainloop.c
字号:
} else if (is_www_index && more) { char buf[128]; sprintf(buf, WWW_INDEX_MORE_MESSAGE, key_for_func(LYK_INDEX_SEARCH)); _statusline(buf); } else if (is_www_index) { char buf[128]; sprintf(buf, WWW_INDEX_MESSAGE, key_for_func(LYK_INDEX_SEARCH)); _statusline(buf); } else if (more) { if (user_mode == NOVICE_MODE) _statusline(MORE); else _statusline(MOREHELP); } else { _statusline(HELP); } } else { show_help = FALSE; } if (!(nlinks > 0 && links[curdoc.link].type == WWW_FORM_LINK_TYPE && (links[curdoc.link].form->type == F_TEXT_TYPE || links[curdoc.link].form->type == F_TEXTAREA_TYPE))) /* * Highlight current link. */ highlight(ON, curdoc.link, prev_target); if (traversal) { /* * Don't go interactively into forms, * or accept keystrokes from the user */ if (crawl && crawl_ok) { crawl_ok = FALSE;#ifdef FNAMES_8_3 sprintf(cfile,"lnk%05d.dat",ccount);#else sprintf(cfile,"lnk%08d.dat",ccount);#endif /* FNAMES_8_3 */ ccount = ccount + 1; if ((cfp = LYNewTxtFile(cfile)) != NULL) { print_crawl_to_fd(cfp,curdoc.address,curdoc.title); fclose(cfp); } else { if (!dump_output_immediately) cleanup();#ifdef UNIX if (dump_output_immediately) fprintf(stderr, "Fatal error - could not open output file %s\n",cfile); else#endif printf( "Fatal error - could not open output file %s\n",cfile); if (!dump_output_immediately) {#ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */ (void) signal(SIGTERM, SIG_DFL);#ifndef VMS (void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP if (no_suspend) (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */ exit(-1); } return(-1); } } } else { /* * Normal, non-traversal handling. */ if (nlinks > 0 && links[curdoc.link].type == WWW_FORM_LINK_TYPE && (links[curdoc.link].form->type == F_TEXT_TYPE || links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE || links[curdoc.link].form->type == F_PASSWORD_TYPE || links[curdoc.link].form->type == F_TEXTAREA_TYPE)) { /* * Replace novice lines if in NOVICE_MODE. */ if (user_mode==NOVICE_MODE) { move(LYlines-2,0); clrtoeol(); addstr(FORM_NOVICELINE_ONE); move(LYlines-1,0); clrtoeol(); addstr(FORM_NOVICELINE_TWO); } c = change_form_link(&links[curdoc.link], FORM_UP, &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); if (c == '\n' || c == '\r')#ifdef FASTTAB /* * Make return act like down-arrow. */ c = DNARROW;#else /* * Make return act like tab. */ c = '\t';#endif /* FASTTAB */ } else { /* * Get a keystroke from the user. * Save the last keystroke to avoid * redundant error reporting. */ real_c = c = LYgetch(); /* get user input */#ifndef VMS if (c == 3) { /* ^C */ /* * This shouldn't happen. We'll try to * deal with whatever bug caused it. - FM */ signal(SIGINT, cleanup_sig); old_c = 0; cmd = LYK_QUIT; goto new_cmd; }#endif /* !VMS */ if (old_c != real_c) { old_c = 0; } } }#ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; c = DO_NOTHING; }#else if (recent_sizechange) { if (c <= 0) c = DO_NOTHING; }#endif /* VMS */new_keyboard_input: /* * A goto point for new input without going * back through the getch() loop. */ if (traversal) { /* * This is a special feature to traverse every http link * derived from startfile and check for errors or create * crawl output files. Only URL's that begin with * "traversal_host" are searched - this keeps the search * from crossing to other servers (a feature, not a bug!). */ rlink_exists = (nlinks > 0 && links[curdoc.link].lname != NULL); if (rlink_exists) { rlink_allowed = (!lookup_reject(links[curdoc.link].lname) && traversal_host && links[curdoc.link].lname && !strncmp(traversal_host, (strncmp(links[curdoc.link].lname, "LYNXIMGMAP:", 11) ? links[curdoc.link].lname : (links[curdoc.link].lname + 11)), strlen(traversal_host))); } else { rlink_allowed = FALSE; } if (rlink_exists && rlink_allowed) { if (lookup(links[curdoc.link].lname)) { if (more_links || (curdoc.link > -1 && curdoc.link < nlinks -1)) c= DNARROW; else { if (STREQ(curdoc.title,"Entry into main screen") || (nhist <= 0 )) { if (!dump_output_immediately) { cleanup();#ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */ (void) signal(SIGTERM, SIG_DFL);#ifndef VMS (void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP if (no_suspend) (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */ exit(-1); } return(-1); } c = LTARROW; } } else { StrAllocCopy(traversal_link_to_add, links[curdoc.link].lname); if (strncmp(traversal_link_to_add, "LYNXIMGMAP:", 11)) crawl_ok = TRUE; c = RTARROW; } } else { /* no good right link, so only down and left arrow ok*/ if (rlink_exists) add_to_reject_list(links[curdoc.link].lname); if (more_links || (curdoc.link > -1 && curdoc.link < nlinks-1)) c = DNARROW; else { /* * curdoc.title doesn't always work, so * bail out if the history list is empty. */ if (STREQ(curdoc.title,"Entry into main screen") || (nhist <= 0 )) { if (!dump_output_immediately) { cleanup();#ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL);#endif /* NOSIGHUP */ (void) signal(SIGTERM, SIG_DFL);#ifndef VMS (void) signal(SIGINT, SIG_DFL);#endif /* !VMS */#ifdef SIGTSTP if (no_suspend) (void) signal(SIGTSTP,SIG_DFL);#endif /* SIGTSTP */ exit(-1); } return(-1); } c = LTARROW; } } /* right link not NULL or link to another site*/ } /* traversal */ cmd = keymap[c+1]; /* add 1 to map EOF to 0 */#if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) if (lynx_edit_mode && override[c+1] && !no_dired_support) cmd = override[c+1];#endif /* DIRED_SUPPORT && OK_OVERRIDE */ real_cmd = cmd;new_cmd: /* * A goto point for new input without going * back through the getch() loop. */ switch(cmd) { case 0: /* unmapped character */ default: if (more) _statusline(MOREHELP); else _statusline(HELP); show_help = TRUE; if (TRACE) { sprintf(cfile, "%d", c); addstr(cfile); /* show the user input */ cfile[0] = '\0'; } break; case LYK_INTERRUPT: /* * No network transmission to interrupt - 'til we multithread. */ break; case LYK_F_LINK_NUM: c = '\0'; case LYK_1: case LYK_2: case LYK_3: case LYK_4: case LYK_5: case LYK_6: case LYK_7: case LYK_8: case LYK_9: { /* * Get a number from the user and follow that link number. */ int lindx = ((nlinks > 0) ? curdoc.link : 0); int number; switch (follow_link_number(c, lindx, &newdoc, &number)) { case DO_LINK_STUFF: /* * Follow a normal link. */ StrAllocCopy(newdoc.address, links[lindx].lname); StrAllocCopy(newdoc.title, links[lindx].hightext);#ifndef DONT_TRACK_INTERNAL_LINKS /* * For internal links, retain POST content if present. * If we are on the List Page, prevent pushing it on * the history stack. Otherwise set try_internal to * signal that the top of the loop should attempt to * reposition directly, without calling getfile. - kw */ if (links[lindx].type == WWW_INTERN_LINK_TYPE) { LYinternal_flag = TRUE; newdoc.internal_link = TRUE; if (0==strcmp((curdoc.title ? curdoc.title : ""), LIST_PAGE_TITLE) && 0==strcmp(HTLoadedDocumentURL(), LYlist_temp_url())) { if (!curdoc.post_data || /* * Normal case - List Page is not associated * with post data. - kw */ (!LYresubmit_posts && curdoc.post_data && history[nhist - 1].post_data && !strcmp(curdoc.post_data, history[nhist - 1].post_data) && HText_getContentBase() && !strncmp(HText_getContentBase(), strncmp(history[nhist - 1].address, "LYNXIMGMAP:", 11) ? history[nhist - 1].address : history[nhist - 1].address + 11, strlen(HText_getContentBase())))) { /* * Normal case - as best as we can check, the * document at the top of the history stack * seems to be the document the List Page is * about (or a LYNXIMGMAP derived from it), * and LYresubmit_posts is not set, so don't * prompt here. If we actually have to repeat * a POST because, against expectations, the * underlying document isn't cached any more, * HTAccess will prompt for confirmation, * unless we had LYK_NOCACHE. - kw */ LYinternal_flag = TRUE; } else { HTLastConfirmCancelled(); /* reset flag */ if (!confirm_post_resub(newdoc.address, newdoc.title, (LYresubmit_posts && HText_POSTReplyLoaded(&newdoc)) ? 1 : 2, 2)) { if (HTLastConfirmCancelled() || (LYresubmit_posts && !HText_POSTReplyLoaded(&newdoc))) { /* cancel the whole thing */ LYforce_no_cache = FALSE; reloading = FALSE; StrAllocCopy(newdoc.address, curdoc.address); StrAllocCopy(newdoc.title, curdoc.title); newdoc.internal_link = curdoc.internal_link; _statusline(CANCELLED); sleep(InfoSecs); if (nlinks > 0) HText_pageDisplay(curdoc.line, prev_target); break; } else if (LYresubmit_posts) { /* If LYresubmit_posts is set, and the answer was No, and we have a cached copy, then use it. - kw */ LYforce_no_cache = FALSE; } else { /* if No, but not ^C or ^G, drop * the post data. Maybe the link * wasn't meant to be internal after * all, here we can recover from that * assumption. - kw */ FREE(newdoc.post_data); FREE(newdoc.post_content_type); newdoc.internal_link = FALSE; _statusline(DISCARDING_POST_DATA); sleep(AlertSecs); } } } /* * Don't push the List Page if we follow an * internal link given by it. - kw */ FREE(curdoc.address); } else try_internal = TRUE; if (!(LYresubmit_posts && newdoc.post_data)) LYinternal_flag = TRUE; force_load = TRUE; break; } else { /* * Free POST content if not an internal link. - kw */ FREE(newdoc.post_data); FREE(newdoc.post_content_type); }#endif /* DONT_TRACK_INTERNAL_LINKS */ /* * Might be an anchor in the same doc from a POST * form. If so, don't free the content. -- FM */ if (are_different(&curdoc, &newdoc)) { FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; } newdoc.internal_link = FALSE; force_load = TRUE; /* force MainLoop to reload */ break; case DO_GOTOLINK_STUFF: /* * Position on a normal link, don't follow it. - KW */ Newline = newdoc.line; newdoc.line = 1; if (Newline == curdoc.line) { /* * It's a link in the current page. - FM */ if (nlinks > 0 && curdoc.link > -1) { if (curdoc.link == newdoc.link) { /* * It's the current link, and presumably * reflects a typo in the statusline entry, * so issue a statusline message for the * typo-prone users (like me 8-). - FM */ StrAllocCopy(temp, user_input_buffer); sprintf(user_input_buffer, LINK_ALREADY_CURRENT, number); _statusline(user_input_buffer); sleep(MessageSecs); strcpy(user_input_buffer, temp); FREE(temp); } else { /* * It's a different link on this page, * so turn the highlighting off, set the * current link to the new link value from * follow_link_number(), and re-initialize * the new link value. - FM */ highlight(OFF, curdoc.link, prev_target); curdoc.link = newdoc.link; newdoc.link = 0; } } } break; /* nothing more to do */ case DO_GOTOPAGE_STUFF: /* * Position on a page in this document. - FM */ Newline = newdoc.line; newdoc.line = 1; if (Newline == curdoc.line) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -