# 2.11BSD#431 - /usr/src/new/rn/art.c

##### Functions

    art_init          X
    do_article        X
    innermore         X
    page_switch       X

##### Variables

    alinebeg          X
    art_buf           X
    blinebeg          X
    bool              X
    highlight         X
    innersearch       X
    isrchline         X
    restart           X
    slines            X

##### Macros

    PS_ASK            X
    PS_NORM           X
    PS_RAISE          X
    PS_TOEND          X

       1: /* $Header: art.c,v 4.3.1.5 85/09/10 11:07:18 lwall Exp $
       2:  *
       3:  * $Log:	art.c,v $
       4:  * Revision 4.3.1.5  85/09/10  11:07:18  lwall
       5:  * %m not restored on some returns.
       6:  *
       7:  * Revision 4.3.1.4  85/05/23  12:13:31  lwall
       8:  * shouldn't display article that's really a subdirectory.
       9:  *
      10:  * Revision 4.3.1.3  85/05/13  09:29:55  lwall
      11:  * Added CUSTOMLINES option.
      12:  *
      13:  * Revision 4.3.1.2  85/05/10  13:46:07  lwall
      14:  * Fixed header reparse bug on backpage.
      15:  *
      16:  * Revision 4.3.1.1  85/05/10  11:30:56  lwall
      17:  * Branch for patches.
      18:  *
      19:  * Revision 4.3  85/05/01  11:34:51  lwall
      20:  * Baseline for release with 4.3bsd.
      21:  *
      22:  */
      23:
      24: #include "EXTERN.h"
      25: #include "common.h"
      26: #include "rn.h"
      27: #include "ngstuff.h"
      28: #include "head.h"
      29: #include "cheat.h"
      30: #include "help.h"
      31: #include "search.h"
      32: #include "artio.h"
      33: #include "ng.h"
      34: #include "bits.h"
      35: #include "final.h"
      36: #include "artstate.h"
      37: #include "rcstuff.h"
      38: #include "term.h"
      39: #include "sw.h"
      40: #include "util.h"
      41: #include "backpage.h"
      42: #include "intrp.h"
      43: #include "INTERN.h"
      44: #include "art.h"
      45:
      46: /* page_switch() return values */
      47:
      48: #define PS_NORM 0
      49: #define PS_ASK 1
      50: #define PS_RAISE 2
      51: #define PS_TOEND 3
      52:
      53: bool special = FALSE;       /* is next page special length? */
      54: int slines = 0;         /* how long to make page when special */
      55: ART_LINE highlight = -1;    /* next line to be highlighted */
      56: char *restart = Nullch;     /* if nonzero, the place where last */
      57:                 /* line left off on line split */
      58: char *blinebeg;         /* where in buffer current line began */
      59: ART_POS alinebeg;       /* where in file current line began */
      60:
      61: #ifdef INNERSEARCH
      62: ART_POS innersearch = 0;    /* artpos of end of line we found */
      63:                 /* for 'g' command */
      64: ART_LINE isrchline = 0;         /* last line to display */
      65: bool hide_everything = FALSE;
      66:                 /* if set, do not write page now, */
      67:                 /* but refresh when done with page */
      68: COMPEX gcompex;             /* in article search pattern */
      69: #endif
      70:
      71: bool firstpage;         /* is this the 1st page of article? */
      72:
      73: char art_buf[LBUFLEN];      /* place for article lines */
      74:
      75: void
      76: art_init()
      77: {
      78:     ;
      79: }
      80:
      81: int
      82: do_article()
      83: {
      84:     register char *s;
      85:     ART_POS artsize;            /* size in bytes of article */
      86:     bool hide_this_line = FALSE;    /* hidden header line? */
      87:     ART_LINE linenum;   /* line # on page, 1 origin */
      88: #ifdef ULSMARTS
      89:     bool under_lining = FALSE;
      90:                 /* are we underlining a word? */
      91: #endif
      92:     register char *bufptr = art_buf;
      93:                 /* pointer to input buffer */
      94:     register int outpos;    /* column position of output */
      95:     static char prompt_buf[64];     /* place to hold prompt */
      96:     bool notesfiles = FALSE;        /* might there be notesfiles junk? */
      97:     char oldmode = mode;
      98:
      99: #ifdef INNERSEARCH
     100:     register int outputok;
     101: #endif
     102:
     103:     if (fstat(artfp->_file,&filestat))
     104:                 /* get article file stats */
     105:     return DA_CLEAN;
     106:     if (filestat.st_mode & S_IFMT != S_IFREG)
     107:     return DA_NORM;
     108:     artsize = filestat.st_size;
     109:                 /* from that get article size */
     110:     sprintf(prompt_buf,
     111:     "%%sEnd of article %ld (of %ld)--what next? [%%s]",
     112:     (long)art,(long)lastart);   /* format prompt string */
     113:     prompt = prompt_buf;
     114:     int_count = 0;      /* interrupt count is 0 */
     115:     firstpage = (topline < 0);
     116:     for (;;) {          /* for each page */
     117:     assert(art == openart);
     118:     if (do_fseek) {
     119: #ifdef ASYNC_PARSE
     120:         parse_maybe(art);       /* make sure header is ours */
     121: #endif
     122:         artpos = vrdary(artline);
     123:         if (artpos < 0)
     124:         artpos = -artpos;   /* labs(), anyone? */
     125:         if (firstpage)
     126:         artpos = (ART_POS)0;
     127:         fseek(artfp,artpos,0);
     128:         if (artpos < htype[PAST_HEADER].ht_minpos)
     129:         in_header = SOME_LINE;
     130:         do_fseek = FALSE;
     131:         restart = Nullch;
     132:     }
     133:     if (firstpage) {
     134:         if (firstline) {
     135:         interp(art_buf, (sizeof art_buf), firstline);
     136: #ifdef CLEAREOL
     137:         maybe_eol();    /* PWP */
     138: #endif CLEAREOL
     139:         fputs(art_buf,stdout) FLUSH;
     140:         artopen(art);       /* rewind article in case interp */
     141:                     /* forced a header parse */
     142:         }
     143:         else {
     144:         ART_NUM i;
     145:
     146: #ifdef CLEAREOL
     147:         maybe_eol();    /* PWP */
     148: #endif CLEAREOL
     149:         printf("Article %ld",(long)art);
     150:         i = (((ART_NUM)toread[ng]) - 1 + was_read(art));
     151: #ifdef DELAYMARK
     152:         if (i || dmcount) {
     153:             printf(" (%ld more",(long)i);
     154:             if (dmcount)
     155:             printf(" + %ld Marked to return)",(long)dmcount);
     156:             putchar(')');
     157:         }
     158: #else
     159:         if (i)
     160:             printf(" (%ld more)",(long)i);
     161: #endif
     162:         if (htype[NGS_LINE].ht_flags & HT_HIDE)
     163:             printf(" in %s", ngname);
     164:         fputs(":\n",stdout) FLUSH;
     165:         }
     166:         start_header(art);
     167:         forcelast = FALSE;      /* we will have our day in court */
     168:         restart = Nullch;
     169:         artline = 0;        /* start counting lines */
     170:         artpos = 0;
     171:         vwtary(artline,artpos); /* remember pos in file */
     172:     }
     173:     for (linenum=(firstpage?2:1);
     174:       in_header || (
     175: #ifdef INNERSEARCH
     176:       innersearch ? innermore() :
     177: #endif
     178:       linenum<(firstpage?initlines:(special?slines:LINES)) );
     179:       linenum++) {      /* for each line on page */
     180:         if (int_count) {    /* exit via interrupt? */
     181:         putchar('\n') FLUSH;    /* get to left margin */
     182:         int_count = 0;  /* reset interrupt count */
     183:         mode = oldmode;
     184:         return DA_NORM; /* skip out of loops */
     185:         }
     186:         if (restart) {      /* did not finish last line? */
     187:         bufptr = restart;   /* then start again here */
     188:         restart = Nullch;   /* and reset the flag */
     189:         }
     190:         else {          /* not a restart */
     191:         if (fgets(art_buf,LBUFLEN,artfp)==Nullch) {
     192:                     /* if all done */
     193:             mode = oldmode;
     194:             return DA_NORM; /* skip out of loops */
     195:         }
     196:         bufptr = art_buf;   /* so start at beginning */
     197:         art_buf[LBUFLEN-1] = '\0';
     198:                     /* make sure string ends */
     199:         }
     200:         blinebeg = bufptr;  /* remember where we began */
     201:         alinebeg = artpos;  /* both in buffer and file */
     202:         if (in_header && bufptr == art_buf)
     203:         hide_this_line =
     204:             parseline(art_buf,do_hiding,hide_this_line);
     205:         else if (notesfiles && do_hiding &&
     206:           bufptr == art_buf && *art_buf == '#' &&
     207:           isupper(art_buf[1]) && art_buf[2] == ':' ) {
     208:         fgets(art_buf,sizeof(art_buf),artfp);
     209:         if (index(art_buf,'!') != Nullch)
     210:             fgets(art_buf,sizeof(art_buf),artfp);
     211:         htype[PAST_HEADER].ht_minpos = ftell(artfp);
     212:                     /* exclude notesfiles droppings */
     213:         hide_this_line = TRUE;  /* and do not print either */
     214:         notesfiles = FALSE;
     215:         }
     216: #ifdef CUSTOMLINES
     217:         if (hideline && bufptr == art_buf &&
     218:           execute(&hide_compex,art_buf) )
     219:         hide_this_line = TRUE;
     220: #endif
     221:         if (in_header && htype[in_header].ht_flags & HT_MAGIC) {
     222:         if (in_header == NGS_LINE) {
     223:             hide_this_line = (index(art_buf,',') == Nullch);
     224:         }
     225:         else if (in_header == EXPIR_LINE) {
     226:             if (!(htype[EXPIR_LINE].ht_flags & HT_HIDE))
     227:             hide_this_line = (strlen(art_buf) < 10);
     228:         }
     229:         }
     230:         if (in_header == SUBJ_LINE &&
     231:         htype[SUBJ_LINE].ht_flags & HT_MAGIC) {
     232:                 /* is this the subject? */
     233:         int length;
     234:
     235:         length = strlen(art_buf)-1;
     236:         artline++;
     237:         art_buf[length] = '\0';     /* wipe out newline */
     238: #ifdef NOFIREWORKS
     239:         no_ulfire();
     240: #endif
     241:         notesfiles =
     242:             (instr(&art_buf[length-10]," - (nf") != Nullch);
     243:         if (oldsubject) {
     244:             length += 7;
     245:             fputs("(SAME) ",stdout);
     246:             oldsubject = FALSE;
     247:         }
     248:         if (length+UG > COLS) {     /* rarely true */
     249:             linenum++;
     250:             vwtary(artline,vrdary(artline-1)+COLS);
     251:             artline++;
     252:         }
     253:         s = art_buf + 8;
     254:         *s++ = '\0';    /* make into 2 strings */
     255: #ifdef CLEAREOL
     256:         maybe_eol();    /* PWP */
     257: #endif CLEAREOL
     258:         fputs(art_buf,stdout) FLUSH;
     259:                 /* print up through : */
     260:         if (!UG)
     261:             putchar(' ');
     262:         underprint(s);  /* print subject underlined */
     263:         putchar('\n') FLUSH;    /* and finish the line */
     264:         }
     265:         else if (hide_this_line && do_hiding) {
     266:                     /* do not print line? */
     267:         linenum--;      /* compensate for linenum++ */
     268:         if (!in_header)
     269:             hide_this_line = FALSE;
     270:         }
     271:         else {          /* just a normal line */
     272:         if (highlight==artline) {   /* this line to be highlit? */
     273:             if (marking == STANDOUT) {
     274: #ifdef NOFIREWORKS
     275:             if (erase_screen)
     276:                 no_sofire();
     277: #endif
     278:             standout();
     279:             }
     280:             else {
     281: #ifdef NOFIREWORKS
     282:             if (erase_screen)
     283:                 no_ulfire();
     284: #endif
     285:             underline();
     286:             }
     287:             if (*bufptr == '\n')
     288:             putchar(' ');
     289:         }
     290: #ifdef INNERSEARCH
     291:         outputok = !hide_everything;
     292:                     /* get it into register, hopefully */
     293: #endif
     294: #ifdef CLEAREOL
     295: #ifdef INNERSEARCH
     296:         if (outputok)
     297: #endif
     298:         maybe_eol();    /* PWP */
     299: #endif CLEAREOL
     300: #ifdef CUSTOMLINES
     301:         if (pagestop && bufptr == art_buf &&
     302:           execute(&page_compex,art_buf) )
     303:             linenum = 32700;
     304: #endif
     305:         for (outpos = 0; outpos < COLS; ) {
     306:                     /* while line has room */
     307:             if (*bufptr >= ' ') {   /* normal char? */
     308: #ifdef ULSMARTS
     309:             if (*bufptr == '_') {
     310:                 if (bufptr[1] == '\b') {
     311:                 if (!under_lining && highlight!=artline
     312: #ifdef INNERSEARCH
     313:                     && outputok
     314: #endif
     315:                     ) {
     316:                     under_lining++;
     317:                     if (UG) {
     318:                     if (bufptr != buf &&
     319:                       bufptr[-1] == ' ') {
     320:                         outpos--;
     321:                         backspace();
     322:                     }
     323:                     }
     324:                     underline();
     325:                 }
     326:                 bufptr += 2;
     327:                 }
     328:             }
     329:             else {
     330:                 if (under_lining) {
     331:                 under_lining = 0;
     332:                 un_underline();
     333:                 if (UG) {
     334:                     if (*bufptr == ' ')
     335:                     goto skip_put;
     336:                     outpos++;
     337:                 }
     338:                 }
     339:             }
     340: #endif
     341: #ifdef INNERSEARCH
     342:             if (outputok)
     343: #endif
     344:             {
     345: #ifdef ROTATION
     346:                 if (rotate && !in_header
     347:                   && isalpha(*bufptr)) {
     348:                 if ((*bufptr & 31) <= 13)
     349:                     putchar(*bufptr+13);
     350:                 else
     351:                     putchar(*bufptr-13);
     352:                 }
     353:                 else
     354: #endif
     355:                 putchar(*bufptr);
     356:             }
     357:             if (*UC && ((highlight==artline && marking == 1)
     358: #ifdef ULSMARTS
     359:                 || under_lining
     360: #endif
     361:                 )) {
     362:                 backspace();
     363:                 underchar();
     364:             }
     365:             skip_put:
     366:             bufptr++;
     367:             outpos++;
     368:             }
     369:             else if (*bufptr == '\n' || !*bufptr) {
     370:                             /* newline? */
     371: #ifdef ULSMARTS
     372:             if (under_lining) {
     373:                 under_lining = 0;
     374:                 un_underline();
     375:             }
     376: #endif
     377: #ifdef DEBUGGING
     378:             if (debug & DEB_INNERSRCH && outpos < COLS - 6) {
     379:                 standout();
     380:                 printf("%4d",artline);
     381:                 un_standout();
     382:             }
     383: #endif
     384: #ifdef INNERSEARCH
     385:             if (outputok)
     386: #endif
     387:                 putchar('\n') FLUSH;
     388:             restart = 0;
     389:             outpos = 1000;  /* signal normal \n */
     390:             }
     391:             else if (*bufptr == '\t') { /* tab? */
     392: #ifdef INNERSEARCH
     393:             if (outputok)
     394: #endif
     395:                 putchar(*bufptr);
     396:             bufptr++;
     397:             outpos += 8 - outpos % 8;
     398:             }
     399:             else if (*bufptr == '\f') { /* form feed? */
     400: #ifdef INNERSEARCH
     401:             if (outputok)
     402: #endif
     403:                 fputs("^L",stdout);
     404:             if (bufptr == blinebeg && highlight != artline)
     405:                 linenum = 32700;
     406:                 /* how is that for a magic number? */
     407:             bufptr++;
     408:             outpos += 2;
     409:             }
     410:             else {      /* other control char */
     411: #ifdef INNERSEARCH
     412:             if (outputok)
     413: #endif
     414:             {
     415:                 putchar('^');
     416:                 if (highlight == artline && *UC && marking == 1) {
     417:                 backspace();
     418:                 underchar();
     419:                 putchar(*bufptr+64);
     420:                 backspace();
     421:                 underchar();
     422:                 }
     423:                 else
     424:                 putchar(*bufptr+64);
     425:             }
     426:             bufptr++;
     427:             outpos += 2;
     428:             }
     429:
     430:         } /* end of column loop */
     431:
     432:         if (outpos < 1000) {/* did line overflow? */
     433:             restart = bufptr;
     434:                     /* restart here next time */
     435:             if (AM) {   /* automatic margins on tty? */
     436:             if (!XN && *bufptr == '\n')
     437:                     /* need we simulate XN? */
     438:                 restart = 0;
     439:                     /* skip the newline */
     440:             }
     441:             else {      /* cursor just hangs there */
     442: #ifdef INNERSEARCH
     443:             if (outputok)
     444: #endif
     445:                 putchar('\n') FLUSH;
     446:                     /* so move it down ourselves */
     447:             if (*bufptr == '\n')
     448:                 restart = 0;
     449:                     /* simulate XN if need be */
     450:             }
     451: #ifdef CLEAREOL
     452: /* #ifdef INNERSEARCH
     453: 		    if (outputok)
     454: #endif
     455: 		    maybe_eol(); */   /* PWP *//* comment this out for now
     456: 						    until I am sure it is
     457: 						    needed*/
     458:
     459: #endif CLEAREOL
     460:         }
     461:
     462:         /* handle normal end of output line formalities */
     463:
     464:         if (highlight == artline) {
     465:                     /* were we highlighting line? */
     466:             if (marking == STANDOUT)
     467:             un_standout();
     468:             else
     469:             un_underline();
     470:             highlight = -1; /* no more we are */
     471:         }
     472:         artline++;  /* count the line just printed */
     473:         if (artline - LINES + 1 > topline)
     474:                 /* did we just scroll top line off? */
     475:             topline = artline - LINES + 1;
     476:                 /* then recompute top line # */
     477:         }
     478:
     479:         /* determine actual position in file */
     480:
     481:         if (restart)    /* stranded somewhere in the buffer? */
     482:         artpos += restart - blinebeg;
     483:                 /* just calculate position */
     484:         else        /* no, ftell will do */
     485:         artpos = ftell(artfp);
     486:                 /* so do ftell */
     487:         vwtary(artline,artpos); /* remember pos in file */
     488:     } /* end of line loop */
     489:
     490: #ifdef INNERSEARCH
     491:     innersearch = 0;
     492:     if (hide_everything) {
     493:         hide_everything = FALSE;
     494:         *buf = Ctl('l');
     495:         goto fake_command;
     496:     }
     497: #endif
     498:     if (linenum >= 32700)/* did last line have formfeed? */
     499:         vwtary(artline-1,-vrdary(artline-1));
     500:                 /* remember by negating pos in file */
     501:
     502:     special = FALSE;    /* end of page, so reset page length */
     503:     firstpage = FALSE;  /* and say it is not 1st time thru */
     504:
     505:     /* extra loop bombout */
     506:
     507:     if (artpos == artsize) {/* did we just now reach EOF? */
     508:         mode = oldmode;
     509:         return DA_NORM; /* avoid --MORE--(100%) */
     510:     }
     511:
     512: /* not done with this article, so pretend we are a pager */
     513:
     514: reask_pager:
     515:     unflush_output();   /* disable any ^O in effect */
     516:     standout();     /* enter standout mode */
     517:     printf("--MORE--(%ld%%)",(long)(artpos*100/artsize));
     518:     un_standout();  /* leave standout mode */
     519:     fflush(stdout);
     520: /* reinp_pager:     			/* unused, commented for lint */
     521:     eat_typeahead();
     522: #ifdef DEBUGGING
     523:     if (debug & DEB_CHECKPOINTING) {
     524:         printf("(%d %d %d)",checkcount,linenum,artline);
     525:         fflush(stdout);
     526:     }
     527: #endif
     528:     if (checkcount >= docheckwhen &&
     529:       linenum == LINES &&
     530:       (artline > 40 || checkcount >= docheckwhen+10) ) {
     531:                 /* while he is reading a whole page */
     532:                 /* in an article he is interested in */
     533:         checkcount = 0;
     534:         checkpoint_rc();    /* update .newsrc */
     535:     }
     536:     collect_subjects();     /* loads subject cache until */
     537:                     /* input is pending */
     538:     mode = 'p';
     539:     getcmd(buf);
     540:     if (errno) {
     541:         if (LINES < 100 && !int_count)
     542:         *buf = '\f';/* on CONT fake up refresh */
     543:         else {
     544:         *buf = 'q'; /* on INTR or paper just quit */
     545:         }
     546:     }
     547:     carriage_return();
     548: #ifndef CLEAREOL
     549:     erase_eol();    /* and erase the prompt */
     550: #else
     551:     if (erase_screen && can_home_clear) /* PWP was here */
     552:         clear_rest();
     553:     else
     554:         erase_eol();    /* and erase the prompt */
     555: #endif CLEAREOL
     556:     fflush(stdout);
     557:
     558:     fake_command:       /* used by innersearch */
     559:
     560:     /* parse and process pager command */
     561:
     562:     switch (page_switch()) {
     563:     case PS_ASK:    /* reprompt "--MORE--..." */
     564:         goto reask_pager;
     565:     case PS_RAISE:  /* reparse on article level */
     566:         mode = oldmode;
     567:         return DA_RAISE;
     568:     case PS_TOEND:  /* fast pager loop exit */
     569:         mode = oldmode;
     570:         return DA_TOEND;
     571:     case PS_NORM:   /* display more article */
     572:         break;
     573:     }
     574:     } /* end of page loop */
     575: }
     576:
     577: /* process pager commands */
     578:
     579: int
     580: page_switch()
     581: {
     582:     register char *s;
     583:
     584:     switch (*buf) {
     585:     case 'd':
     586:     case Ctl('d'):  /* half page */
     587:     special = TRUE;
     588:     slines = LINES / 2 + 1;
     589:     if (marking && *blinebeg != '\f'
     590: #ifdef CUSTOMLINES
     591:       && (!pagestop || blinebeg != art_buf ||
     592:           !execute(&page_compex,blinebeg))
     593: #endif
     594:       ) {
     595:         up_line();
     596:         highlight = --artline;
     597:         restart = blinebeg;
     598:         artpos = alinebeg;
     599:     }
     600:     return PS_NORM;
     601:     case '!':           /* shell escape */
     602:     escapade();
     603:     return PS_ASK;
     604: #ifdef INNERSEARCH
     605:     case Ctl('i'):
     606:     gline = 3;
     607:     sprintf(cmd_buf,"^[^%c]",*blinebeg);
     608:     compile(&gcompex,cmd_buf,TRUE,TRUE);
     609:     goto caseG;
     610:     case Ctl('g'):
     611:     gline = 3;
     612:     compile(&gcompex,"^Subject:",TRUE,TRUE);
     613:     goto caseG;
     614:     case 'g':       /* in-article search */
     615:     if (!finish_command(FALSE))/* get rest of command */
     616:         return PS_ASK;
     617:     s = buf+1;
     618:     if (isspace(*s))
     619:         s++;
     620:     if ((s = compile(&gcompex,s,TRUE,TRUE)) != Nullch) {
     621:                 /* compile regular expression */
     622:         printf("\n%s\n",s) FLUSH;
     623:         return PS_ASK;
     624:     }
     625:     carriage_return();
     626:     erase_eol();    /* erase the prompt */
     627:     /* FALL THROUGH */
     628:     caseG:
     629:     case 'G': {
     630:     /* ART_LINE lines_to_skip = 0; */
     631:     ART_POS start_where;
     632:
     633:     if (gline < 0 || gline > LINES-2)
     634:         gline = LINES-2;
     635: #ifdef DEBUGGING
     636:     if (debug & DEB_INNERSRCH)
     637:         printf("Start here? %d  >=? %d\n",topline + gline + 1,artline)
     638:           FLUSH;
     639: #endif
     640:     if (*buf == Ctl('i') || topline+gline+1 >= artline)
     641:         start_where = artpos;
     642:             /* in case we had a line wrap */
     643:     else {
     644:         start_where = vrdary(topline+gline+1);
     645:         if (start_where < 0)
     646:         start_where = -start_where;
     647:     }
     648:     if (start_where < htype[PAST_HEADER].ht_minpos)
     649:         start_where = htype[PAST_HEADER].ht_minpos;
     650:     fseek(artfp,(long)start_where,0);
     651:     innersearch = 0; /* assume not found */
     652:     while (fgets(buf, sizeof buf, artfp) != Nullch) {
     653:         /* lines_to_skip++; 		NOT USED NOW */
     654: #ifdef DEBUGGING
     655:         if (debug & DEB_INNERSRCH)
     656:         printf("Test %s",buf) FLUSH;
     657: #endif
     658:         if (execute(&gcompex,buf) != Nullch) {
     659:         innersearch = ftell(artfp);
     660:         break;
     661:         }
     662:     }
     663:     if (!innersearch) {
     664:         fseek(artfp,artpos,0);
     665:         fputs("(Not found)",stdout) FLUSH;
     666:         return PS_ASK;
     667:     }
     668: #ifdef DEBUGGING
     669:     if (debug & DEB_INNERSRCH)
     670:         printf("On page? %ld <=? %ld\n",(long)innersearch,(long)artpos)
     671:           FLUSH;
     672: #endif
     673:     if (innersearch <= artpos) {    /* already on page? */
     674:         if (innersearch < artpos) {
     675:         artline = topline+1;
     676:         while (vrdary(artline) < innersearch)
     677:             artline++;
     678:         }
     679:         highlight = artline - 1;
     680: #ifdef DEBUGGING
     681:         if (debug & DEB_INNERSRCH)
     682:         printf("@ %d\n",highlight) FLUSH;
     683: #endif
     684:         topline = highlight - gline;
     685:         if (topline < -1)
     686:         topline = -1;
     687:         *buf = '\f';        /* fake up a refresh */
     688:         innersearch = 0;
     689:         return page_switch();
     690:     }
     691:     else {              /* who knows how many lines it is? */
     692:         do_fseek = TRUE;
     693:         hide_everything = TRUE;
     694:     }
     695:     return PS_NORM;
     696:     }
     697: #else
     698:     case 'g': case 'G': case Ctl('g'):
     699:     notincl("g");
     700:     return PS_ASK;
     701: #endif
     702:     case '\n':      /* one line */
     703:     special = TRUE;
     704:     slines = 2;
     705:     return PS_NORM;
     706: #ifdef ROTATION
     707:     case 'X':
     708:     rotate = !rotate;
     709:     /* FALL THROUGH */
     710: #endif
     711:     case 'l':
     712:     case '\f':      /* refresh screen */
     713: #ifdef DEBUGGING
     714:     if (debug & DEB_INNERSRCH) {
     715:         printf("Topline = %d",topline) FLUSH;
     716:         gets(buf);
     717:     }
     718: #endif
     719:     clear();
     720:     do_fseek = TRUE;
     721:     artline = topline;
     722:     if (artline < 0)
     723:         artline = 0;
     724:     firstpage = (topline < 0);
     725:     return PS_NORM;
     726:     case 'b':
     727:     case '\b':          /* I like backspace for this -- PWP */
     728:                     /* Leaving it undocumented in case */
     729:                     /* I want to steal the key--LAW */
     730:     case Ctl('b'): {    /* back up a page */
     731:     ART_LINE target;
     732:
     733: #ifndef CLEAREOL
     734:     clear();
     735: #else
     736:     if (can_home_clear) /* if we can home do it -- PWP */
     737:         home_cursor();
     738:     else
     739:         clear();
     740:
     741: #endif CLEAREOL
     742:     do_fseek = TRUE;    /* reposition article file */
     743:     target = topline - (LINES - 2);
     744:     artline = topline;
     745:     do {
     746:         artline--;
     747:     } while (artline >= 0 && artline > target &&
     748:         vrdary(artline-1) >= 0);
     749:     topline = artline;
     750:             /* remember top line of screen */
     751:             /*  (line # within article file) */
     752:     if (artline < 0)
     753:         artline = 0;
     754:     firstpage = (topline < 0);
     755:     return PS_NORM;
     756:     }
     757:     case 'h': {     /* help */
     758:     int cmd;
     759:
     760:     if ((cmd = help_page()) > 0)
     761:         pushchar(cmd);
     762:     return PS_ASK;
     763:     }
     764:     case '\177':
     765:     case '\0':      /* treat del,break as 'n' */
     766:     *buf = 'n';
     767:     /* FALL THROUGH */
     768:     case 'k':   case 'K':
     769:     case 'n':   case 'N':   case Ctl('n'):
     770:     case 's':   case 'S':
     771:     case 'u':
     772:     case 'w':   case 'W':
     773:     case '|':
     774:     mark_as_read(art);  /* mark article as read */
     775:     /* FALL THROUGH */
     776:     case '#':
     777:     case '$':
     778:     case '&':
     779:     case '-':
     780:     case '.':
     781:     case '/':
     782:     case '1': case '2': case '3': case '4': case '5':
     783:     case '6': case '7': case '8': case '9':
     784:     case '=':
     785:     case '?':
     786:     case 'c':   case 'C':
     787:     case 'f':   case 'F':
     788:     case 'j':
     789:                 case Ctl('k'):
     790:     case 'm':   case 'M':
     791:     case 'p':   case 'P':   case Ctl('p'):
     792:         case 'Q':
     793:     case 'r':   case 'R':   case Ctl('r'):
     794:     case 'v':
     795:         case 'Y':
     796: #ifndef ROTATION
     797:     case 'x':   case 'X':
     798: #endif
     799:     case Ctl('x'):
     800:     case '^':
     801:
     802: #ifdef ROTATION
     803:     rotate = FALSE;
     804: #endif
     805:     reread = FALSE;
     806:     do_hiding = TRUE;
     807:     if (index("nNpP",*buf) == Nullch &&
     808:       index("wWsS!&|/?123456789.",*buf) != Nullch) {
     809:         setdfltcmd();
     810:         standout();     /* enter standout mode */
     811:         printf(prompt,mailcall,dfltcmd);
     812:                 /* print prompt, whatever it is */
     813:         un_standout();  /* leave standout mode */
     814:         putchar(' ');
     815:         fflush(stdout);
     816:     }
     817:     return PS_RAISE;    /* and pretend we were at end */
     818: #ifdef ROTATION
     819:     case 'x':
     820:     rotate = TRUE;
     821:     /* FALL THROUGH */
     822: #endif
     823:     case 'y':
     824:     case Ctl('v'):      /* I like emacs -- PWP */
     825:                     /* Leaving it undocumented in case */
     826:                     /* I want to steal the key--LAW */
     827:     case ' ':   /* continue current article */
     828:     if (erase_screen) { /* -e? */
     829: #ifndef CLEAREOL
     830:         clear();        /* clear screen */
     831: #else
     832:         if (can_home_clear) /* if we can home do it -- PWP */
     833:         home_cursor();
     834:         else
     835:         clear();    /* else clear screen */
     836:
     837: #endif CLEAREOL
     838:         if (*blinebeg != '\f'
     839: #ifdef CUSTOMLINES
     840:           && (!pagestop || blinebeg != art_buf ||
     841:               !execute(&page_compex,blinebeg))
     842: #endif
     843:           ) {
     844:         restart = blinebeg;
     845:         artline--;   /* restart this line */
     846:         artpos = alinebeg;
     847:         if (marking)    /* and mark repeated line */
     848:             highlight = artline;
     849:         }
     850:         topline = artline;
     851:             /* and remember top line of screen */
     852:             /*  (line # within article file) */
     853:     }
     854:     else if (marking && *blinebeg != '\f'
     855: #ifdef CUSTOMLINES
     856:       && (!pagestop || blinebeg != art_buf ||
     857:           !execute(&page_compex,blinebeg))
     858: #endif
     859:       ) {
     860:                 /* are we marking repeats? */
     861:         up_line();      /* go up one line */
     862:         highlight = --artline;/* and get ready to highlight */
     863:         restart = blinebeg; /*   the old line */
     864:         artpos = alinebeg;
     865:     }
     866:     return PS_NORM;
     867:     case 'q':   /* quit this article? */
     868:     do_hiding = TRUE;
     869:     return PS_TOEND;
     870:     default:
     871:     fputs(hforhelp,stdout) FLUSH;
     872:     settle_down();
     873:     return PS_ASK;
     874:     }
     875: }
     876:
     877: #ifdef INNERSEARCH
     878: bool
     879: innermore()
     880: {
     881:     if (artpos < innersearch) {     /* not even on page yet? */
     882: #ifdef DEBUGGING
     883:     if (debug & DEB_INNERSRCH)
     884:         printf("Not on page %ld < %ld\n",(long)artpos,(long)innersearch)
     885:           FLUSH;
     886: #endif
     887:     return TRUE;
     888:     }
     889:     if (artpos == innersearch) {    /* just got onto page? */
     890:     isrchline = artline;        /* remember first line after */
     891:     highlight = artline - 1;
     892: #ifdef DEBUGGING
     893:     if (debug & DEB_INNERSRCH)
     894:         printf("There it is %ld = %ld, %d @ %d\n",(long)artpos,
     895:         (long)innersearch,hide_everything,highlight) FLUSH;
     896: #endif
     897:     if (hide_everything) {      /* forced refresh? */
     898:         topline = highlight - gline;
     899:         if (topline < -1)
     900:         topline = -1;
     901:         return FALSE;       /* let refresh do it all */
     902:     }
     903:     }
     904: #ifdef DEBUGGING
     905:     if (debug & DEB_INNERSRCH)
     906:     printf("Not far enough? %d <? %d + %d\n",artline,isrchline,gline)
     907:       FLUSH;
     908: #endif
     909:     if (artline < isrchline + gline) {
     910:     return TRUE;
     911:     }
     912:     return FALSE;
     913: }
     914: #endif

#### Defined functions

art_init defined in line 75; used 2 times

- in /usr/src/new/rn/art.h line 16
- in /usr/src/new/rn/init.c line 169

do_article defined in line 81; used 2 times

- in /usr/src/new/rn/art.h line 17
- in /usr/src/new/rn/ng.c line 423

innermore defined in line 878; used 2 times

- in line 176
- in /usr/src/new/rn/art.h line 19

page_switch defined in line 579; used 3 times

- in line 562, 689
- in /usr/src/new/rn/art.h line 18

#### Defined variables

alinebeg defined in line 59; used 4 times

- in line 201, 598, 846, 864

art_buf defined in line 73; used 32 times

- in line 92, 135-139(3), 191-210(14), 217-227(4), 235-242(3), 253-258(2), 301-302(2), 591, 840, 856

blinebeg defined in line 58; used 16 times

- in line 200, 404, 482, 589-597(4), 607, 838-844(4), 854-857(3), 863

bool defined in line 878; never used
highlight defined in line 55; used 16 times

- in line 272, 311, 357, 404, 416, 464, 470, 596, 679-684(3), 848, 862, 891-898(3)

innersearch defined in line 62; used 14 times

- in line 176, 491, 651, 659-663(2), 670-676(4), 688, 881-889(3), 895

isrchline defined in line 64; used 3 times

- in line 890, 906-909(2)

restart defined in line 56; used 14 times

- in line 131, 168, 186-188(3), 388, 433-438(2), 448, 481-482(2), 597, 844, 863

slines defined in line 54; used 3 times

- in line 178, 588, 704

#### Defined macros

PS_ASK defined in line 49; used 7 times

- in line 603, 616, 623, 666, 700, 762, 873

PS_NORM defined in line 48; used 6 times

- in line 600, 695, 705, 725, 755, 866

PS_RAISE defined in line 50; used 1 times

- in line 817

PS_TOEND defined in line 51; used 1 times

- in line 869

Last modified: 1987-03-16 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 2579 |