⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ng.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
	case '+':	    putchar('\n') FLUSH;	    return AS_ASK;	case 'Q':	    exit_code = NG_ASK;	    /* FALL THROUGH */	case 'q':	    break;	case 'N':	    exit_code = NG_SELNEXT;	    break;	case 'P':	    exit_code = NG_SELPRIOR;	    break;	default:	    if (toread[ng])		return AS_NORM;	    break;	}	return AS_CLEAN;    case '=': {			/* list subjects */	char tmpbuf[256];	ART_NUM oldart = art;	int cmd;	char *s;	char *subjline = getval("SUBJLINE",Nullch);	ARTICLE *ap = article_ptr(firstart);	page_init();	for (i=firstart; i<=lastart && !int_count; i++, ap++) {	    if (!(ap->flags & AF_READ) && (s = fetchsubj(i,FALSE)) != Nullch) {		sprintf(tmpbuf,"%5ld ", i);		if (subjline) {		    art = i;		    interp(tmpbuf + 6, (sizeof tmpbuf) - 6, subjline);		}		else		    safecpy(tmpbuf + 6, s, (sizeof tmpbuf) - 6);		if (cmd = print_lines(tmpbuf,NOMARKING)) {		    if (cmd > 0)			pushchar(cmd);		    break;		}	    }	}	int_count = 0;	art = oldart;	return AS_ASK;    }    case '^':	top_article();#ifdef ARTSEARCH	srchahead = 0;#endif	return AS_NORM;#ifdef DEBUG    case 'D':	printf("\nFirst article: %ld\n",(long)firstart) FLUSH;	{	    ARTICLE *ap = article_ptr(firstart);	    for (i = firstart; i <= lastart && !int_count; i++, ap++) {		if (ap->subj)		    printf("%5ld %c %s\n",i,(was_read(i)?'y':'n'),			   ap->subj->str) FLUSH;	    }	}	int_count = 0;	return AS_ASK;#endif    case 'v':	if (art <= lastart) {	    reread = TRUE;	    do_hiding = FALSE;	}	return AS_NORM;#ifdef ROTATION    case Ctl('x'):#endif    case Ctl('r'):#ifdef ROTATION	rotate = (*buf==Ctl('x'));#endif	if (art <= lastart)	    reread = TRUE;	else	    forcelast = TRUE;	return AS_NORM;#ifdef ROTATION    case 'X':	rotate = !rotate;	/* FALL THROUGH */#else    case Ctl('x'):    case 'x':    case 'X':	notincl("x");	return AS_ASK;#endif    case 'l': case Ctl('l'):		/* refresh screen */	if (art <= lastart) {	    reread = TRUE;	    clear();	    do_fseek = TRUE;	    artline = topline;	    if (artline < 0)		artline = 0;	}	return AS_NORM;    case Ctl('f'):	carriage_return();	erase_eol();		/* erase the prompt */#ifdef MAILCALL	setmail(TRUE);		/* force a mail check */#endif	return AS_ASK;    case 'b': case Ctl('b'):		/* back up a page */	if (art <= lastart) {	    ART_LINE target;	    reread = TRUE;	    clear();	    do_fseek = TRUE;	    target = topline - (LINES - 2);	    artline = topline;	    if (artline >= 0) do {		artline--;	    } while(artline >= 0 && artline > target && vrdary(artline-1) >= 0);	    topline = artline;	    if (artline < 0)		artline = 0;	}	return AS_NORM;    case '!':			/* shell escape */	if (escapade())	    return AS_INP;	return AS_ASK;    case 'C': {	cancel_article();	return AS_ASK;    }    case 'Z':    case 'z': {	supersede_article();	/* supersedes */	return AS_ASK;    }    case 'R':    case 'r': {			/* reply? */	reply();	return AS_ASK;    }    case 'F':    case 'f': {			/* followup command */	followup();	forcegrow = TRUE;		/* recalculate lastart */	return AS_ASK;    }    case '|':    case 'w': case 'W':    case 's': case 'S':		/* save command */    case 'e':			/* extract command */	if (save_article() == SAVE_ABORT)	    return AS_INP;	int_count = 0;	return AS_ASK;    case 'E':	if (decode_fp)	    decode_end();	else	    putchar('\n') FLUSH;	return AS_ASK;    case 'Y':				/* yank back M articles */	yankback();	top_article();			/* from the beginning */	return AS_NORM;			/* pretend nothing happened */#ifdef STRICTCR    case '\n':	fputs(badcr,stdout) FLUSH;	return AS_ASK;#endif    case '_':	if (!finish_dblchar())	    return AS_INP;	switch (buf[1] & 0177) {	case 'P':	    art--;	    goto check_dec_art;	case 'N':	    if (art > lastart)		art = absfirst;	    else		art++;	    if (art <= lastart)		reread = TRUE;#ifdef ARTSEARCH	    srchahead = 0;#endif	    return AS_NORM;	case '+':	    if (ThreadedGroup) {		select_thread(artp->subj->thread, 0);		printf("\nSelected all articles in this thread.\n");	    } else {		select_subject(artp->subj, 0);		printf("\nSelected all articles in this subject.\n");	    }	    return AS_ASK;	case '-':	    if (sel_mode == SM_THREAD) {		deselect_thread(artp->subj->thread);		printf("\nDeselected all articles in this thread.\n");	    } else {		deselect_subject(artp->subj);		printf("\nDeselected all articles in this subject.\n");	    }	    return AS_ASK;	case 'a':  case 's':  case 't':  case 'T':	    *buf = buf[1];	    goto run_the_selector;	}	/* FALL THROUGH */    default:	printf("\n%s",hforhelp) FLUSH;	settle_down();	break;    }    return AS_ASK;}#ifdef MAILCALL/* see if there is any mail */voidsetmail(force)bool_int force;{    if (force)	mailcount = 0;    if (!(mailcount++)) {	char *mailfile = filexp(getval("MAILFILE",MAILFILE));		if (stat(mailfile,&filestat) < 0 || !filestat.st_size	    || filestat.st_atime > filestat.st_mtime)	    mailcall = nullstr;	else	    mailcall = getval("MAILCALL","(Mail) ");    }    mailcount %= 10;			/* check every 10 articles */}#endifvoidsetdfltcmd(){    if (!toread[ng]) {	if (art > lastart)	    dfltcmd = "qnp";	else	    dfltcmd = "npq";    }    else {#ifdef ARTSEARCH	if (srchahead)	    dfltcmd = "^Nnpq";	else#endif	    dfltcmd = "npq";    }}/* Ask the user about catching-up the current group.  Returns 'y' if yes,** 'n' or 'N' if no ('N' means we used one line when in the selector),** or 'u' for yes with unsubscribe.  Actually performs the catchup and** unsubscription as needed.*/charask_catchup(){    char ch;    bool use_one_line = (mode == 't');    if (!use_one_line)	putchar('\n') FLUSH;reask_catchup:#ifdef VERBOSE    IF(verbose)	in_char("Do you really want to mark everything as read? [yn] ", 'C');    ELSE#endif#ifdef TERSE	in_char("Really? [ynh] ", 'C');#endif    setdef(buf,"y");#ifdef VERIFY    printcmd();#endif    if ((ch = *buf) == 'h') {	use_one_line = FALSE;#ifdef VERBOSE	IF(verbose)	    fputs("\n\Type y or SP to mark all articles as read.\n\Type n to leave articles marked as they are.\n\Type u to mark everything read and unsubscribe.\n\n\",stdout) FLUSH;	ELSE#endif#ifdef TERSE	    fputs("\n\y or SP to mark all read.\n\n to forget it.\n\u to mark all and unsubscribe.\n\n\",stdout) FLUSH;#endif	goto reask_catchup;    }    if (ch == 'n' || ch == 'q') {	if (use_one_line)	    return 'N';	putchar('\n') FLUSH;	return 'n';    }    if (ch != 'y' && ch != 'u') {	use_one_line = FALSE;	printf("\n%s\n", hforhelp) FLUSH;	settle_down();	goto reask_catchup;    }    if (mode == 'n') {	putchar('\n') FLUSH;	catch_up(ng);    }    else {	int i;	ARTICLE *ap;	for (i = firstart, ap = article_ptr(i); i <= lastart; i++, ap++)	    ap->flags = ((ap->flags & ~sel_mask) | AF_READ);	selected_count = selected_subj_cnt = selected_only = 0;	toread[ng] = 0;	if (dmcount)	    yankback();	putchar('\n') FLUSH;    }    if (ch == 'u')	rcchar[ng] = NEGCHAR;    return ch;}charask_memorize(ch)char_int ch;{    bool thread_cmd = (ch == 'T');    bool use_one_line = (mode == 't');    char *mode_string = (thread_cmd? "thread" : "subject");    char *mode_phrase = (thread_cmd? "replies to this article" :				     "this subject and all replies");    ART_NUM art_hold = art;    ARTICLE *artp_hold = artp;    if (!use_one_line)	putchar('\n') FLUSH;    sprintf(cmd_buf,"Memorize %s command: [+.j,cC]", mode_string);reask_memorize:    in_char(cmd_buf, 'm');    setdef(buf,"+");#ifdef VERIFY    printcmd();#endif    if ((ch = *buf) == 'h') {	use_one_line = FALSE;#ifdef VERBOSE	IF(verbose)	    printf("\n\Type + or SP to auto-select this %s (i.e. includes future articles).\n\Type . to auto-select %s.\n\Type j to auto-kill (junk) this %s.\n\Type , to auto-kill %s.\n\Type c to clear all selection/killing on this %s.\n\Type C to clear all selection/killing on %s.\n\Type q to abort the operation.\n\n\",mode_string,mode_phrase,mode_string,mode_phrase,mode_string,mode_phrase) FLUSH;	ELSE#endif#ifdef TERSE	    printf("\n\+ or SP auto-selects this %s.\n\. auto-selects %s.\n\j auto-kills this %s.\n\, auto-kills %s.\n\c clears auto-commands for this %s.\n\C clears auto-commands for %s.\n\q aborts.\n\n\",mode_string,mode_phrase,mode_string,mode_phrase,mode_string,mode_phrase) FLUSH;#endif	goto reask_memorize;    }    if (ch == 'q') {	if (use_one_line)	    return 'Q';	putchar('\n');	return 'q';    }    if (ch == '+') {	if (!thread_cmd) {	    (void)art_search(buf, (sizeof buf), TRUE);	    art = art_hold;	    artp = artp_hold;	    ch = '.';	} else	    ch = (use_one_line? '+' : '.');	if (thread_cmd)	    select_thread(artp->subj->thread, AF_AUTOSELECTALL);	else	    select_subject(artp->subj, 0);	if (mode != 't')	    printf("\nSelection memorized.\n");    } else if (ch == '.') {	if (!thread_cmd) {	    (void)art_search(buf, (sizeof buf), TRUE);	    art = art_hold;	    artp = artp_hold;	} else	    ch = (use_one_line? '+' : '.');	select_subthread(artp,thread_cmd? AF_AUTOSELECT : 0);	if (mode != 't')	    printf("\nSelection memorized.\n");    } else if (ch == 'j') {	if (!thread_cmd) {	    *buf = 'K';	    (void)art_search(buf, (sizeof buf), TRUE);	    art = art_hold;	    artp = artp_hold;	}	if (thread_cmd)	    kill_thread(artp->subj->thread,KF_ALL|KF_KILLFILE);	else	    kill_subject(artp->subj,KF_ALL);	if (mode != 't')	    printf("\nKill memorized.\n");    } else if (ch == ',') {	if (!thread_cmd) {	    (void)art_search(buf, (sizeof buf), TRUE);	    art = art_hold;	    artp = artp_hold;	}	kill_subthread(artp,KF_ALL|(thread_cmd?KF_KILLFILE:0));	if (mode != 't')	    printf("\nKill memorized.\n");    } else if (ch == 'c') {	if (thread_cmd)	    clear_thread(artp->subj->thread);	else	    clear_subject(artp->subj);    } else if (ch == 'C') {	clear_subthread(artp);    } else {	use_one_line = FALSE;	printf("\n%s\n", hforhelp) FLUSH;	settle_down();	goto reask_memorize;    }    if (!use_one_line)	putchar('\n') FLUSH;    return ch;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -