📄 lymainloop.c
字号:
/* * It's the current page, so issue a * statusline message for the typo-prone * users (like me 8-). - FM */ if (Newline <= 1) { _statusline(ALREADY_AT_BEGIN); } else if (!more) { _statusline(ALREADY_AT_END); } else { StrAllocCopy(temp, user_input_buffer); sprintf(user_input_buffer, ALREADY_AT_PAGE, number); _statusline(user_input_buffer); sleep(MessageSecs); strcpy(user_input_buffer, temp); FREE(temp); } sleep(MessageSecs); } break; case PRINT_ERROR: old_c = real_c; _statusline(BAD_LINK_NUM_ENTERED); sleep(MessageSecs); break; } break; } case LYK_SOURCE: /* toggle view source mode */ /* * Check if this is a reply from a POST, and if so, * seek confirmation if the safe element is not set. - FM */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, curdoc.title, 1, 1) == FALSE) { _statusline(CANCELLED); sleep(InfoSecs); break; } if (HTisDocumentSource()) { HTOutputFormat = WWW_PRESENT; } else { if (HText_getOwner()) StrAllocCopy(ownerS_address, HText_getOwner()); LYUCPushAssumed(HTMainAnchor); HTOutputFormat = WWW_SOURCE; } LYforce_no_cache = TRUE; FREE(curdoc.address); /* so it doesn't get pushed */ break; case LYK_RELOAD: /* control-R to reload and refresh */ /* * Check if this is a reply from a POST, and if so, * seek confirmation if the safe element is not set. - FM */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { _statusline(CANCELLED); sleep(InfoSecs); break; } /* * Check to see if should reload source, or load html */ if (HTisDocumentSource()) { HTOutputFormat = WWW_SOURCE; } HEAD_request = HTLoadedDocumentIsHEAD(); HTuncache_current_document();#ifdef NO_ASSUME_SAME_DOC /* * Don't assume the reloaded document will be the same. - FM */ newdoc.line = 1; newdoc.link = 0;#else /* * Do assume the reloaded document will be the same. - FM * (I don't remember all the reasons why we couldn't assume * this. As the problems show up, we'll try to fix them, * or add warnings. - FM) */ if (lynx_mode == FORMS_LYNX_MODE) { /* * Note that if there are no form links on the current * page, lynx_mode won't have this setting and we won't * know that this warning should be issued. - FM */ _statusline(RELOADING_FORM); sleep(AlertSecs); } newdoc.line = ((curdoc.line > 0) ? curdoc.line : 1); newdoc.link = ((curdoc.link > -1) ? curdoc.link : 0);#endif /* NO_ASSUME_SAME_DOC */ FREE(curdoc.address); /* so it doesn't get pushed */#ifdef VMS lynx_force_repaint();#endif /* VMS */ /* * Reload should force a cache refresh on a proxy. * -- Ari L. <luotonen@dxcern.cern.ch> * * -- but only if this was really a reload requested by * the user, not if we jumped here to handle reloading for * INLINE_TOGGLE, IMAGE_TOGGLE, RAW_TOGGLE, etc. - KW */ if (real_cmd == LYK_RELOAD) reloading = TRUE; break; case LYK_HISTORICAL: /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element * is not set. - FM */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 0, 0) == FALSE) { _statusline(WILL_NOT_RELOAD_DOC); sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); } if (historical_comments) historical_comments = FALSE; else historical_comments = TRUE; if (minimal_comments) { _statusline(historical_comments ? HISTORICAL_ON_MINIMAL_OFF : HISTORICAL_OFF_MINIMAL_ON); } else { _statusline(historical_comments ? HISTORICAL_ON_VALID_OFF : HISTORICAL_OFF_VALID_ON); } sleep(AlertSecs); break; case LYK_MINIMAL: if (!historical_comments) { /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element * is not set. - FM */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 0, 0) == FALSE) { _statusline(WILL_NOT_RELOAD_DOC); sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); } } if (minimal_comments) minimal_comments = FALSE; else minimal_comments = TRUE; if (!historical_comments) { _statusline(minimal_comments ? MINIMAL_ON_IN_EFFECT : MINIMAL_OFF_VALID_ON); } else { _statusline(minimal_comments ? MINIMAL_ON_BUT_HISTORICAL : MINIMAL_OFF_HISTORICAL_ON); } sleep(AlertSecs); break; case LYK_SOFT_DQUOTES: /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element * is not set. - FM */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 1, 1) == FALSE) { _statusline(WILL_NOT_RELOAD_DOC); sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); } if (soft_dquotes) soft_dquotes = FALSE; else soft_dquotes = TRUE; _statusline(soft_dquotes ? SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF); sleep(MessageSecs); break; case LYK_SWITCH_DTD: /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element * is not set. - FM, kw */ if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 1, 1) == FALSE) { _statusline(WILL_NOT_RELOAD_DOC); sleep(InfoSecs); } else { /* * If currently viewing preparsed source, switching * to the other DTD parsing may show source differences, * so stay in source view - kw */ if (HTisDocumentSource() && LYPreparsedSource) { HTOutputFormat = WWW_SOURCE; } HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); }#ifdef NO_ASSUME_SAME_DOC newdoc.line=1; newdoc.link=0;#else newdoc.line = ((curdoc.line > 0) ? curdoc.line : 1); newdoc.link = ((curdoc.link > -1) ? curdoc.link : 0);#endif /* NO_ASSUME_SAME_DOC */ if (New_DTD) New_DTD = NO; else New_DTD = YES; HTSwitchDTD(New_DTD); _statusline(New_DTD ? USING_DTD_1 : USING_DTD_0); sleep(MessageSecs); break;#ifdef NOT_DONE_YET case LYK_PIPE: /* ignore for now */ break;#endif /* NOT_DONE_YET */ case LYK_QUIT: /* quit */ if (LYQuitDefaultYes == TRUE) { _statusline(REALLY_QUIT_Y); } else { _statusline(REALLY_QUIT_N); } c = LYgetch(); if (LYQuitDefaultYes == TRUE) { if (TOUPPER(c) != 'N' && c != 7) { return(0); } else { statusline(NO_CANCEL); sleep(InfoSecs); } } else if (TOUPPER(c) == 'Y') { return(0); } else { statusline(NO_CANCEL); sleep(InfoSecs); } break; case LYK_ABORT: /* don't ask the user about quitting */ return(0); break; case LYK_NEXT_PAGE: /* next page */ if (more) { Newline += display_lines; } else if (curdoc.link < nlinks-1) { highlight(OFF, curdoc.link, prev_target); curdoc.link = nlinks-1; /* put on last link */ } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_END); sleep(MessageSecs); } break; case LYK_PREV_PAGE: /* page up */ if (Newline > 1) { Newline -= display_lines; } else if (curdoc.link > 0) { highlight(OFF, curdoc.link, prev_target); curdoc.link = 0; /* put on first link */ } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_BEGIN); sleep(MessageSecs); } break; case LYK_UP_TWO: if (Newline > 1) { int scrollamount = (Newline > 2 ? 2 : 1); Newline -= scrollamount; if (nlinks > 0 && curdoc.link > -1) { if (links[curdoc.link].ly + scrollamount <= display_lines) { newdoc.link = curdoc.link + HText_LinksInLines(HTMainText, Newline, scrollamount); } else { arrowup = TRUE; } } } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_BEGIN); sleep(MessageSecs); } break; case LYK_DOWN_TWO: if (more) { Newline += 2; if (nlinks > 0 && curdoc.link > -1 && links[curdoc.link].ly > 2) { newdoc.link = curdoc.link; for (i = 0; links[i].ly <= 2; i++) --newdoc.link; } } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_END); sleep(MessageSecs); } break; case LYK_UP_HALF: if (Newline > 1) { int scrollamount = display_lines/2; if (Newline - scrollamount < 1) scrollamount = Newline - 1; Newline -= scrollamount; if (nlinks > 0 && curdoc.link > -1) { if (links[curdoc.link].ly + scrollamount <= display_lines) { newdoc.link = curdoc.link + HText_LinksInLines(HTMainText, Newline, scrollamount); } else { arrowup = TRUE; } } } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_BEGIN); sleep(MessageSecs); } break; case LYK_DOWN_HALF: if (more) { Newline += (display_lines/2); if (nlinks > 0 && curdoc.link > -1 && links[curdoc.link].ly > display_lines/2) { newdoc.link = curdoc.link; for (i = 0; links[i].ly <= (display_lines/2); i++) --newdoc.link; } } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_END); sleep(MessageSecs); } break; case LYK_REFRESH: refresh_screen = TRUE; lynx_force_repaint(); break; case LYK_HOME: if (curdoc.line > 1) Newline = 1; else { cmd = LYK_PREV_PAGE; goto new_cmd; } break; case LYK_END: if (more) { Newline = MAXINT; /* go to end of file */ arrowup = TRUE; /* position on last link */ } else { cmd = LYK_NEXT_PAGE; goto new_cmd; } break; case LYK_PREV_LINK: if (curdoc.link > 0) { /* previous link */ /* * Unhighlight current link. */ highlight(OFF, curdoc.link, prev_target); curdoc.link--; } else if (!more && curdoc.link==0 && Newline==1) { /* at the top of list */ /* * If there is only one page of data and the user * goes off the top, then unhighlight the current * link and just move the cursor to last link on * the page. */ highlight(OFF, curdoc.link, prev_target); curdoc.link = nlinks-1; /* the last link */ } else if (curdoc.line > 1) { /* previous page */ /* * Go back to the previous page. */ int scrollamount = (Newline > display_lines ? display_lines : Newline - 1); Newline -= scrollamount; if (scrollamount < display_lines && nlinks > 0 && curdoc.link == 0 && links[0].ly - 1 + scrollamount <= display_lines) { newdoc.link = HText_LinksInLines(HTMainText, 1, scrollamount) - 1; } else { arrowup = TRUE; } } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_BEGIN); sleep(MessageSecs); } break; case LYK_NEXT_LINK: if (curdoc.link < nlinks-1) { /* next link */ highlight(OFF, curdoc.link, prev_target);#ifdef FASTTAB /* * Move to different textarea if TAB in textarea. */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->type == F_TEXTAREA_TYPE && c=='\t') { int thisgroup = links[curdoc.link].form->number; char *thisname = links[curdoc.link].form->name; do curdoc.link++; while ((curdoc.link < nlinks-1) && links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->type == F_TEXTAREA_TYPE && links[curdoc.link].form->number == thisg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -