home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / mush5.7 / part06 / curses.c next >
Encoding:
C/C++ Source or Header  |  1987-09-17  |  17.1 KB  |  617 lines

  1. /* @(#)curses.c    (c) copyright 3/18/87 (Dan Heller) */
  2.  
  3. /* curses.c -- routine to deal with the curses interface */
  4. #ifdef CURSES
  5.  
  6. #include "mush.h"
  7. #include "bindings.h"
  8.  
  9. curses_init(argc, argv)
  10. register char **argv;
  11. {
  12.     char buf[80];
  13.     extern char *UP, ttytype[];
  14.  
  15.     if (argv && *++argv && !strcmp(*argv, "-?"))
  16.     return help(0, "curses", cmd_help);
  17.     if (iscurses) {
  18.     print("You can't run curses from the curses mode (silly).");
  19.     return -1;
  20.     }
  21.     if (ison(glob_flags, IS_GETTING)) {
  22.     print("Finish your letter first.\n");
  23.     return -1;
  24.     }
  25. #ifdef SUNTOOL
  26.     if (istool) {
  27.     print("My, aren't we the adventuresome type!");
  28.     timerclear(&(mail_timer.it_interval));
  29.     timerclear(&(mail_timer.it_value));
  30.     tool_destroy(tool), istool = FALSE;
  31.     curses_init(0, 0);
  32.     do_loop(); /* doesn't return */
  33.     }
  34. #endif SUNTOOL
  35.  
  36.     /* you can not start curses in no echo mode.. must be in normal mode */
  37.     echo(), nocrmode();
  38.     (void) initscr();
  39. #ifdef SIGCONT
  40.     /* initscr will play with signals -- make sure they're set right. */
  41.     (void) signal(SIGTSTP, stop_start);
  42.     (void) signal(SIGCONT, stop_start);
  43. #endif SIGCONT
  44.     if (!UP || !*UP) {
  45.     print("Terminal type %s can not use the curses interface.\n", ttytype);
  46.     return -1;
  47.     }
  48.     iscurses = TRUE;
  49.     noecho(), crmode(); /* reset tty state -- do not use "echo_on/off()" */
  50.     scrollok(stdscr, TRUE);
  51.     /* if the user hasn't set his screen explicitely, set it for him */
  52.     if (!do_set(set_options, "screen"))
  53.     switch (_tty.sg_ospeed) {
  54.         case B300 : screen = min(LINES-2, 7);
  55.         when B1200 : screen = min(LINES-2, 14);
  56.         when B2400 : screen = min(LINES-2, 22);
  57.         otherwise : screen = LINES-2;
  58.     }
  59.     else
  60.     screen = min(screen, LINES-2);
  61.     crt = LINES;
  62.     if (argc)
  63.     (void) cmd_line(sprintf(buf, "headers %d", current_msg+1), msg_list);
  64.     if (!do_set(set_options, "no_reverse"))
  65.     turnon(glob_flags, REV_VIDEO);
  66.     turnoff(glob_flags, CONT_PRNT);
  67.     return -1; /* doesn't affect messages */
  68. }
  69.  
  70. /*
  71.  * get input in cbreak mode and execute the appropriate command.
  72.  * when the command is done (usually), the user is prompted to
  73.  * hit any key to continue. At this point, the user may enter a
  74.  * new command so no screen refreshing needds to be done. This
  75.  * new command is returned to caller and may be passed back.
  76.  *
  77.  * The variable "cntd_cmd" (continued command) is set to true if
  78.  * this routine is called with the passed parameter (c) > 0. If
  79.  * so, then the character passed is the character input by the
  80.  * user at the last "hit return" prompt indicating that he wants
  81.  * to execute a new command and not draw the screen.
  82.  *
  83.  * cntd_cmd is also set to true if the command that the user invokes
  84.  * causes any sort of output that requires a screen refresh.  The
  85.  * variable redo is set to 1 if the header page not only requires
  86.  * redrawing, but updating ... (new call to do_hdrs)
  87.  *
  88.  * calls that say: print("%s", compose_hdr(current_msg)) are constructed
  89.  * that way cuz if the header has a `%' in it, then print will try to
  90.  * expand it.
  91.  */
  92. curses_command(c)
  93. register int c;
  94. {
  95.     char     buf[BUFSIZ], file[128], list[128];
  96.     int     n, cntd_cmd = (c > 0), curlin;
  97.     static int  redo;  /* set if headers should be redrawn */
  98.  
  99.     clear_msg_list(msg_list); /* play it safe */
  100.     if (!cntd_cmd) {
  101.     (void) check_new_mail();
  102.     curlin = max(1, current_msg - n_array[0] + 1);
  103.     (void) strncpy(buf, stdscr->_y[curlin], COLS-1);
  104.     buf[COLS-1] = 0; /* strncpy does not null terminate */
  105.     if (ison(glob_flags, REV_VIDEO) && msg_cnt)
  106.         STANDOUT(curlin, 0, buf);
  107.     mail_status(0);
  108.     move(curlin, 0), refresh();
  109.     /* reprint to remove reverse video from current line (don't refresh) */
  110.     if (ison(glob_flags, REV_VIDEO))
  111.         mvaddstr(curlin, 0, buf);
  112.     c = getcmd(); /* get input AFTER line redrawn without reverse video */
  113.     }
  114.     buf[0] = list[0] = file[0] = '\0';
  115.  
  116.     /* goto a specific line number */
  117.     if (c == C_GOTO_MSG) {
  118.     c = C_NULL;
  119.     if (msg_cnt <= 1)
  120.         print("Not enough messages.");
  121.     else if (curses_msg_list(strcpy(buf, "goto msg: "), list, msg_list)) {
  122.         for (n = 0; !msg_bit(msg_list, n); n++)
  123.         ;
  124.         if ((current_msg = n) < n_array[0] || n > n_array[screen-1])
  125.         redo = 1;
  126.     }
  127.     if (cntd_cmd && msg_cnt)
  128.         print("%s", compose_hdr(current_msg));
  129.     if (cntd_cmd)
  130.         putchar('\n');
  131.     } else if (c == C_WRITE_LIST || c == C_SAVE_LIST || c == C_COPY_LIST
  132.                    || c == C_DELETE_LIST || c == C_UNDEL_LIST) {
  133.     
  134.     if (msg_cnt <= 1)
  135.         print("Not enough messages."), c = C_NULL;
  136.     else if (!curses_msg_list(sprintf(buf, "%s msg list: ",
  137.         (c == C_WRITE_LIST)? "write" : (c == C_SAVE_LIST)?  "save" :
  138.         (c == C_DELETE_LIST)? "delete" : "undelete"), list, msg_list))
  139.         c = C_NULL;
  140.     if (cntd_cmd)
  141.         putchar('\n');
  142.     }
  143.  
  144.     /* first do non-mail command stype stuff */
  145.     switch (c) {
  146.     case C_NULL : ;
  147.  
  148.     /* screen optimization stuff */
  149.     when C_REVERSE :
  150.         if (ison(glob_flags, REV_VIDEO))
  151.         turnoff(glob_flags, REV_VIDEO);
  152.         else
  153.         turnon(glob_flags, REV_VIDEO);
  154.  
  155.     when C_REDRAW : if (!redo) redraw();
  156.  
  157.     /*
  158.      * screen movement
  159.      */
  160.     when C_NEXT_MSG :
  161.     /* case 'j' : case 'J' : case '+' : case '\n' : /* next */
  162.         if (current_msg + 2 > msg_cnt || !cntd_cmd && curlin == screen)
  163.         bell(); /* reached the end */
  164.         else {
  165.         if (++current_msg > n_array[screen-1])
  166.             redo = 1;
  167.         if (cntd_cmd)
  168.             print("%s", compose_hdr(current_msg)), putchar('\n');
  169.         }
  170.     when C_PREV_MSG :
  171.     /* when 'k' : case 'K' : case '-' : case CTRL(k) : /* previous */
  172.         if (!cntd_cmd && curlin == 1 || current_msg == 0)
  173.         bell();  /* at the beginning */
  174.         else {
  175.         if (--current_msg < n_array[0])
  176.             redo = 1;
  177.         if (cntd_cmd)
  178.             print("%s", compose_hdr(current_msg)), putchar('\n');
  179.         }
  180.     when C_FIRST_MSG : case C_LAST_MSG :
  181.         n = current_msg;
  182.         if (c == C_FIRST_MSG && (current_msg = 0) < n_array[0] ||
  183.         c == C_LAST_MSG && (current_msg = msg_cnt-1)> n_array[screen-1])
  184.         if (!cntd_cmd)
  185.             (void) cmd_line(sprintf(buf, "headers %d", current_msg+1),
  186.                  msg_list);
  187.         else
  188.             redo = 1;
  189.         if (cntd_cmd && n != current_msg)
  190.         print("%s", compose_hdr(current_msg)), putchar('\n');
  191.     /* top and bottom of headers screen */
  192.     when C_TOP_PAGE : case C_BOTTOM_PAGE :
  193.         if (!cntd_cmd)
  194.         if (c == C_TOP_PAGE)
  195.             current_msg = n_array[0];
  196.         else
  197.             current_msg = min(n_array[screen-1], msg_cnt-1);
  198.         else
  199.         bell();
  200.     when C_NEXT_SCREEN : /* next page */
  201.         if (msg_cnt > screen) {
  202.         (void) cmd_line(strcpy(buf, "headers +"), msg_list);
  203.         current_msg = n_array[0];
  204.         return redo = 0;
  205.         } else
  206.         bell();
  207.     when C_PREV_SCREEN : /* previous page */
  208.         if (current_msg > 0 || cntd_cmd)
  209.         (void) cmd_line(strcpy(buf, "headers -"), msg_list), redo = 0;
  210.         current_msg = (msg_cnt <= 1)? 0 : n_array[0];
  211.         return 0;
  212.         /* break;  (not stated for lint) */
  213.  
  214.     case C_SHOW_HDR :
  215.         if (cntd_cmd && msg_cnt)
  216.         puts(compose_hdr(current_msg));
  217.  
  218.     /* read from/save to record file (.mushrc) */
  219.     when C_SOURCE : case C_SAVEOPTS :
  220.         print("%s filename [default]: ",
  221.         (c == C_SOURCE)? "source" : "save options to");
  222.         if (Getstr(file, LINES-40, 0) < 0) {
  223.         clr_bot_line();
  224.         return 0;
  225.         }
  226.         iscurses = FALSE;
  227.         turnon(glob_flags, PRE_CURSES);
  228.         (void) cmd_line(sprintf(buf, "%s %s",
  229.         (c == C_SOURCE) ? "source" : "saveopts", file), msg_list);
  230.         iscurses = TRUE;
  231.         turnoff(glob_flags, PRE_CURSES);
  232.         cntd_cmd = 1;
  233.  
  234.     /*
  235.      * search commands
  236.      */
  237.     when C_NEXT_SEARCH : case C_PREV_SEARCH : case C_CONT_SEARCH :
  238.         if (c != C_CONT_SEARCH)
  239.         c = search(0 + (c == C_PREV_SEARCH));
  240.         else
  241.         c = search(-1);
  242.         if (cntd_cmd)
  243.         putchar('\n');
  244.         if (c == 0)
  245.         break;
  246.         if (cntd_cmd)
  247.         print("%s", compose_hdr(current_msg)), putchar('\n');
  248.         if (n_array[0] > current_msg || n_array[screen-1] < current_msg) {
  249.         redo = 1;
  250.         if (!cntd_cmd)
  251.             (void) cmd_line(sprintf(buf, "headers %d",
  252.                         current_msg+1), msg_list);
  253.         }
  254.  
  255.     /*
  256.      * actions on messages
  257.      */
  258.     /* delete/undelete */
  259.     when C_DELETE_MSG : case C_DELETE_LIST :
  260.     case C_UNDEL_MSG : case C_UNDEL_LIST :
  261.         if (!msg_cnt) {
  262.         print("No messages.");
  263.         if (cntd_cmd)
  264.             putchar('\n');
  265.         break;
  266.         }
  267.         if (!*list)
  268.         set_msg_bit(msg_list, current_msg);
  269.         turnon(glob_flags, DO_UPDATE);
  270.         for (n = 0; n < msg_cnt; n++)
  271.         if (msg_bit(msg_list, n)) {
  272.             if (c == C_DELETE_MSG || c == C_DELETE_LIST)
  273.             turnon(msg[n].m_flags, DELETE);
  274.             else
  275.             turnoff(msg[n].m_flags, DELETE);
  276.             if (!cntd_cmd && msg_cnt < screen ||
  277.             !cntd_cmd && n >= n_array[0] && n <= n_array[screen-1])
  278.             mvaddstr(max(1, n - n_array[0] + 1), 0, compose_hdr(n));
  279.             else
  280.             redo = 1;
  281.         }
  282.         if (cntd_cmd || *list) {
  283.         if (cntd_cmd) { /* print(), THEN putchar() -- overwrite line */
  284.             print("%sdeleted %s",
  285.             (c == C_DELETE_MSG || c == C_DELETE_LIST)? "":"un", list);
  286.             putchar('\n');
  287.         }
  288.         if (ison(msg[current_msg].m_flags, DELETE))
  289.             (void) next_msg(FALSE, DELETE);
  290.         if (do_set(set_options, "autoprint"))
  291.             return C_DISPLAY_MSG;
  292.         if (cntd_cmd)
  293.             puts(compose_hdr(current_msg));
  294.         }
  295.  
  296.     /*
  297.      * write/save messages.  If a list is necessary, the user already
  298.      * entered it above since he must have used a capital letter. If so,
  299.      * list will contain good data (already been validated above).
  300.      * if a list is given, set iscurses to 0 so that print statements
  301.      * will scroll and the user sees the multiple output. else, one
  302.      * line can go on the bottom line just fine.
  303.      */
  304.     when C_WRITE_MSG : case C_SAVE_MSG : case C_COPY_MSG :
  305.     case C_WRITE_LIST : case C_SAVE_LIST : case C_COPY_LIST : {
  306.         register char *p =
  307.         (c == C_WRITE_MSG || c == C_WRITE_LIST)? "write" :
  308.         (c == C_SAVE_MSG  || c == C_SAVE_LIST)?  "save"  : "copy";
  309.         print(sprintf(buf, "filename to %s [mbox]: ", p));
  310.         if (Getstr(file, COLS-1-strlen(buf), 0) >= 0) {
  311.         char *argv[3];
  312.         clr_bot_line();
  313.         argv[0] = strcpy(buf, p);
  314.         argv[1] = file;
  315.         argv[2] = NULL;
  316.         if (!*list)
  317.             set_msg_bit(msg_list, current_msg);
  318.         move(LINES-1, 0), refresh();
  319.         if (*list)
  320.             iscurses = FALSE;
  321.         turnon(glob_flags, IS_PIPE);
  322.         if (save_msg(2, argv, msg_list) < 0)
  323.             *list = 0;
  324.         turnoff(glob_flags, IS_PIPE);
  325.         if (cntd_cmd)
  326.             putchar('\n'), puts(compose_hdr(current_msg));
  327.         if (*list)
  328.             iscurses = cntd_cmd = redo = TRUE;
  329.         else if (!cntd_cmd && msg_cnt)
  330.             mvaddstr(curlin, 0, compose_hdr(current_msg));
  331.         } else {
  332.         print("No messages saved.");
  333.         if (cntd_cmd)
  334.             putchar('\n');
  335.         }
  336.     }
  337.  
  338.     /* preserve message */
  339.     when C_PRESERVE :
  340.         if (!msg_cnt) {
  341.         print("No messages.");
  342.         if (cntd_cmd)
  343.             putchar('\n');
  344.         break;
  345.         }
  346.         if (ison(msg[current_msg].m_flags, PRESERVE))
  347.         turnoff(msg[current_msg].m_flags, PRESERVE);
  348.         else
  349.         turnon(msg[current_msg].m_flags, PRESERVE);
  350.         if (cntd_cmd) {
  351.         print("%s", compose_hdr(current_msg)), putchar('\n');
  352.         redo = 1;
  353.         } else
  354.         mvaddstr(curlin, 0, compose_hdr(current_msg));
  355.  
  356.     /* order messages (sort) and rediesplay the headers */
  357.     when C_SORT : case C_REV_SORT :
  358.         (void) strcpy(file, "sort");
  359.         if (c == C_REV_SORT) {
  360.         print("Reverse "), turnon(glob_flags, CONT_PRNT);
  361.         (void) strcat(file, " -");
  362.         }
  363.         print("Order messages by [Status, date, subject, author]: ");
  364.         if ((c = getchar()) == 's' || c == 'S' || c == 'd' || c == 'a') {
  365.         print("reordering messages...");
  366.         (void) cmd_line(sprintf(buf, "%s %c", file, c), msg_list);
  367.         print_more("done.");
  368.         if (cntd_cmd)
  369.             putchar('\n'), puts(compose_hdr(current_msg));
  370.         redo = 1;
  371.         } else
  372.         clr_bot_line();
  373.  
  374.     when C_QUIT_HARD :
  375.         (void) quit(0, DUBL_NULL);
  376.         redo = 1; /* new mail must have come in */
  377.  
  378.     /* quit or update -- vrfy_update (returns 1 if updated) */
  379.     when C_QUIT : case C_UPDATE :
  380.         if (!vrfy_update(&cntd_cmd, &redo))
  381.         if (c == C_UPDATE)
  382.             break;
  383.         else
  384.             turnoff(glob_flags, DO_UPDATE);
  385.         if (c == C_QUIT) {
  386.         putchar('\n');
  387.         cleanup(0);
  388.         redo = 1;
  389.         }
  390.  
  391.     when C_EXIT : case C_EXIT_HARD :
  392.         clr_bot_line();
  393.         iscurses = FALSE;
  394.         if (c != C_EXIT && c != C_EXIT_HARD)
  395.         putchar('\n');
  396.         cleanup(0);
  397.  
  398.     /* change to a new folder */
  399.     when C_FOLDER :
  400.         for (;;) {
  401.         print("New folder (?=list): ");
  402.         if (Getstr(file, COLS-22, 0) > 0) {
  403.             if (!strcmp(file, "?")) {
  404.             clr_bot_line();
  405.             iscurses = 0;
  406.             puts("folders in your folder directory:");
  407.             (void) cmd_line(strcpy(buf, "folders"), msg_list);
  408.     puts("Precede folder names with a +. `%' to specify system mailbox.");
  409.             cntd_cmd = iscurses = 1;
  410.             continue;
  411.             }
  412.             clearok(stdscr, FALSE);
  413.             if (strcmp(file, "-?"))
  414.             vrfy_update(&cntd_cmd, &redo);
  415.             move(LINES-1, 0), refresh();
  416.             if (cmd_line(sprintf(buf, "folder ! -N %s", file),
  417.                  msg_list) == -1) {
  418.             /* error message was printed; leave room to read it */
  419.             putchar('\n');
  420.             cntd_cmd = 1, redo = 0;
  421.             } else
  422.             redo = 1, cntd_cmd = 0;
  423.             break;
  424.         } else {
  425.             print("\"%s\" unchanged.", mailfile);
  426.             if (cntd_cmd)
  427.             putchar('\n');
  428.             break;
  429.         }
  430.         }
  431.  
  432.     /* shell escape */
  433.     when C_SHELL_ESC :
  434.         print("Shell command: ");
  435.         if (Getstr(file, COLS-24, 0) < 0)
  436.         clr_bot_line();
  437.         else {
  438.         putchar('\n');
  439.         iscurses = FALSE;
  440.         (void) cmd_line(sprintf(buf, "sh %s", file), msg_list);
  441.         iscurses = TRUE;
  442.         cntd_cmd = 1;
  443.         }
  444.  
  445.     /* do a line-mode like command */
  446.     when C_CURSES_ESC :
  447.         print(":");
  448.         if (Getstr(buf, COLS-2, 0) < 0)
  449.         break;
  450.         putchar('\n');
  451.         iscurses = FALSE;
  452.         if (!*buf) {
  453.         /* return -1 because iscurses = 0 is not enough! */
  454.         redo = 0;
  455.         endwin(); /* this turns echoing back on! */
  456.         echo_off();
  457.         return -1;
  458.         }
  459.         (void) cmd_line(buf, msg_list);
  460.         /* they may have affected message status or had text output */
  461.         cntd_cmd = redo = 1;
  462.         iscurses = TRUE;
  463.         if (msg_cnt)
  464.         puts(compose_hdr(current_msg));
  465.  
  466.     /* send message to printer */
  467.     when C_PRINT_MSG : lpr(0, DUBL_NULL, msg_list);
  468.  
  469.     /* cd */
  470.     when C_CHDIR :
  471.         print("chdir to [.]: ");
  472.         if (Getstr(file, COLS-12, 0) < 0)
  473.         break;
  474.         clr_bot_line();
  475.         (void) cmd_line(sprintf(buf, "cd %s", file), msg_list);
  476.         if (cntd_cmd)
  477.         putchar('\n');
  478.  
  479.     /* variable settings */
  480.     when C_VAR_SET : case C_IGNORE : case C_ALIAS : case C_OWN_HDR :
  481.         curs_vars(c, &cntd_cmd); /* cntd_cmd is reset if there's output! */
  482.  
  483.     when C_VERSION :
  484.         do_version(); /* duh */
  485.         if (cntd_cmd)
  486.         putchar('\n');
  487.  
  488.     when C_MAIL_FLAGS :
  489.         print("flags [-?]: ");
  490.         if ((c = Getstr(file, COLS-50, 0)) < 0)
  491.         break;
  492.         putchar('\n');
  493.         if (c == 0)
  494.         (void) strcpy(file, "-?");
  495.     /* Fall thru */
  496.     case C_MAIL :
  497.         clr_bot_line();
  498.         iscurses = FALSE;
  499.         (void) cmd_line(sprintf(buf, "mail %s", file), msg_list);
  500.         iscurses = TRUE, cntd_cmd = 1;
  501.         if (msg_cnt)
  502.         print("%s", compose_hdr(current_msg)), putchar('\n');
  503.  
  504.     /* reply to mail */
  505.     when C_REPLY_SENDER : case C_REPLY_ALL : {
  506.         register char *p = (c == C_REPLY_ALL)? "replyall" : "replysender";
  507.         clr_bot_line();
  508.         iscurses = FALSE;
  509.         (void) cmd_line(sprintf(buf, "%s %d", p, current_msg+1),
  510.         msg_list);
  511.         iscurses = TRUE, cntd_cmd = 1;
  512.         if (msg_cnt)
  513.         print("%s", compose_hdr(current_msg)), putchar('\n');
  514.     }
  515.  
  516.     /* type out a message */
  517.     when C_DISPLAY_MSG : case C_TOP_MSG : case C_DISPLAY_NEXT :
  518.         if (!msg_cnt ||
  519.         c != C_DISPLAY_NEXT && ison(msg[current_msg].m_flags, DELETE)) {
  520.         if (!msg_cnt)
  521.             print("No messages.");
  522.         else
  523.             print("Message %d deleted; type 'u' to undelete.",
  524.                       current_msg+1);
  525.         if (cntd_cmd)
  526.             putchar('\n');
  527.         break;
  528.         }
  529.         clr_bot_line();
  530.         iscurses = FALSE;
  531.         if (cntd_cmd)
  532.         putchar('\n');
  533.         if (c == C_DISPLAY_MSG)
  534.         c = cmd_line(strcpy(buf, "type"), msg_list);
  535.         else if (c == C_TOP_MSG)
  536.         c = cmd_line(strcpy(buf, "top"), msg_list);
  537.         else
  538.         c = cmd_line(strcpy(buf, "next"), msg_list);
  539.         if (c > -1)
  540.         cntd_cmd = redo = 1;
  541.         iscurses = TRUE;
  542.         puts(compose_hdr(current_msg));
  543.  
  544.     /* bind a key or string to a command */
  545.     when C_BIND :  case C_UNBIND : {
  546.         char *argv[2];
  547.         argv[0] = (c == C_BIND) ? "bind" : "unbind";
  548.         argv[1] = NULL;
  549.         if (bind_it(0, argv) < -1)
  550.         cntd_cmd = 1;
  551.         else if (cntd_cmd) /* if it was already set anyway */
  552.         putchar('\n');
  553.     }
  554.  
  555.     /* help stuff */
  556.     when C_HELP :
  557.         (void) c_bind(NULL);
  558.         cntd_cmd = 1;
  559.         if (msg_cnt)
  560.         puts(compose_hdr(current_msg));
  561.  
  562.     /* now do interactive stuff as if run from the mush shell */
  563.     otherwise :
  564.         bell();
  565.         if (cntd_cmd) {
  566.         /* use print instead of puts to overwrite hit_return msg */
  567.         print("unknown command"), putchar('\n');
  568.         redo = 1;
  569.         }
  570.     }
  571.  
  572.     if (cntd_cmd) {
  573.     int old_cnt = msg_cnt;
  574.     if (!(c = hit_return()) && !redo && msg_cnt == old_cnt)
  575.         redraw();
  576.     clr_bot_line();
  577.     if (old_cnt !=  msg_cnt)
  578.         redo = 1;
  579.     if (c)
  580.         return c;
  581.     }
  582.     if (redo) {
  583.     n = current_msg;
  584.     clear();
  585.     if (msg_cnt < screen || n_array[0] < n && n < n_array[screen-1])
  586.         (void) do_hdrs(0, DUBL_NULL, NULL);
  587.     else
  588.         (void) cmd_line(sprintf(buf, "headers %d", n+1), msg_list);
  589.     redo = 0;
  590.     }
  591.     return 0;
  592. }
  593.  
  594. vrfy_update(cntd_cmd, redo)
  595. int *cntd_cmd, *redo;
  596. {
  597.     char buf[16];
  598.     int c;
  599.  
  600.     /* update current folder */
  601.     if (ison(glob_flags, DO_UPDATE)) {
  602.     print("Update %s [y]? ", mailfile);
  603.     if ((c = getchar()) == 'n' || c == 'N' || c == 7 || c == 127 || c == 4){
  604.         print("%s unmodified.", mailfile);
  605.         if (*cntd_cmd)
  606.         putchar('\n');
  607.         return 0;
  608.     }
  609.     (void) cmd_line(strcpy(buf, "update"), msg_list);
  610.     if (*cntd_cmd)
  611.         *redo = 1, *cntd_cmd = 0;
  612.     }
  613.     turnoff(glob_flags, DO_UPDATE);
  614.     return 1; /* make sure bottom line is clear and no reverse video */
  615. }
  616. #endif CURSES
  617.