home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 14view / message.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.1 KB  |  73 lines

  1. /*
  2.  *    message -- routines used to display and clear
  3.  *    messages in a reserved message area
  4.  */
  5.  
  6. #include "message.h"
  7.  
  8. MESSAGE Ml;
  9. extern int writec(char, int, int);
  10.  
  11. /*
  12.  *    set up the message-line manager
  13.  */
  14.  
  15. void
  16. initmsg(r, c, w, a, pg)
  17. int r;            /* message row */
  18. int c;            /* message column */
  19. int w;            /* width of message field */
  20. unsigned char a;    /* message field video attribute */
  21. int pg;            /* active page for messages */
  22. {
  23.     MESSAGE *mp;
  24.     void clrmsg();
  25.  
  26.     mp = &Ml;
  27.     mp->m_row = r;
  28.     mp->m_col = c;
  29.     mp->m_wid = w;
  30.     mp->m_attr = a;
  31.     mp->m_pg = pg;
  32.     mp->m_flag = 1;
  33.     clrmsg();
  34. }
  35.  
  36.  
  37. /*
  38.  *    showmsg -- display a message and set the message flag
  39.  */
  40.  
  41. void
  42. showmsg(msg)
  43. char *msg;
  44. {
  45.     MESSAGE *mp;
  46.  
  47.     mp = &Ml;
  48.     putcur(mp->m_row, mp->m_col, mp->m_pg);
  49.     writec(' ', mp->m_wid, mp->m_pg);
  50.     putstr(msg, mp->m_pg);
  51.     mp->m_flag = 1;
  52.     return;
  53. }
  54.  
  55.  
  56. /* 
  57.  *    clrmsg -- erase the message area and reset the message flag
  58.  */
  59.  
  60. void
  61. clrmsg()
  62. {
  63.     MESSAGE *mp;
  64.  
  65.     mp = &Ml;
  66.     if (mp->m_flag != 0) {
  67.         putcur(mp->m_row, mp->m_col, mp->m_pg);
  68.         writec(' ', mp->m_wid, mp->m_pg);
  69.         mp->m_flag = 0;
  70.     }
  71.     return;
  72. }
  73.