home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / ELM23-2 / ELM23-2.ZIP / src / help.c < prev    next >
C/C++ Source or Header  |  1993-10-02  |  9KB  |  331 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: help.c,v 4.1 90/04/28 22:43:11 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    help.c,v $
  17.  * Revision 4.1  90/04/28  22:43:11  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /*** help routine for ELM program
  24.  
  25. ***/
  26.  
  27. #include <ctype.h>
  28. #include "headers.h"
  29.  
  30. help(pager_help)
  31. int pager_help;
  32. {
  33.     /** Process the request for help [section] from the user.
  34.         If pager_help is TRUE, then act a little differently from
  35.         if pager_help is FALSE (index screen)
  36.      **/
  37.  
  38.     char ch;        /* character buffer for input */
  39.     char *s;        /* string pointer...          */
  40.     int prompt_line, info_line;
  41.     static char help_message[] =
  42.    "Press the key you want help for, '?' for a key list, or '.' to exit help";
  43.     static char help_prompt[] = "Help for key: ";
  44.  
  45.     MoveCursor(LINES-4,0);
  46.     CleartoEOS();
  47.  
  48.     if(pager_help) {
  49.       put_border();
  50.       Centerline(LINES, help_message);
  51.       prompt_line = LINES-3;
  52.     } else {
  53.       Centerline(LINES-4, "ELM Help System");
  54.       Centerline(LINES-3, help_message);
  55.       prompt_line = LINES-2;
  56.     }
  57.     info_line = prompt_line + 1;
  58.  
  59.     PutLine0(prompt_line, 0, help_prompt);
  60.  
  61.     do {
  62.       MoveCursor(prompt_line, strlen(help_prompt));
  63.       ch = ReadCh();
  64.  
  65.       if (ch == '.') return(0);    /* zero means footer rewrite only */
  66.  
  67.       s = "Unknown command.  Use '?' for a list of commands.";
  68.  
  69.       switch (ch) {
  70.  
  71.         case '?': display_helpfile(pager_help? PAGER_HELP : MAIN_HELP);
  72.               return(1);
  73.  
  74.         case '$': if(!pager_help) s =
  75. "$ = Force resynchronization of the current folder. This will purge deleted mail.";
  76.               break;
  77.  
  78.         case '!': s =
  79.      "! = Escape to the Unix shell of your choice, or just to enter commands.";
  80.                   break;
  81.  
  82.         case '@': if(!pager_help) s =
  83.        "@ = Debug - display a summary of the messages on the header page.";
  84.               break;
  85.  
  86.         case '|': s =
  87.    "| = Pipe the current message or tagged messages to the command specified.";
  88.               break;
  89.  
  90.         case '#': if(!pager_help) s =
  91.         "# = Debug - display all information known about current message.";
  92.               break;
  93.  
  94.         case '%': s =
  95.      "% = Debug - display the computed return address of the current message.";
  96.               break;
  97.  
  98.         case '*': if(!pager_help)
  99.                s = "* = Go to the last message in the current folder.";
  100.               break;
  101.  
  102.         case '-': if(!pager_help) s =
  103. "- = Go to the previous page of messages.  This is the same as the LEFT arrow.";
  104.               break;
  105.  
  106.         case '=': if(!pager_help) s =
  107.             "'=' = Go to the first message in the current folder.";
  108.               break;
  109.  
  110.         case ' ': if(pager_help) s =
  111.   "<space> = Display next screen of current message (or first screen of next).";
  112.               else s = "<space> = Display the current message.";
  113.               break;
  114.  
  115.         case '+': if(!pager_help)
  116.                 s =
  117.   "+ = Go to the next page of messages.  This is the same as the RIGHT arrow.";
  118.               break;
  119.  
  120.         case '/': if(!pager_help)
  121.             s = "/ = Search for specified pattern in folder.";
  122.               break;
  123.  
  124.         case '<': s =
  125.            "< = Scan current message for calendar entries (if enabled).";
  126.               break;
  127.  
  128.         case '>': s =
  129.            "> = Save current message or tagged messages to specified file.";
  130.               break;
  131.  
  132.         case '^': if(!pager_help) s =
  133.            "^ = Toggle the Delete/Undelete status of the current message.";
  134.               break;
  135.  
  136.         case 'a': if(!pager_help) s =
  137.        "a = Enter the alias sub-menu section.  Create and display aliases.";
  138.               break;
  139.  
  140.         case 'b': s =
  141.       "b = Bounce (remail) a message to someone as if you have never seen it.";
  142.               break;
  143.  
  144.         case 'C': s =
  145.                "C = Copy current message or tagged messages to specified file.";
  146.               break;
  147.  
  148.         case 'c': if(!pager_help) s =
  149.      "c = Change folders, leaving the current folder as if 'quitting'.";
  150.               break;
  151.  
  152.         case 'd': s = "d = Mark the current message for future deletion.";
  153.               break;
  154.  
  155.         case ctrl('D') : if(!pager_help) s =
  156.           "^D = Mark for deletion all messages with the specified pattern.";
  157.               break;
  158.  
  159.         case 'e': if(!pager_help) s =
  160.      "e = Invoke the editor on the entire folder, resynchronizing when done.";
  161.               break;
  162.  
  163.         case 'f': s =
  164.     "f = Forward the current message to someone, return address is yours.";
  165.               break;
  166.  
  167.         case 'g': s =
  168.    "g = Group reply not only to the sender, but to everyone who received msg.";
  169.               break;
  170.  
  171.         case 'h': s =
  172.          "h = Display message with all Headers (ignore weedout list).";
  173.                   break;
  174.  
  175.         case 'i': if(pager_help) s = "i = Return to the index.";
  176.               break;
  177.  
  178.         case 'J': s = "J = Go to the next message.";
  179.               break;
  180.  
  181.         case 'j': s =
  182.   "j = Go to the next undeleted message.  This is the same as the DOWN arrow.";
  183.               break;
  184.  
  185.         case 'K': s = "K = Go to the previous message.";
  186.               break;
  187.  
  188.         case 'k': s =
  189. "k = Go to the previous undeleted message.  This is the same as the UP arrow.";
  190.               break;
  191.  
  192.         case 'l': if(!pager_help) s =
  193.                "l = Limit displayed messages based on the specified criteria.";
  194.               break;
  195.  
  196.         case 'm': s =
  197.          "m = Create and send mail to the specified person or persons.";
  198.               break;
  199.  
  200.         case 'n': if(pager_help)
  201.             s = "n = Display the next message.";
  202.               else
  203.             s =
  204.        "n = Display the current message, then move current to next messge.";
  205.               break;
  206.  
  207.         case 'o': if(!pager_help) s = "o = Go to the options submenu.";
  208.                   break;
  209.  
  210.         case 'p': s =
  211.               "p = Print the current message or the tagged messages.";
  212.                   break;
  213.  
  214.         case 'q': if(pager_help) s =
  215.             "q = Quit the pager and return to the index.";
  216.               else s =
  217.             "q = Quit the mailer, asking about deletion, saving, etc.";
  218.               break;
  219.  
  220.         case 'r': s =
  221. "r = Reply to the message.  This only sends to the originator of the message.";
  222.                   break;
  223.  
  224.         case 's': s =
  225.                "s = Save current message or tagged messages to specified file.";
  226.               break;
  227.  
  228.         case 't': s =
  229.                "t = Tag a message for further operations (or untag if tagged).";
  230.               break;
  231.  
  232.         case ctrl('T') : if(!pager_help) s =
  233.                 "^T = Tag all messages with the specified pattern.";
  234.               break;
  235.  
  236.         case 'u': s =
  237.               "u = Undelete - remove the deletion mark on the message.";
  238.               break;
  239.  
  240.         case 'x': s = "x = Exit the mail system quickly.";
  241.               break;
  242.  
  243.         case 'Q': if(!pager_help) s =
  244.         "Q = Quick quit the mailer, save read, leave unread, delete deleted.";
  245.               break;
  246.  
  247.         case '\n':
  248.         case '\r': if(pager_help)
  249.              s =
  250.   "<return> = Display current message, or (builtin pager only) scroll forward.";
  251.                else
  252.              s = "<return> = Display the current message.";
  253.                break;
  254.  
  255.         case ctrl('L'): if(!pager_help) s = "^L = Rewrite the screen.";
  256.                break;
  257.  
  258.             case ctrl('?'):                        /* DEL */
  259.         case ctrl('Q'): if(!pager_help) s = "Exit the mail system quickly.";
  260.                break;
  261.  
  262.         default : if (isdigit(ch) && !pager_help)
  263.                 s = "<number> = Make specified number the current message.";
  264.       }
  265.  
  266.       ClearLine(info_line);
  267.       Centerline(info_line, s);
  268.  
  269.     } while (ch != '.');
  270.  
  271.     /** we'll never actually get here, but that's okay... **/
  272.  
  273.     return(0);
  274. }
  275.  
  276. display_helpfile(section)
  277. int section;
  278. {
  279.     /*** Help me!  Read file 'helpfile.<section>' and echo to screen ***/
  280.  
  281.     char buffer[SLEN];
  282.  
  283.     sprintf(buffer, "%s/%s.%d", helphome, helpfile, section);
  284.     return(display_file(buffer));
  285. }
  286.  
  287. display_file(file)
  288. char *file;
  289. {
  290.     /*** Display file to screen ***/
  291.  
  292.     FILE *fileptr;
  293.     int  lines=0;
  294.     char buffer[SLEN];
  295.  
  296.     if ((fileptr = fopen(file,"r")) == NULL) {
  297.       dprint(1, (debugfile,
  298.          "Error: Couldn't open file %s (help)\n", file));
  299.       error1("Couldn't open file %s.",file);
  300.       return(FALSE);
  301.     }
  302.  
  303.     ClearScreen();
  304.  
  305.     while (fgets(buffer, SLEN, fileptr) != NULL) {
  306.       if (lines > LINES-3) {
  307.         PutLine0(LINES,0,"Press <space> to continue, 'q' to return.");
  308.         if(ReadCh() == 'q') {
  309.           clear_error();
  310.           fclose(fileptr);
  311.           return(TRUE);
  312.         }
  313.         lines = 0;
  314.         ClearScreen();
  315.         Write_to_screen("%s\r", 1, buffer);
  316.       }
  317.       else
  318.         Write_to_screen("%s\r", 1, buffer);
  319.  
  320.       lines += strlen(buffer)/COLUMNS + 1;
  321.     }
  322.  
  323.         PutLine0(LINES,0,"Press any key to return.");
  324.  
  325.     (void) ReadCh();
  326.     clear_error();
  327.  
  328.     fclose(fileptr);
  329.     return(TRUE);
  330. }
  331.