home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / vn.jan.88 / part04 / help.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-30  |  5.4 KB  |  214 lines

  1. /*
  2. ** vn news reader.
  3. **
  4. ** help.c - print help
  5. **
  6. ** see copyright disclaimer / history in vn.c source file
  7. */
  8. #include <stdio.h>
  9. #include <setjmp.h>
  10. #include "config.h"
  11. #include "tty.h"
  12. #include "tune.h"
  13. #include "node.h"
  14. #include "page.h"
  15. #include "reader.h"
  16. #include "vn.h"
  17.  
  18. extern int L_allow;
  19. extern int C_allow;
  20. extern int Digest;
  21. extern char *Contstr;
  22. extern char Cxptoi[], Cxrtoi[];
  23.  
  24. /*
  25.     Help message table.  Character for command, plus its help
  26.     message.  Table order is order of presentation to user.
  27. */
  28. static struct HELPTAB
  29. {
  30.     char cmd, *msg;
  31.     int dig;
  32.     char *amsg;
  33. Helptab [] =
  34. {
  35.     { QUIT, "quit", 1, NULL},
  36.     { UP, "(or up arrow) move up [number of lines]", 1, NULL},
  37.     { DOWN, "(or down arrow) move down [number of lines]", 1, NULL},
  38. #ifdef PAGEARROW
  39.     { BACK, "(or left arrow) previous page [number of pages]", 1, NULL},
  40.     { FORWARD, "(or right arrow) next page [number of pages]", 1, NULL},
  41. #else
  42.     { BACK, "previous page [number of pages]", 1, NULL},
  43.     { FORWARD, "next page [number of pages]", 1, NULL},
  44. #endif
  45.     { TOPMOVE, "move to top of page", 1, NULL},
  46.     { BOTMOVE, "move to bottom of page", 1, NULL},
  47.     { ALTBOTTOM, "move to bottom of page (alternate L)", 1, NULL},
  48.     { MIDMOVE, "move to middle of page", 1, NULL},
  49.     { DIGEST, "unpack digest", 1, "exit digest"},
  50.     { READ, "read article [number of articles]", 1, NULL},
  51.     { ALTREAD, "read article (alternate 'r')", 1, NULL},
  52.     { READALL, "read all articles on page", 1, NULL},
  53.     { READSTRING, "specify articles to read", 1, NULL},
  54.     { SAVE, "save or pipe article [number of articles]", 1, NULL},
  55.     { SAVEALL, "save or pipe all articles on page", 1, NULL},
  56.     { SAVESTRING, "specify articles to save", 1, NULL},
  57.     { ALTSAVE, "specify articles to save (alternate ctl-s)", 1, NULL},
  58.     { PRINT, "print article [number of articles]", 1, NULL},
  59.     { PRINTALL, "print all article on page", 1, NULL},
  60.     { PRINTSTRING, "specify articles to print", 1, NULL},
  61.     { UPDATE, "update .newsrc status to cursor", 0, NULL},
  62.     { UPALL, "update .newsrc status for whole newsgroup", 0, NULL},
  63.     { UPSEEN, "update .newsrc status for all pages displayed", 0, NULL},
  64.     { ORGGRP, "recover original .newsrc status for newsgroup", 0, NULL},
  65.     { ORGSTAT, "recover all original .newsrc status", 0, NULL},
  66.     { SSTAT, "display count of groups and pages - shown and total", 0, NULL},
  67.     { GRPLIST, "list newsgroups with new article, updated counts", 0, NULL},
  68.     { NEWGROUP, "specify newsgroup to display and/or resubscribe to", 1, NULL},
  69.     { UNSUBSCRIBE, "unsubscribe from group", 0, NULL},
  70.     { MARK, "mark/unmark article [number of articles]", 1, NULL},
  71.     { ART_MARK, "mark/unmark article [number of articles]", 1, NULL},
  72.     { UNMARK, "erase marks on articles", 1, NULL},
  73.     { HEADTOG, "toggle flag for display of headers when reading", 1, NULL},
  74.     { SETROT, "toggle rotation for reading", 1, NULL},
  75.     { REDRAW, "redraw screen", 1, NULL},
  76.     { UNESC, "escape to UNIX to execute a command", 1, NULL},
  77.     { PRTVERSION, "show vn version", 1, NULL},
  78.     { HELP, "show this help menu", 1, NULL}
  79. };
  80.  
  81. #define HTSIZE (sizeof(Helptab)/sizeof(struct HELPTAB))
  82.  
  83. /*
  84.     help from main screen
  85. */
  86. help ()
  87. {
  88.     int i,lcount,lim; 
  89.     term_set (ERASE);
  90.     lim = L_allow + RECBIAS - 2;
  91.     printf("%s\n",HELP_HEAD);
  92.     lcount = HHLINES;
  93.     for (i=0; i < (sizeof(Helptab))/(sizeof(struct HELPTAB)); ++i)
  94.     {
  95.         if (Digest && !(Helptab[i].dig))
  96.             continue;
  97.         ++lcount;
  98.         if (Digest && Helptab[i].amsg != NULL)
  99.             h_print (Cxptoi[Helptab[i].cmd],Helptab[i].amsg);
  100.         else
  101.             h_print (Cxptoi[Helptab[i].cmd],Helptab[i].msg);
  102.         if (lcount >= lim)
  103.         {
  104.             printf ("\n%s",Contstr);
  105.             getnoctl ();
  106.             term_set (MOVE,0,lim+1);
  107.             term_set (ZAP,0,strlen(Contstr));
  108.             term_set (MOVE,0,lim-1);
  109.             putchar ('\n');
  110.             lcount = 0;
  111.         }
  112.     }
  113.     if (lcount > 0)
  114.     {
  115.         printf ("\n%s",Contstr);
  116.         getnoctl ();
  117.     }
  118. }
  119.  
  120. /*
  121.     help from reader
  122. */
  123. help_rd()
  124. {
  125.     h_print (Cxrtoi[PG_NEXT],HPG_NEXT);
  126.     h_print (Cxrtoi[PG_QUIT],HPG_QUIT);
  127.     h_print (Cxrtoi[PG_FLIP],HPG_FLIP);
  128.     h_print (Cxrtoi[PG_REWIND],HPG_REWIND);
  129.     h_print (Cxrtoi[PG_WIND],HPG_WIND);
  130.     h_print (Cxrtoi[PG_SEARCH],HPG_SEARCH);
  131.     h_print (Cxrtoi[PG_STEP],HPG_STEP);
  132.     h_print (Cxrtoi[PG_REPLY],HPG_REPLY);
  133.     h_print (Cxrtoi[PG_FOLLOW],HPG_FOLLOW);
  134.     h_print (Cxrtoi[SAVE],HPG_SAVE);
  135.     h_print (Cxrtoi[PRINT],HPG_PRINT);
  136.     h_print (Cxrtoi[SETROT],HPG_ROT);
  137.     h_print (Cxrtoi[HEADTOG],HPG_HEAD);
  138.     h_print (Cxrtoi[PG_HELP],HPG_HELP);
  139.     printf ("%s\n",HPG_DEF);
  140. }
  141.  
  142. srch_help(c,dig)
  143. char c;
  144. int *dig;
  145. {
  146.     int i;
  147.  
  148.     for (i=0; i < HTSIZE; ++i)
  149.         if (Helptab[i].cmd == c)
  150.             break;
  151.     if (i < HTSIZE)
  152.     {
  153.         *dig = Helptab[i].dig;
  154.         return (0);
  155.     }
  156.     return(-1);
  157. }
  158.  
  159. /*
  160.     h_print prints a character and a legend for a help menu.
  161. */
  162. static
  163. h_print(c,s)
  164. char c,*s;
  165. {
  166.     if (strlen(s) > (C_allow - 14))
  167.         s [C_allow - 14] = '\0';
  168.     if (c > ' ' && c != '\177')
  169.         printf ("     %c - %s\n",c,s);
  170.     else
  171.     {
  172.         switch (c)
  173.         {
  174.         case '\177':
  175.             printf ("  <delete> - %s\n",s);  
  176.             break;
  177.         case '\040':
  178.             printf ("   <space> - %s\n",s);  
  179.             break;
  180.         case '\033':
  181.             printf ("  <escape> - %s\n",s);  
  182.             break;
  183.         case '\n':
  184.             printf ("  <return> - %s\n",s);  
  185.             break;
  186.         case '\t':
  187.             printf ("     <tab> - %s\n",s);  
  188.             break;
  189.         case '\b':
  190.             printf (" <back sp> - %s\n",s);  
  191.             break;
  192.         case '\f':
  193.             printf ("<formfeed> - %s\n",s);  
  194.             break;
  195.         case '\07':
  196.             printf ("    <bell> - %s\n",s);  
  197.             break;
  198.         case '\0':
  199.             printf ("    <null> - %s\n",s);  
  200.             break;
  201.         default:
  202.             if (c < '\033')
  203.             {
  204.                 c += 'a' - 1;
  205.                 printf(" control-%c - %s\n",c,s);
  206.             }
  207.             else
  208.                 printf("       %c0%o - %s\n",'\\',(int) c,s);
  209.             break;
  210.         }
  211.     }
  212. }
  213.