home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / shellforms / part02 / msg.c < prev    next >
C/C++ Source or Header  |  1988-05-09  |  3KB  |  110 lines

  1. /* Last update: 01/13/88  10:59 AM  (Edition: 11) */
  2. #include    <stdio.h>
  3. #include    <strings.h>
  4. #include    "basic.h"
  5. #include    "form.h"
  6. /*
  7.     Two flavors to display message:
  8.  
  9.     form_msg    display message then  position cursor at given
  10.             position, this allows form filling on terminal
  11.             without cursor save restore capability.
  12.  
  13.     formmsg        display  message and return   to  the caller's
  14.             position  using terminal's save/restore cursor
  15.             ability. This is designed to be used  by field
  16.             checking routine where  user don't know  where
  17.             the field is.
  18. */
  19.  
  20. #define MAXSMSG 5
  21. #define MSGSIZE 132
  22.  
  23. int    Form_msg = 0;            /* form message on screen flag */
  24.  
  25. static    char    Savemsg [MAXSMSG][MSGSIZE];
  26. static    int    Sdx = 0;        /* number of next entry to use */
  27. static    int    Smcount = 0;        /* number of messages saved */
  28. /*----------------------------------------------------------------------+
  29. |                                    |
  30. |        form_msg : display message on the message line        |
  31. |                                    |
  32. +----------------------------------------------------------------------*/
  33. form_msg (s, line, col)
  34. char        *s;        /* message to display, if NULL, clear message */
  35. unsigned char    line;        /* line to go at end */
  36. unsigned char    col;        /* column to go at end */
  37.     {
  38.     ENTER (form_msg);
  39.     poscur ((unsigned char)24, (unsigned char)1, (char *)NULL);
  40.     screen (SCR_REVERSE);
  41.     screen (SCR_EEOL);
  42.     if (s) {
  43.         Form_msg = 1;
  44.         put_string (s, 0);
  45.         save_msg (s);
  46.         }
  47.     else    Form_msg = 0;
  48.     poscur (line, col, (char *)NULL);
  49.     EXIT;
  50.     }
  51.  
  52. /*----------------------------------------------------------------------+
  53. |                                    |
  54. |      formmsg : form_msg () use terminal SC, RC feature        |
  55. |                                    |
  56. +----------------------------------------------------------------------*/
  57. formmsg (s)
  58. char    *s;        /* message to display, if NULL, clear message */
  59.     {
  60.     ENTER (formmsg);
  61.     screen (SCR_SAVE);
  62.     poscur ((unsigned char)24, (unsigned char)1, (char *)NULL);
  63.     screen (SCR_REVERSE);
  64.     screen (SCR_EEOL);
  65.     if (s) {
  66.         Form_msg = 1;
  67.         put_string (s, 0);
  68.         save_msg (s);
  69.         }
  70.     else    Form_msg = 0;
  71.     screen (SCR_RESTORE);
  72.     EXIT;
  73.     }
  74.  
  75. /*----------------------------------------------------------------------+
  76. |                                    |
  77. |        save_msg : save a message on the message buffer        |
  78. |                                    |
  79. +----------------------------------------------------------------------*/
  80. save_msg (s)
  81. char    *s;
  82.     {
  83.     ENTER (save_msg);
  84.     strncpy (Savemsg[Sdx], s, MSGSIZE);
  85.     if (++Sdx >= MAXSMSG) Sdx = 0;
  86.     if (Smcount < MAXSMSG) Smcount++;
  87.     EXIT;
  88.     }
  89.  
  90. /*----------------------------------------------------------------------+
  91. |                                    |
  92. |        prev_msg : display previously displayed message        |
  93. |                                    |
  94. +----------------------------------------------------------------------*/
  95. prev_msg ()
  96.     {
  97.     ENTER (prev_msg);
  98.     if (!Smcount) return (0);
  99.     /* This routine actually pop the message stored */
  100.     if (--Sdx < 0) Sdx = MAXSMSG-1;
  101.     screen (SCR_SAVE);
  102.     poscur ((unsigned char)24, (unsigned char)1, (char *)NULL);
  103.     screen (SCR_REVERSE);
  104.     screen (SCR_EEOL);
  105.     put_string (Savemsg[Sdx], 0);
  106.     Form_msg = 1;
  107.     screen (SCR_RESTORE);
  108.     RETURN (1);
  109.     }
  110.