home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / aix-rs6000 / elm2.3.11.AIX3.1.5.Z / elm2.3.11.AIX3.1.5 / src / showmsg_c.c < prev    next >
C/C++ Source or Header  |  1990-04-28  |  9KB  |  324 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: showmsg_c.c,v 4.1 90/04/28 22:44:08 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:    showmsg_c.c,v $
  17.  * Revision 4.1  90/04/28  22:44:08  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  * 
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** This is an interface for the showmsg command line.  The possible
  24.     functions that could be invoked from the showmsg command line are
  25.     almost as numerous as those from the main command line and include
  26.     the following;
  27.  
  28.        |    = pipe this message to command...
  29.        !    = call Unix command
  30.        <    = scan message for calendar info
  31.        b    = bounce (remail) message
  32.        d    = mark message for deletion
  33.        f    = forward message
  34.        g    = group reply
  35.        h    = redisplay this message from line #1, showing headers
  36.        <CR> = redisplay this message from line #1, weeding out headers
  37.        i,q  = move back to the index page (simply returns from function)
  38.        J    = move to body of next message
  39.        j,n  = move to body of next undeleted message
  40.        K    = move to body of previous message
  41.        k    = move to body of previous undeleted message
  42.        m    = mail a message out to someone
  43.        p    = print this (all tagged) message
  44.        r    = reply to this message
  45.        s    = save this message to a maibox/folder 
  46.        t    = tag this message
  47.        u    = undelete message
  48.        x    = Exit Elm NOW 
  49.  
  50.     all commands not explicitly listed here are beeped at.  Use i)ndex
  51.     to get back to the main index page, please.
  52.  
  53.     This function returns when it is ready to go back to the index
  54.     page.
  55. **/
  56.  
  57. #include "headers.h"
  58.  
  59. int    screen_mangled = 0;
  60. char    msg_line[SLEN];
  61. #define store_msg(a)    (void)strcpy(msg_line,a)
  62. #define put_prompt()    PutLine0(LINES-3, 0, "Command:")
  63. #define put_help()    PutLine0(LINES-3, 45, "(Use 'i' to return to index.)")
  64. #define POST_PROMPT_COL    strlen("Command: ")
  65.  
  66.  
  67. int
  68. process_showmsg_cmd(command)
  69. int command;
  70. {
  71.     int     i, intbuf;        /* for dummy parameters...etc */
  72.     int     ch;            /* for arrow keys */
  73.     int    key_offset;        /* for arrow keys */
  74.     int    istagged;        /* for tagging and subsequent msg */
  75.  
  76.     Raw(ON);
  77.  
  78.     while (TRUE) {
  79.       clear_error();
  80.       switch (command) {
  81.         case '?' : if (help(TRUE)) {
  82.              ClearScreen();
  83.              build_bottom();
  84.                } else screen_mangled = TRUE;
  85.                break;
  86.  
  87.         case '|' : put_cmd_name("Pipe", TRUE);
  88.                (void) do_pipe();     /* do pipe - ignore return val */
  89.                ClearScreen();
  90.                build_bottom();
  91.                break; 
  92.  
  93. #ifdef ALLOW_SUBSHELL
  94.         case '!' : put_cmd_name("System call", TRUE);
  95.                (void) subshell();
  96.                ClearScreen();
  97.                build_bottom();
  98.                break;
  99. #endif
  100.  
  101.         case '<' : 
  102. #ifdef ENABLE_CALENDAR
  103.                put_cmd_name("Scan messages for calendar entries", TRUE);
  104.                scan_calendar();
  105. #else
  106.                store_msg("Can't scan for calendar entries!");
  107. #endif
  108.                break;
  109.  
  110.         case '%' : put_cmd_name("Display return address", TRUE);
  111.                get_return(msg_line, current-1);
  112.                break;
  113.  
  114.         case 'b' : put_cmd_name("Bounce message", TRUE);
  115.                remail();
  116.                break;
  117.   
  118.         case 'd' : delete_msg(TRUE, FALSE); /* really delete it, silent */
  119.                if (! resolve_mode)
  120.              store_msg("Message marked for deletion.");
  121.                else
  122.              goto next_undel_msg;
  123.                break;
  124.  
  125.         case 'f' : put_cmd_name("Forward message", TRUE);
  126.                if(forward()) put_border();
  127.                break;
  128.  
  129.         case 'g' : put_cmd_name("Group reply", TRUE);
  130.                (void) reply_to_everyone();
  131.                break;
  132.  
  133.         case 'h' : screen_mangled = 0;
  134.                if (filter) { 
  135.                  filter = 0; 
  136.                  intbuf = show_msg(current); 
  137.                  filter = 1;
  138.              return(intbuf);
  139.                } else
  140.                  return(show_msg(current)); 
  141.  
  142.         case 'q' :
  143.         case 'i' : (void) get_page(current);
  144.                clear_error();        /* zero out pending msg   */
  145.                if (cursor_control)
  146.              transmit_functions(ON);
  147.                screen_mangled = 0;
  148.                return(0);        /* avoid <return> looping */
  149.  
  150. next_undel_msg :    /* a target for resolve mode actions */
  151.  
  152.         case ' ' :
  153.         case 'j' :
  154.         case 'n' : screen_mangled = 0;
  155.                if((i=next_message(current-1, TRUE)) != -1)
  156.              return(show_msg(current = i+1));
  157.                else return(0);
  158.  
  159. next_msg:
  160.         case 'J' : screen_mangled = 0;
  161.                if((i=next_message(current-1, FALSE)) != -1)
  162.              return(show_msg(current = i+1));
  163.                else return(0);
  164.  
  165. prev_undel_msg:
  166.         case 'k' : screen_mangled = 0;
  167.                if((i=prev_message(current-1, TRUE)) != -1)
  168.              return(show_msg(current = i+1));
  169.                else return(0);
  170.  
  171.         case 'K' : screen_mangled = 0;
  172.                if((i=prev_message(current-1, FALSE)) != -1)
  173.              return(show_msg(current = i+1));
  174.                else return(0);
  175.  
  176.         case 'm' : put_cmd_name("Mail message", TRUE);
  177.                if(sendmsg("","","", TRUE, allow_forms, FALSE))
  178.              put_border();
  179.                break;
  180.  
  181.         case 'p' : put_cmd_name("Print message", FALSE);
  182.                print_msg();
  183.                store_msg("Queued for printing.");
  184.                break;
  185.  
  186.         case 'r' : put_cmd_name("Reply to message", TRUE);
  187.                if(reply()) put_border();
  188.                break;
  189.  
  190.         case '>' :
  191.         case 'C' :
  192.         case 's' : put_cmd_name((command != 'C' ? "Save" : "Copy"), TRUE);
  193.                (void) save(&intbuf, TRUE, (command != 'C'));
  194.                if (resolve_mode && command != 'C')
  195.              goto next_undel_msg;
  196.                break;
  197.  
  198.         case 't' : istagged=tag_message(FALSE);    
  199.                if(istagged)
  200.              store_msg("Message tagged.");
  201.                else 
  202.              store_msg("Message untagged.");
  203.                break;
  204.  
  205.         case 'u' : undelete_msg(FALSE); /* undelete it, silently */
  206.                if (! resolve_mode)
  207.              store_msg("Message undeleted.");
  208.                else {
  209. /******************************************************************************
  210.  ** We're special casing the U)ndelete command here *not* to move to the next
  211.  ** undeleted message ; instead it'll blindly move to the next message in the
  212.  ** list.  See 'elm.c' and the command by "case 'u'" for further information.
  213.  ** The old code was:
  214.              goto next_undel_msg;
  215. *******************************************************************************/
  216.              goto next_msg;
  217.                }
  218.                break;
  219.  
  220.         case 'x' : put_cmd_name("Exit", TRUE);
  221.                exit_prog();
  222.                break;
  223.         
  224.         case ctrl('J'):
  225.         case ctrl('M'):  screen_mangled = 0;
  226.                  return(show_msg(current));
  227.  
  228.  
  229.             case ESCAPE : if (cursor_control) {
  230.   
  231.                             key_offset = 1;
  232.   
  233.                             ch = ReadCh(); 
  234.   
  235.                             if (ch == ESCAPE)
  236.                              ch = ReadCh();
  237.   
  238.                             if ( ch == '[' || ch == 'O') 
  239.                             {
  240.                               ch = ReadCh();
  241.                               key_offset++;
  242.                             }
  243.   
  244.                             if (ch == up[key_offset])
  245.                   goto prev_undel_msg;
  246.                             else if (ch == down[key_offset])
  247.                   goto next_undel_msg;
  248.                             else {
  249.                   screen_mangled = 0;
  250.                               return(0);
  251.                 }
  252.                           }
  253.                           else          /* Eat 2 chars for escape codes */
  254.                           {
  255.                             ch = ReadCh();
  256.                             ch = ReadCh();
  257.                             putchar((char) 007);
  258.                             fflush(stdout);
  259.                 screen_mangled = 0;
  260.                             return(0);
  261.                            }
  262.   
  263.         default  : putchar((char) 007);    /* BEEP! */
  264.       }
  265.  
  266.       /* display prompt */
  267.       if (screen_mangled) {
  268.         /* clear what was left over from previous command 
  269.          * and display last generated message.
  270.          */
  271.         put_prompt();
  272.         CleartoEOS();
  273.         put_help();
  274.         Centerline(LINES, msg_line);
  275.         MoveCursor(LINES-3, POST_PROMPT_COL);
  276.       } else {
  277.         /* display bottom line prompt with last generated message */
  278.         MoveCursor(LINES, 0);
  279.         CleartoEOS();
  280.         StartBold();
  281.         Write_to_screen("%s Command ('i' to return to index): ",
  282.         1, msg_line);
  283.         EndBold();
  284.       }
  285.       *msg_line = '\0';    /* null last generated message */
  286.  
  287.       command = ReadCh();    /* get next command from user */
  288.     }
  289. }
  290.  
  291. put_cmd_name(command, will_mangle)
  292. char *command;
  293. int will_mangle;
  294. {
  295.  
  296.     /* If screen is or will be mangled display the command name 
  297.      * and erase the bottom of the screen.
  298.      * But first if the border line hasn't yet been drawn, draw it.
  299.      */
  300.     if(will_mangle && !screen_mangled) {
  301.       build_bottom();
  302.       screen_mangled = TRUE;
  303.     }
  304.     if(screen_mangled) {
  305.       PutLine0(LINES-3, POST_PROMPT_COL, command);
  306.       CleartoEOS();
  307.     }
  308. }
  309.  
  310. put_border()
  311. {
  312.      PutLine0(LINES-4, 0, 
  313. "--------------------------------------------------------------------------\n");
  314. }
  315.  
  316. build_bottom()
  317. {
  318.      MoveCursor(LINES-4, 0);
  319.      CleartoEOS();
  320.      put_border();
  321.      put_prompt();
  322.      put_help();
  323. }
  324.